Hello,
I'm writing simple program to interface Arduino with Siemens TC35 modem.
It must do following:
AT+CMGF=1 // sets SMS mode to text
AT+CMDG=1 // delete 1st message
AT+CNMI=3,1,0,0 // set modem to send SMS data to serial out upon receipt
After this comes loop:
If modem sends +CMTI: "SM",1
then read 1st message AT+CMGR=1
If message says hello then light up pin 13 led for 5 sec then off and delete 1st message
If message says bye the light up pin 14 led for 5 sec then off and delete 1st message
If message says anything else just delete 1st message // not programmed yet.
But then I get +CMTI: "SM",1 it doesn't do anything.
Maybe You guys can help me to sort this out?
BTW whet I type AT+CMGR=2 serial output looks like this:
+CMGR: "REC UNREAD","+38947953879_phone_number",,"01/08/19,02:13:01+12"
hello
OK
Serial data:
AT+CMGF=1
OK
AT+CMGD=1
OK
AT+CNMI=3,1,0,0
OK
+CMTI: "SM",1
Program code:
#include <NewSoftSerial.h>
NewSoftSerial cell(10,11);
char inchar;
void setup()
{
pinMode(13, OUTPUT);
pinMode(14, OUTPUT);
cell.begin(9600);
delay(30000);
cell.println("AT+CMGF=1");
delay(1000);
cell.println("AT+CMGD=1");
delay(1000);
cell.println("AT+CNMI=3,1,0,0");
delay(1000);
}
void loop()
{
if(cell.available() >0)
{
inchar = cell.read();
if(inchar == '+CMTI: "SM",1')
{
cell.println("AT+CMGR=1");
inchar = cell.read();
if(inchar == 'hello')
{
digitalWrite(13, HIGH);
delay(5000);
digitalWrite(13, LOW);
cell.println("AT+CMGD=1");
}
if(inchar == 'bye')
{
digitalWrite(14, HIGH);
delay(5000);
digitalWrite(14, LOW);
cell.println("AT+CMGD=1");
}
}
}
}