Shop OBEX P1 Docs P2 Docs Learn Events
SMS reciving by basic stamp!!!!!! — Parallax Forums

SMS reciving by basic stamp!!!!!!

karim10216karim10216 Posts: 2
edited 2014-10-17 02:48 in Accessories
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!!!!!

Comments

  • NAVFAC10NAVFAC10 Posts: 23
    edited 2014-08-10 12:14
    I built a project a few years ago using the SM5100B and the prop. As I recall, the command to read an sms message is "AT+CMGR=X", where X is the memory location. Not sure if you tried this, but have you connected your GSM to a computer and communicated with it using hyper-terminal? It's a great way to experiment with "AT" commands. Good luck.
  • Ken GraceyKen Gracey Posts: 7,392
    edited 2014-08-10 16:26
    karim10216,

    What's the application, exactly?

    Ken Gracey
  • karim10216karim10216 Posts: 2
    edited 2014-08-11 04:34
    hi ken,
    I am using this to control a relay by sms meg, to turn on and off the lights....
  • KARIM102KARIM102 Posts: 75
    edited 2014-08-19 05:33
    I tried this program in GE864 it works but when I tried with the SM5100b it didn't work, can anyone correct or tell me what is going on
    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
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-08-19 09:59
    Hi KARIM102,

    We're a little confused here. Are you and karim10216 the same person?

    Thanks,
    -Phil
  • KARIM102KARIM102 Posts: 75
    edited 2014-08-20 03:23
    yes, I am but I don't know why my nickname has been changed...
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2014-08-20 18:14
    KARIM102 wrote: »
    yes, I am but I don't know why my nickname has been changed...

    No kidding?
    Well, I think that the "smart money" is betting on your having logged in on two accounts.
  • NAVFAC10NAVFAC10 Posts: 23
    edited 2014-08-22 09:35
    Not sure if you are using the CNMI command correctly for the SM5100B. Go to the sparkfun website and download the AT command set. http://www.sparkfun.com/datasheets/Cellular%20Modules/CEL-09533-AT%20Command_V1%5B1%5D.0.0-1.pdf
  • xanatosxanatos Posts: 1,120
    edited 2014-10-07 07:43
    I'm just gonna put this code here, both to archive it for my own future reference, and to help anyone else who wants to get started using an SM5100B with a BS2px (the px isn't necessary with the SM5100B but I had it interfaced to a bunch of other stuff that did). This is one slot of a five-slot code that ran on the px. If you use another BS2, be sure to adjust the baud rate, etc. I have removed a lot of code from the original, and this SHOULD work... it tokenizes on it's own here. The main thing is to remember that your band setting ( AT+SBAND=7 ) may need to be different. 7 works here in the USA with an AT&T SIM Card. I've seen several posts where folks needed to use 8. There may be other numbers, it's up to you to figure out which you need for your location and carrier.

    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
    
    
    
  • macrobeakmacrobeak Posts: 354
    edited 2014-10-17 02:48
    Xanatos, Thanks for your code - it is very helpful. I am really keen in getting the breakout board to work with a Basic Stamp or Prop. I did get it working very successfully with Arduino. Here is a very good tutorial that I used - it is helpful with the AT codes. http://tronixstuff.com/2011/01/19/tutorial-arduino-and-gsm-cellular-part-one/ Please can I ask you you to detail the exact pin connections between the SM5100B and BS2px? Is it also possible to highlight the microjumpers in a photograph? Many thanks in advance.
Sign In or Register to comment.