#include <SoftwareSerial.h>
SoftwareSerial gsmSerial(6,7) //GSM Module connect rx - 6 ; tx - 7
void setup(){
Serial.begin(9600);
delay(1000);
gsmSerial.begin(9600);
delay(1000);
gsmSerial.println("AT+CNMI=2,2,0,0,0");
Serial.println("AT+CNMI=2,2,0,0,0");
delay(3000);
}
void loop(){
while(gsmSerial.available()){
gsmSerial.read();
}
while(Serial.available()){
Serial.read();
}
get_gsm();
}
void get_gsm()
{
gsmSerial.listen();
while(gsmSerial.available()>0)
{Serial.println("gsmSerial.available");
if(gsmSerial.find("Hello"))
{Serial.println("SMS with Hello Detected.");
gsmSerial.println("AT+CMGF=1");
delay(1000); // Delay of 1 second
gsmSerial.println("AT+CMGS="+xxxxxxxxxxxx"\r");
delay(1000);
gsmSerial.listen();
Serial.print("SMS Message");
gsmSerial.print("SMS Message");
delay(100);
gsmSerial.println((char)26);
delay(1000);
}
}
}
This is the code, I use an A9G GPS GPRS module and an arduino uno, the A9G communicates with the arduino via serial, this code should do the following, when I send sms with "Hello" with the phone the module send me the message back from gsmSerial.print ("SMS Message"); but
when i send sms with "Hello" with the phone i don't get back message from module, is it something wrong with the code or why it doesn't work? please help me