Reading SMS
PVJohn
Posts: 60
Hello,·I would like·to read SMS from my cell phone and print it in debug window, but I couldn't find any good example. I don't know what's in the message and how long it is, so·I can't use [noparse][[/noparse]WAIT ("anything")] to·search for the string and I must be able to read 160 characters. I'm using BS2px at 2400. This is my code to send·SMS out.
'{$STAMP BS2px}
'{$PBASIC 2.5}
'
'
' I/O Definitions
'
· RXfromModem·· CON···· 0··· ' receive (from modem)
· TXtoModem······ CON···· 1··· ' transmit (to modem)
'
' Constants
'
· Baud···· CON···· 1646····· ' 2400-N-8-1
· ControlZ CON···· 26······· ' Escape character·
'
' Program Code
'
Main:
· GOSUB SendText
· STOP
'
' Subroutines
'
SendText:
· DEBUG "Setting receiving number",CR,LF
· SEROUT TXtoModem, Baud, [noparse][[/noparse]"AT+CMGS=",34,"+15128318653",34,CR]
· SERIN RXfromModem, Baud, [noparse][[/noparse]WAIT (">")]
·
· SEROUT TXtoModem, Baud, [noparse][[/noparse]"My message.",CR]
· SEROUT TXtoModem, Baud, [noparse][[/noparse]ControlZ,CR]
· DEBUG "sent ctrl-z",CR,LF
· SERIN RXfromModem, Baud, [noparse][[/noparse]WAIT ("OK")]
· DEBUG "Got OK from modem",CR,LF
· DEBUG "Message has been send",CR,LF
RETURN
Thanks for your help.
PVJohn
'{$STAMP BS2px}
'{$PBASIC 2.5}
'
'
' I/O Definitions
'
· RXfromModem·· CON···· 0··· ' receive (from modem)
· TXtoModem······ CON···· 1··· ' transmit (to modem)
'
' Constants
'
· Baud···· CON···· 1646····· ' 2400-N-8-1
· ControlZ CON···· 26······· ' Escape character·
'
' Program Code
'
Main:
· GOSUB SendText
· STOP
'
' Subroutines
'
SendText:
· DEBUG "Setting receiving number",CR,LF
· SEROUT TXtoModem, Baud, [noparse][[/noparse]"AT+CMGS=",34,"+15128318653",34,CR]
· SERIN RXfromModem, Baud, [noparse][[/noparse]WAIT (">")]
·
· SEROUT TXtoModem, Baud, [noparse][[/noparse]"My message.",CR]
· SEROUT TXtoModem, Baud, [noparse][[/noparse]ControlZ,CR]
· DEBUG "sent ctrl-z",CR,LF
· SERIN RXfromModem, Baud, [noparse][[/noparse]WAIT ("OK")]
· DEBUG "Got OK from modem",CR,LF
· DEBUG "Message has been send",CR,LF
RETURN
Thanks for your help.
PVJohn
Comments
I am trying to do a similar project where I want to program a BS2 to send SMS messages using a cell phone. Do you have any success sending commands to a cell phone using the BS2? I can't even send simple commands such as dialing out to the cell phone. Here's my code:
GPS4800 CON 500 '4800N-8-1
SEROUT 1, GPS4800, [noparse][[/noparse]"ATDT 6133331234"]
SEROUT 1, GPS4800, [noparse][[/noparse]CR]
Thanks
You need to change your baudmode for the BS-2 to one of the following for 4800 BPS:
4800 8-N-1 TRUE = 188
4800 8-N-1 Inverted = 16572
Regards,
Bruce Bates
It even has a HEX-> message and message->HEX conversion utiliities so you can easily perform sanity checks on your PBASIC code to make sure it is in agreement (working properly).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
Sorry, I forgot to mention that I have a BS2sx chip.
Therefore I tried both:
4800 8-N-1 TRUE = 500
4800 8-N-1 Inverted = 16884
What happens it that after the BS2sx chip sends the ATDT command to the cell phone, I DO get a audio response from the phone but it doesn't dial out as it's supposed to. (I've tried 9600, 2400 bit rates also)
For example, if I connect the cell phone (Sony Ericsson T610) to my PC with a serial data cable and I send the ATDT command using hyperterminal, the cell phone would beep once and the cell display will say it is dialing out.
If the BS2sx sends out the ATDT command, the phone just beeps once and does not dial out like in the case above.
That being the case, I'd change the SEROUT command to look like this:
SEROUT 1, GPS4800, [noparse][[/noparse]"ATDT6133331234", CR]
and see how that goes.
Regards,
Bruce Bates
How did you interface your cell phone to your basic stamp? Directly by the pins of the cell or through a data cable?
I have the same problem as you. When I use the serial cable to connect the SE phone to my PC, I can communicate fine between the two using hyperterminal. But when connecting the BS2, I get garbage responses.
I interfaced the BS2 and the phone by connecting the pins of the data cable to the I/O pins of the BS2.
I connected the BS2 SEROUT I/O -> Pin3 of the male DB9 connector
" " SERIN I/O -> Pin 2 " "
" " VSS -> Pin5 " " (ground)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com