yes you will need variables to store the modem answer!
Remember to add 13 at the end of the at command SEROUT2 TXPIN, BAUD, ["AT+CMGR=1",13]
schematic for you project is rather simple because you will use only one pin for output to drive your rele. Since the rele will work at 12 volts and it will require minimum 100 mA you will use a transitor to interface it. I suggest you to use one ULN2803 which is an array of 8 transistor ready for ttl interfacing so you can connect it directly to your pic. Connect all the array, perhaps later you will need an extra rele. Check the data sheet for the other connections.
In writing the software you will need to set up your phone first of all.
ReadTxt:
SEROUT TXPIN, BAUD, ["AT+CMGF=1",13]
SERIN RXPIN, BAUD,5000,ReadTxt, ["OK"],Data
if Data=10 or Data=13 then JumpOut
pause 5000
goto ReadTxt
JumpOut:
ModemOn=1
This routine will set your phone in text mode and will set the variable ModemOn to 1. This is very important because when you will switch of your system I will find this variable very useful.
Second thing you will net is to set the memory place where to read the incoming messages
SEROUT TXPIN, BAUD, ["AT+CPMS=MT",13]
Pause 10000
Now you are ready to check your phone for the presence of sms
Loop:
SEROUT TXPIN, BAUD, ["AT+CMGF=1",13]
SERIN2 RXPIN, BAUD,5000,Loop, [wait("^SMGR:"),str Data\5
if Data[1]=48 and Data[4]=48 then Loop
SERIN2 RXPIN, BAUD,5000,NoSms, [wait("XYZ"),str Data\9
do here your decoding and actions
NoSms:'remove SMS
SEROUT2 TXPIN, BAUD, ["AT+CMGD=1",13]
Pause 1000
goto Loop
Hope it will help
Alberto
Bookmarks