hello there. newbie here. just need some help in interfacing sim900d gsm module to arduino.
i tried sending "AT" serially to the gsm module, then i tried to listen to whatever it will send back.
i should expect an "OK" repsonse from the module. but when i try to use gsmRxTx.read() then print it, i only get trash characters. (by the way i used NewSoftSerial in my program).
could anyone please help me? please. thanks in advance.
here's my code.
#include <stdio.h>
#include <NewSoftSerial.h>
#define powerOn 4
char filter[5];
NewSoftSerial gsmRxTx (2, 3); //(rxpin, txpin) declaration of new rx/tx pin
void setup(){
Serial.begin(9600);
gsmRxTx.begin(9600);
digitalWrite(powerOn, HIGH); //connect powerOn of gsm module to pin 4. this will open gsm module
digitalWrite(powerOn, LOW);
delay(5000);
startUp();
}
void startUp(){
int i;
gsmRxTx.print("AT\r\n"); //send AT serially, expect OK as gsm response
delay(1000);
if (gsmRxTx.available()){ //check if there's any available in serial port
Serial.println("pass");
for (i=0;i<5;i++){
filter[i] = gsmRxTx.read();
Serial.println(filter[i]);
}
}
}
void loop(){
Serial.println("halo");
delay(1000);
}