SMS reciving by basic stamp!!!!!!
what is the statment to makeGSM receive sms and command basic stamp to control a pin????
i tried this but didnt help,
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[ I/O Definitions ]
GPRS_RX PIN 1 'Connected with Pin Tx in Gsm Module
GPRS_TX PIN 0 'connected with Pin Rx in Gsm Module
'
[ Constants ]
T9600 CON 84
GPRS_Baud CON T9600
'
Mode VAR Word
'
SMS_Prep:
PAUSE 500
SEROUT GPRS_TX, GPRS_Baud, ["AT+CMGF=1", CR]
SERIN GPRS_RX, GPRS_Baud, 3000, SMS_Prep, [WAIT("OK")]
DO
SERIN GPRS_RX, GPRS_Baud,[WAIT("!"),Mode]
IF Mode = "A" THEN
HIGH 15
ENDIF
LOOP
plz help me!!!!!
i tried this but didnt help,
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[ I/O Definitions ]
GPRS_RX PIN 1 'Connected with Pin Tx in Gsm Module
GPRS_TX PIN 0 'connected with Pin Rx in Gsm Module
'
[ Constants ]
T9600 CON 84
GPRS_Baud CON T9600
'
Mode VAR Word
'
SMS_Prep:
PAUSE 500
SEROUT GPRS_TX, GPRS_Baud, ["AT+CMGF=1", CR]
SERIN GPRS_RX, GPRS_Baud, 3000, SMS_Prep, [WAIT("OK")]
DO
SERIN GPRS_RX, GPRS_Baud,[WAIT("!"),Mode]
IF Mode = "A" THEN
HIGH 15
ENDIF
LOOP
plz help me!!!!!
Comments
What's the application, exactly?
Ken Gracey
I am using this to control a relay by sms meg, to turn on and off the lights....
this is software
' {$STAMP BS2}
' {$PBASIC 2.5}
A VAR Word
'================================================= ================================================== ====
'
main routine
'================================================= ================================================== ====
frist:
PAUSE 500
SEROUT 14 ,84, ["AT+CMGD=1,4",13,10] ' Delect All messages
SERIN 15, 84 , [WAIT("OK")]
MAIN:
PAUSE 500
SEROUT 14 , 84, ["AT+CMGF=1", 13,10] ' Text mode
SERIN 15 , 84,3000,MAIN, [WAIT("OK")]
SECOND:
PAUSE 500
SEROUT 14,84, ["AT+CNMI=1,2,0,0,0",13,10] ' Read all messages
SERIN 15 , 84,3000,SECOND,[WAIT("OK") ]
THRID:
DO
SERIN 15 , 84, [WAIT(">"),A]
IF A = "A" THEN
HIGH 0 'when received A message
SMS_Prep:
PAUSE 500
SEROUT 14, 84, ["AT+CMGF=1", CR]
SERIN 15, 84, 3000, SMS_Prep, [WAIT("OK")] ' Text mode
SMS:
PAUSE 500
SEROUT 14,84, ["AT+CMGS=", $22, "39922358", $22, CR] ' Send to this phone number
SERIN 15, 84, 3000, SMS, [WAIT(">")]
SMS2:
PAUSE 500
SEROUT 14, 84, ["The Light's Number 1 is on!", $1A] ' Data to be send
SERIN 15, 84, 5000, SMS2, [WAIT("OK")]
GOTO THRID
ENDIF
LOOP
We're a little confused here. Are you and karim10216 the same person?
Thanks,
-Phil
No kidding?
Well, I think that the "smart money" is betting on your having logged in on two accounts.
Also in the code below I have just set a long modem startup delay. The modem is actually fairly verbose when initializing, it reports all sorts of info related to it's connection status, etc. For simplicity in setup here I just have a PAUSE 50000 to let it do it's dance and come ready, but if you want to monitor the startup, you certainly can. See the SM5100B manual for detailed descriptions of the codes it puts out.
The SM5100B is very user friendly, but not it's pinout. I highly suggest you also pick up the breakout board for the unit from SparkFun. It not only has the SM5100B socket, but also the SIM Card socket, and all interconnects, etc. The breakout board comes ready to talk to your COMPUTER via the built-in USB port on the card. You MUST unsolder the microjumpers on the board (RX, DTR, RTS, TX, and CTS) in order to talk to the unit with a microcontroller.
I'll answer any questions you may have on this code, but it's up to you to read the SM5100B and AT Command manual, which is specific for the unit, and will probably answer any questions you may have on the code, since in reality the code is basically just SEROUTs of AT Commands, and SERINs of acknowledgements or received data/texts.
Happy Texting!
Dave
' ========================================================================= ' ' File...... SM5100B.bpx - CELLULAR MODEM ' Purpose... TX/RX SMS using the SM5100B with a BS2px ' Author.... David Xanatos, Xanatronics ' E-mail.... xanatos@xanatos.com ' Started... 2014-09-14 ' ' {$STAMP BS2px} ' {$PBASIC 2.5} ' 'To use a BS2 TO communicate with the SM5100's UART, make sure you clear the RX, DTR, RTS, TX, and CTS jumpers on the SM5100B breakout/dev board (sparkfun). 'Receiving a message in the TEXT mode: 'Send Config message TO SM5100B (should only need TO DO once): 'AT+SBAND=7 --- USA, AT&T SIM Card. You may need to use 8 for some other networks. 'Screen returns: 'OK 'Send TO SM5100B: 'AT+CMGF=1 'Screen returns: 'OK 'Send TO SM5100B: 'AT+CMGL="ALL" 'Screen returns: '+CMGL: 4,0,"REC UNREAD","+1AAAXXXYYYY","14/08/31,15:32:00+00" <<< Where 1AAAXXXYYYY is the phone number it received the message from. 'Second message for receive testing. <<< This is the actual message I sent, on the next line. Format repeats for every message. 'OK '*******SENDING SMS:******* 'Config: AT+CSMP=19,143,0,0 'AT+CMGF=1 'AT+CMGS="1413XXXYYYY" 'When you rx the >, enter text, followed by Ctrl-z (I believe in PBASIC it'll be $1A) 'Response: +CMGS: XX Where XX is a sequence number apparently. 'Then an OK. '********************* 'AT+CSQ Returns signal quality (+CSQ: SS, BE - SSS: 0 = -110dbm, 31 = -48dbm; BE: 07 = val, 99 - ineffective.) 'ATZ Restores all settings TO user defined set. 'AT&W Stores all current parameters TO user defined set. 'Set current time: AT+CCLK="14/08/31,20:41:10" 'AT+CIND? +CIND: 0,12,1,0,1,0,0,0 +CIND: <battery>, <signal level>, <service>, <sounder>, <message>, <call>, <roam>, <smsfull> ' ' ========================================================================= ' -----[ Constants ]------------------------------------------------------- #SELECT $STAMP #CASE BS2, BS2E, BS2PE T2400 CON 396 T9600 CON 84 T19K2 CON 32 #CASE BS2SX, BS2P T2400 CON 1021 T9600 CON 240 T19K2 CON 110 #CASE BS2PX T1200 CON 3313 T2400 CON 1646 T4800 CON 813 T9600 CON 396 T19K2 CON 188 T38K4 CON 84 #ENDSELECT ' -----[ I/O Definitions ]------------------------------------------------- TXB2RXC PIN 8 ' BS2 TX to SM5100B RXD0 TXC2RXB PIN 9 ' SM5100B TXD0 to BS2 RX ' -----[ Variables ]------------------------------------------------------- serStr VAR Byte(9) sigStr VAR Byte ' Cellular Signal Strength x VAR Byte ' -----[ User/Site Setup ]-------------------------------------------------- ' -----[ Comm Mode Specific Initialization ]-------------------------------------------------- ' Everything after here assumes Comm Mode 2 (CELLULAR): OUTPUT TXB2RXC INPUT TXC2RXB PAUSE 10 ' -----[ Program Code ]---------------------------------------------------- Main: DEBUG "Running Cellular Mode", CR serStr = 0 PAUSE 2000 DEBUG "Wait for cell modem startup", CR, CR PAUSE 50000 ' Waiting for the cellular modem to start up. You can be more active here if you wish. See the manual for the output strings to watch for. DEBUG "Initializing...", CR, CR DEBUG "AT+SBAND=7", CR SEROUT TXB2RXC, T9600, ["AT+SBAND=7", CR] ' This is for USA, AT&T SIM Card SERIN TXC2RXB, T9600, 5000, timeout, [WAIT ("OK")] ' SM5100B will in most cases respond with OK if it has accepted the command. DEBUG "OK", CR, CR PAUSE 1000 DEBUG "AT+CSMP=19,143,0,0", CR ' See the AT Command manual for the SM5100B for definitions of these codes. SEROUT TXB2RXC, T9600, ["AT+CSMP=19,143,0,0", CR] SERIN TXC2RXB, T9600, [WAIT ("OK")] DEBUG "OK", CR, CR PAUSE 1000 DEBUG "AT+CMGF=1", CR SEROUT TXB2RXC, T9600, ["AT+CMGF=1", CR] ' See the AT Command manual for the SM5100B for definitions of these codes. SERIN TXC2RXB, T9600, [WAIT ("OK")] DEBUG "OK", CR, CR PAUSE 1000 DO sigStr = 0 DEBUG "AT+CSQ", CR 'AT+CSQ Returns signal quality (+CSQ: SS, BE - SSS: 0 = -110dbm, 31 = -48dbm; BE: 07 = val, 99 - ineffective.) SEROUT TXB2RXC, T9600, ["AT+CSQ", CR] SERIN TXC2RXB, T9600, [WAIT("+CSQ: "), STR serStr\5, WAIT("OK")] DEBUG STR serStr, CR IF serStr(1) = $2C THEN ' Checking for position of comma (2C) - doesn't have a leading zero in power level. x = serStr(0) sigStr = x.LOWNIB ELSEIF serStr(2) = $2C THEN x = serStr(0) x = x.LOWNIB sigStr = 10 * x x = serStr(1) x = x.LOWNIB sigStr = sigStr + x ENDIF 'IF sigStr < 1 then RESET ' Helps if unit didn't start - use a hardware reset with timeout for full restart DEBUG "Signal: ", DEC2 sigStr, CR, CR IF sigStr < 15 THEN DEBUG "RED", CR, CR ' I was going to use a bi-color LED here for signal strength indication, but I ran out of IO pins on my original application :) 'sigX = 1 'sigY = 0 ELSEIF sigStr > 14 THEN DEBUG "GREEN", CR, CR 'sigX = 0 'sigY = 1 ENDIF IF sigStr < 1 THEN GOTO Main PAUSE 4000 sendMsg: ' SEND A TEXT MESSAGE DEBUG "AT+CMGS=", $22, "1413XXXYYYY", $22, CR ' telephone number goes here. No spaces or dashes. SEROUT TXB2RXC, T9600, ["AT+CMGS=", $22, "1413XXXYYYY", $22, CR] SERIN TXC2RXB, T9600, [WAIT (">")] DEBUG ">", CR, CR PAUSE 1000 SEROUT TXB2RXC, T9600, ["Whatever you type in here will be sent out as a text message", CR] SEROUT TXB2RXC, T9600, [$1A] ' NOTE: NO CR!!! SERIN TXC2RXB, T9600, 12000, timeout, [WAIT ("OK")] DEBUG "OK", CR, CR PAUSE 500 DEBUG "Loop completed ", CR PAUSE 30000 LOOP GOTO Main ' -----[ Subroutines ]--------------------------------------------------------------------------------------------------------- timeout: DEBUG "TO1", CR SEROUT TXB2RXC, T9600, [$1A] ' NOTE: NO CR!!! SERIN TXC2RXB, T9600, 5000, timeout2, [WAIT ("OK")] RETURN timeout2: DEBUG "Something's not hooked up right.... ", CR RETURN