Can't read an sms Using TC35i & 16F690


Closed Thread
Results 1 to 15 of 15

Hybrid View

  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

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 : 0

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