Receiving message to PIC through GSM modem


+ Reply to Thread
Results 1 to 12 of 12
  1. #1
    Join Date
    Jun 2013
    Posts
    17

    Default Receiving message to PIC through GSM modem

    Hello every one,

    Can someone help me please? I have tried few ways but I can’t make it to work. I should add, I can send & receive sms as well. Even I can view received sms on lcd. But,
    I am not sure how I can proceed a text message from the GSM such as a command like: "LED1ON" and switch LED1 on.

    Many thanks in advance.


    All suggestions are welcome

  2. #2
    Join Date
    Sep 2009
    Posts
    716

    Default Re: Receiving message to PIC through GSM modem


  3. #3
    Join Date
    Jun 2013
    Posts
    17

    Default Re: Receiving message to PIC through GSM modem

    Hello Pedja,

    Thank you in advance for your help and support.
    I read whole of this link:
    I have used the array for reading from serial in. As I already said, I can show the received message on LCD. so it means arrays work well.
    Here is my simple sample. In this routine my GSM modem (SIM900) even detects the right temperature and shows it on LCD as well. But still I can not control a simple LED throu it .

    Would you please help?
    @ device hs_osc
    define osc 20
    DEFINE CHAR_PACING 10
    include "modedefs.bas"
    '-------------------------------------------------------------------------------
    i var byte
    s var byte[90]
    n var byte[90]
    '-------------------------------------------------------------------------------
    trisb=0
    portb=0
    trisc=%10000010
    portc=0
    trisa=0
    porta=0
    '-------------------------------------------------------------------------------
    define lcd_dreg portb
    define lcd_dbit 4

    define lcd_rsreg portb
    define lcd_rsbit 1

    define lcd_ereg portb
    define lcd_ebit 0

    define lcd_bits 4
    define lcd_lines 2

    lcdout $fe,$01
    '-------------------------------------------------------------------------------
    cr con 13
    cz con 26
    cot con 34
    space con 32
    comma con 44
    '################################################# ##############################
    clear
    high portb.3 'Switching ON"
    lcdout $fe,$01
    lcdout $fe,128,"Power-UP....",#i
    pause 1200
    lcdout $fe,128,"Power released"
    low portb.3

    pause 10000
    '************************************************* *******************************
    ini:
    clear
    lcdout $fe,$01
    for i=0 to 4
    serout portc.6,T9600,["AT",cr]
    pause 1000
    lcdout $fe,128,"Initialize ",#i
    next i
    serout portc.6,T9600,["AT+CMGF=1",cr]
    pause 1000
    serout portc.6,T9600,["AT+CMGDA=",cot,"DEL",space,"ALL",cot,CR] '* DELETE all message
    pause 1500
    lcdout $fe,1

    serout portc.6,T9600,["AT+CMTE?",cr]
    serin portc.7,T9600,1000,ini,["+CMTE:"],n(24)
    for i=25 to 29
    serin portc.7,T9600,1000,ini,n(i)
    next i
    LCDout $fe,192,"Temp=",n(27),n(28),223,"C"

    PAUSE 1000


    start:
    if portc.1=0 then

    for i=30 to 42
    serin portc.7,T9600,1000,start,n(i)
    next i
    if ( n(33)="C" and n(34)="M" and n(35)="T" and n(36)="I") then
    lcdout $fe,1
    lcdout $fe,128,"Reading"
    pause 1000
    serout portc.6,T9600,["AT+CMGR=",n(42),cr]
    serin portc.7, T9600,5000,w2,["+CMGR:"],s(0)
    for i=1 to 84
    serin portc.7, T9600,1000,w2,s(i)
    next i

    endif
    endif
    if (s(59)="S") then
    high portc.3
    s(59)=0
    endif
    if(s(59)="T" and s(60)="a") then
    low portc.3
    s(59)=0
    s(60)=0
    endif
    lcdout $fe,1
    lcdout $fe,128,s(59),"s59",#s(59)
    lcdout $fe,192,s(59),s(60)," 59-60-END" ;for myself understanding and tracing on datas on LCD

    serout portc.6,T9600,["AT+CMGD=",n(42),comma,4,cr]
    pause 1000
    goto start
    '************************************************* *******************************

    '************************************************* *********************************

    w2:
    pause 5000
    serout portc.6,T9600,["AT+CMGR=",n(42),cr]
    serin portc.7, T9600,5000,ini,["+CMS ERROR:"],s(87),s(88),s(89)
    pause 5000
    lcdout $fe,01
    lcdout $fe,128,"SMS receiving"
    lcdout $fe,192,"Error=",s(87),s(88),s(89)
    pause 2000
    goto start
    '************************************************* *************************************************
    END

  4. #4
    Join Date
    Sep 2009
    Posts
    716

    Default Re: Receiving message to PIC through GSM modem

    Did you see this?
    Code:
    CommandParser:
    ; Fast searcher! Case sensitive.  Closely based on info provided by Darrel Taylor.
    ; Searches through Str1. If it finds the strings listed in the quotes, it returns which one it found.
    ; the max length of STR1 that will be searched is in MaxSearchLen
       
        Cmd = 255  ; In case of no match
        MaxSearchLen = 20            
     
        Parse01: Cmd=01 : ARRAYREAD Str1,MaxSearchLen,Parse02,[WAIT("LedOn")] : GOTO Foundit
        Parse02: Cmd=02 : ARRAYREAD Str1,MaxSearchLen,Foundit,[WAIT("LedOff")] : GOTO Foundit
    Foundit:
        return
    Use STR modifier to receive string from modem into array Str1. Then call parser and check Cmd, if Cmd=1 then led on, if Cmd=2 then led off.

  5. #5
    Join Date
    Jun 2013
    Posts
    17

    Default Re: Receiving message to PIC through GSM modem

    Hello Pedja,

    Thank you for your support.

    I am not sure if my compiler (PicbasicPro 2.6) supports "ARRAYREAD".

  6. #6
    Join Date
    Sep 2009
    Posts
    716

    Default Re: Receiving message to PIC through GSM modem

    Then try it... And you will find out

  7. #7
    Join Date
    Jun 2013
    Posts
    17

    Default Re: Receiving message to PIC through GSM modem

    Thank you

  8. #8
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333

    Default Re: Receiving message to PIC through GSM modem

    Have you set new message notification? It is not in your code.

  9. #9
    Join Date
    Jun 2013
    Posts
    17

    Default Re: Receiving message to PIC through GSM modem

    Quote Originally Posted by EarlyBird2 View Post
    Have you set new message notification? It is not in your code.
    Hello Bird,

    Yes, there is a pin on sim900 GSM modem, if a new message be received this pin will be in high state less than 1 second, I use this pin for the new message notification. But i didn't use this feature in this sample routine. Because I am still busy with comparing two things with each other... the question of this thread is still valid

    Thank you

  10. #10
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333

    Default Re: Receiving message to PIC through GSM modem

    Is this the code that does the comparison?

    Code:
    if (s(59)="S") then
     high portc.3
     s(59)=0
     endif
     if(s(59)="T" and s(60)="a") then
     low portc.3
     s(59)=0
     s(60)=0
     endif
    and needs modifying to "LED1ON" and "LED1OFF" but does not work even with the simple test of "S" and "Ta"?

  11. #11
    Join Date
    Jun 2013
    Posts
    17

    Default Re: Receiving message to PIC through GSM modem

    Hello Steve,

    Thanks a lot for your posting here.

    I apologize. I was late in reply

    Yes, it is, it compares incoming message with a pattern and chooses what commands must run. here is just simple put a pin on high or low states.

    Do you have any other suggestion for comparing?

    Thank you

  12. #12
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333

    Default Re: Receiving message to PIC through GSM modem

    Quote Originally Posted by EarlyBird2 View Post
    Is this the code that does the comparison?

    Code:
    if (s(59)="S") then
     high portc.3
     s(59)=0
     endif
     if(s(59)="T" and s(60)="a") then
     low portc.3
     s(59)=0
     s(60)=0
     endif
    and needs modifying to "LED1ON" and "LED1OFF" but does not work even with the simple test of "S" and "Ta"?
    Does this work?

Similar Threads

  1. Interface Pic --> Max232 --> GSM Modem
    By SangkiMangki in forum GSM
    Replies: 1
    Last Post: - 28th September 2013, 12:57
  2. gsm modem and pic communication
    By shani_developer in forum GSM
    Replies: 1
    Last Post: - 7th September 2010, 08:21
  3. GSM modem not working with PIC! Both modem & PIC work fine with PC
    By financecatalyst in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 12th May 2010, 09:31
  4. Anyone used a WAVECOM gsm modem ?
    By isaac in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 8th September 2007, 13:15
  5. SEROUT2 to GSM Modem
    By tommyers in forum General
    Replies: 5
    Last Post: - 21st August 2006, 21:35

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts