Can't read an sms Using TC35i & 16F690


Closed Thread
Results 1 to 15 of 15
  1. #1

    Exclamation Can't read an sms Using TC35i & 16F690

    Hi Everyone
    I am now able to send text messeges using my TC35i & PIC16F690. New Problem, I am unable to read an sms. Here is my code:
    rea:
    serout2 tx,baud,["AT+CMGF=1",13]
    Serin2 rx,baud,5000,rea,[WAIT("OK")]
    HIGH LED
    PAUSE 1000
    LOW LED
    serout2 tx,baud,["AT+CMGR=1",13]
    Serin2 rx,baud,5000,rea,[WAIT("REC UNREAD"),skip 3, STR num\12,skip 27,STR sms\10] 'CODE NEVER MOVES FORWARD FROM HERE
    HIGH LED
    PAUSE 1000
    LOW LED
    if sms[0]="t" and sms[1]="e" and sms[2]="s" and sms[3]="t" then
    goto done
    ELSE
    goto rea
    ENDIF


    done:
    serout2 tx,baud,["AT+CMGF=1",13]
    Serin2 rx,baud,5000,main,[WAIT("OK")]
    HIGH LED
    PAUSE 1000
    LOW LED
    serout2 tx,baud,["AT+CMGS=",34,"XXXXMY NUMBERXXXX",34,13]
    Serin2 rx,baud,5000,main,[WAIT(">")]
    PAUSE 500
    SEROUT2 tx,baud,["done",26]
    goto rea

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Code:
    Ini:
    
    Flag=0
    Count=Count+1
    if Count > 10 then Error      ' Modem doesn' t answer exit to error label
    serout2 tx,baud,["AT+CMGF=1",13]
    Serin2 rx,baud,5000,Ini,[WAIT("OK")]
    Flag=1                                         ' Modem OK Flag setted to 1
    serout2 tx,baud,["AT+CPMS=MT",13] ' set the phone memory to read
    Return
    AT+CMGF=1 set the modem to work in text mode (0= PDU mode), so you don't need to repeat this AT command several times. I suggest you to use a subroutine and call it only at the begining (set count = 0). Next thing you need to do is to tell to the modem which memory you will use for sms recording. Also this AT command is needed only once.

    Code:
    SMS:
    serout2 tx,baud,["AT^SMGR=1",13]
    Serin2 rx,baud,5000,SMS,[WAIT("REC UNREAD"),skip 3, STR num\12,skip 27,STR sms\10]
    Here I start from the assumption that the skips are corrected, if not the risk is that the modem has sent all the data, but SERIN2 has not filled the strings and wait forever for other data that will never be transmitted. So this could be the answer to your statement: CODE NEVER MOVES FORWARD FROM HERE

    Finally, as soon as you have read the incoming sms you should delate it to free the memory space ( if not second incoming sms will be placed in position 2, while you call for sms in position 1)

    Code:
    Delete_Sms:
    serout2 tx,baud,["AT+CMGD=1",13] ' Delete sms from memory position 1
    RETURN
    Al.
    All progress began with an idea

  3. #3


    Did you find this post helpful? Yes | No

    Exclamation

    Hi Aratti, thanks for the answer.
    Unfortunately the code still stands still at main function. I am attaching the main code here:

    start:
    GOSUB ONE
    serout2 tx,baud,["AT+CMGD=1",13]
    serin2 rx,baud,5000,start,[WAIT("OK")]
    pause 1000
    gosub one
    serout2 tx,baud,["AT+CMGF=1",13]
    Serin2 rx,baud,5000,start,[WAIT("OK")]
    pause 1000
    goto one
    goto main


    main:
    gosub two
    serout2 tx,baud,["AT^SMGR=1",13]
    Serin2 rx,baud,5000,main,[WAIT("REC UNREAD")] ' Removed all STR statements to get it to work
    goto start
    one:
    for c=1 to 10
    portc=255
    pause 20
    portc=0
    pause 20
    next c
    return
    two:
    for c=1 to 5
    portc=255
    pause 400
    portc=0
    pause 400
    next c
    return

  4. #4
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    I suspect that you have few "Rec Read" message in memory. Delete them all and than send a new one and try again your code.

    Since you don't know how many sms are stored them loop several time with the "AT+CMGD=1",13 , wait for the "OK", leave a pause 5000 and repeat.

    Al.
    All progress began with an idea

  5. #5


    Did you find this post helpful? Yes | No

    Exclamation

    Quote Originally Posted by aratti View Post
    I suspect that you have few "Rec Read" message in memory. Delete them all and than send a new one and try again your code.

    Since you don't know how many sms are stored them loop several time with the "AT+CMGD=1",13 , wait for the "OK", leave a pause 5000 and repeat.

    Al.
    Hi, I actually inserted the sim in my mobile, deleted all text messeges from the sim and still having the same bad luck. Just to let you know, that I am using internet to send the text messeges (if that makes any difference).
    Is there any way I can point an incomming sms to be stored in location one?
    Is there any command I may be missing pointing to where the sms goes?

    Thanks

  6. #6
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    You must delate also sms present in the modem (TC35i memory). Follow my advice given in previous post.

    First sms goes in position 1; second in position 2; etc. etc. This is way you must keep the modem memory clean deleting sms as soon as they have been read, so incoming sms are always stored in position 1.

    Al.
    Last edited by aratti; - 1st October 2009 at 23:11.
    All progress began with an idea

  7. #7


    Did you find this post helpful? Yes | No

    Exclamation

    Hi Aratti
    Tried deleting from location 1 to 9. Results are the same, the code can't seem to see REC UNREAD. Any other trick you suggest?

  8. #8


    Did you find this post helpful? Yes | No

    Default

    Here is the code at Present:
    main:
    serout2 tx,baud,["AT^SMGR=1",13]
    Serin2 rx,baud,5000,main,[WAIT("REC UNREAD")]
    portc=255
    End
    start:
    gosub one
    serout2 tx,baud,["AT+CMGD=1",13]
    serin2 rx,baud,5000,start,[WAIT("OK")]
    pause 1000
    gosub one
    serout2 tx,baud,["AT+CMGD=2",13]
    serin2 rx,baud,5000,start,[WAIT("OK")]
    pause 1000
    gosub one
    serout2 tx,baud,["AT+CMGD=3",13]
    serin2 rx,baud,5000,start,[WAIT("OK")]
    pause 1000
    gosub one
    serout2 tx,baud,["AT+CMGD=4",13]
    serin2 rx,baud,5000,start,[WAIT("OK")]
    pause 1000
    gosub one
    serout2 tx,baud,["AT+CMGD=5",13]
    serin2 rx,baud,5000,start,[WAIT("OK")]
    pause 1000
    gosub one
    serout2 tx,baud,["AT+CMGD=6",13]
    serin2 rx,baud,5000,start,[WAIT("OK")]
    pause 1000
    gosub one
    serout2 tx,baud,["AT+CMGD=7",13]
    serin2 rx,baud,5000,start,[WAIT("OK")]
    pause 1000
    gosub one
    serout2 tx,baud,["AT+CMGD=8",13]
    serin2 rx,baud,5000,start,[WAIT("OK")]
    pause 1000
    gosub one
    serout2 tx,baud,["AT+CMGD=9",13]
    serin2 rx,baud,5000,start,[WAIT("OK")]
    pause 1000
    gosub one
    serout2 tx,baud,["AT+CMGF=1",13]
    Serin2 rx,baud,5000,start,[WAIT("OK")]
    pause 1000
    goto one
    goto main

  9. #9


    Did you find this post helpful? Yes | No

    Question

    Additional information:

    main:
    serout2 tx,baud,["AT^SMGR=1",13] ' I have tried it with AT+CMGR=1
    Serin2 rx,baud,5000,main,[WAIT("REC UNREAD")] ' I have tried this string with REC READ, STO UNSENT, STO SENT - Nothing works!
    portc=255
    end

  10. #10
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Try to short the qualifier string and maintain the same AT comand:

    Code:
    serout2 tx,baud,["AT^SMGR=1",13]
    Serin2 rx,baud,5000,main,[WAIT("UNREAD")]
    Al.
    Last edited by aratti; - 2nd October 2009 at 09:54.
    All progress began with an idea

  11. #11


    Did you find this post helpful? Yes | No

    Red face

    Quote Originally Posted by aratti View Post
    Try to short the qualifier string and maintain the same AT comand:

    Code:
    serout2 tx,baud,["AT^SMGR=1",13]
    Serin2 rx,baud,5000,main,[WAIT("UNREAD")]
    Al.
    Finally one step forward: The following code worked but of course this is not the target... but dont know where to go from here to check the messege and check the content & number...
    main:
    gosub two
    serout2 tx,baud,["AT+CMGR=1",13]
    Serin2 rx,baud,40000,main,[WAIT("+CMGR")]
    portc=255
    end

  12. #12
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Finally one step forward: The following code worked but of course this is not the target... but dont know where to go from here to check the messege and check the content & number...
    Now you need hyperterminal. You will download a typical sms on the screen and then you can count where the data that interest you commence, so you can plan the number of skips, their dimention as well as the string that should capture your data.

    The other way is to use a large array and sent it to a LCD to do the same job.

    Al.
    All progress began with an idea

  13. #13


    Did you find this post helpful? Yes | No

    Exclamation

    Ok, Downloaded the hyperterminal for vista and bought the serial to usb cable.
    Progress:
    Checked all locations using at+cmgl=" REC READ", "REC UNREAD" STO SENT & UNSENT.
    All show no sign of an remaining sms.

    After that:

    Sent an sms to my phone. Did at+cmgr=1, but it shows +cmgr: 0, ,0
    Then I did at+cmgl="REC UNREAD" - - - Result is only OK ( No sign of an received sms at all.

    What settings should be used for CPMS & CNMI?
    I have got cpms as sm, sm, sm & CNMI as 2,0,0,1 - Are these correct?
    Last edited by financecatalyst; - 2nd October 2009 at 18:17.

  14. #14


    Did you find this post helpful? Yes | No

    Question

    Its working now: this is what I did:

    CNMI=00001
    CNMS=me, me, mt ' stores and reads from TA memory & NOT sim

    What I would like to do is change it to store, read, delete from sim only. I know I have to change CNMS=SM, SM, SM but for this to take effect I need help in changing value of CNMI (Which I am unable to figure out)
    Any advise on CNMI values?

    Thanks

  15. #15
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Any advise on CNMI values?

    I have never used the sim memory. There are problem with the reading of incoming sms.

    It will work pretty well with "MT". Remember that you will delete the sms immediatly after reading it. Otherwise you will not be able to locate it.

    Al.
    Last edited by aratti; - 4th October 2009 at 23:23.
    All progress began with an idea

Similar Threads

  1. TC35i GSM With PIC 16F690 help
    By financecatalyst in forum General
    Replies: 33
    Last Post: - 22nd January 2012, 04:01
  2. Cleaning up code
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd December 2009, 07:14
  3. Replies: 13
    Last Post: - 12th May 2009, 17:26
  4. SEROUT WORD variable problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th April 2009, 11:20
  5. Replies: 18
    Last Post: - 7th April 2009, 21:46

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

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