Dear Friends,
I am trying to receive the SMS to 800L GSM module, and try to read that sms over serial port. I am not able to receive the data over the serial port.But GSM sending the sms
The code is as per below:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11);
void setup()
{
mySerial.begin(9600); // Setting the baud rate of GSM Module
Serial.begin(9600);
mySerial.println("AT+CMGF=1");
delay(500);
mySerial.println("AT+IPR=9600");
delay(100);
}
void loop()
{
if (Serial.available() > 0)
switch (Serial.read())
{
case 's':
SendMessage();
break;
case 'r':
RecieveMessage();
break;
}
if (mySerial.available() > 0)
Serial.write(mySerial.read());
}
void SendMessage()
{
mySerial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
delay(1000); // Delay of 1000 milli seconds or 1 second
mySerial.println("AT+CMGS=\"+91xxxxxxxxxx\"\r"); // Replace x with mobile number
delay(1000);
mySerial.println("I am SMS from GSM Module");// The SMS text you want to send
delay(100);
mySerial.println((char)26);// ASCII code of CTRL+Z
delay(1000);
}
void RecieveMessage()
{
mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
delay(1000);
}