Hi there
I am trying to do a project with SIM808 module and an Arduin UNO. I want to receive an SMS, process it and make some feedback based on the received SMS. So, I need to record the received SMS in a string so that I can do the process. my code for send and receive is provided here:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(9, 10);
String text="zero";
void setup()
{
mySerial.begin(9600); // Setting the baud rate of GSM Module
Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)
delay(100);
}
void loop()
{
if (Serial.available()>0)
switch(Serial.read())
{
case 's':
SendMessage();
break;
default:
RecieveMessage();
break;
}
if (mySerial.available()>0)
Serial.write(mySerial.read());
if (text!="zero"){
mySerial.println("that is good");
delay(90000);
}
}
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=\"+989171887761\"\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);
}
And what I receive in my serial monitor is (I sent a text message with body "Test12" here):
+CMT: "+9123456789","","17/11/16,01:37:46+14"
Test12
Now, I need to record all the printed stuff, or the body of the message. So, my question is that how can I record it as a string?
Your help is very appreciated. If you know any old post related to this also, I would be grateful to see, sorry, I could not find what I want!
Thanks for your help
Zeedo65