gsm modem with 16f877a


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,167

    Default Re: gsm modem with 16f877a

    Modem PIC
    Tx -----------X-----------------Rx
    Rx ------X----|-----------------Tx
    | |
    1k 1k
    | |
    PC |----|
    Rx-------X---X

    Hope this helps you understand.

    Ioannis

  2. #2
    Join Date
    Nov 2007
    Location
    sri lanka
    Posts
    24

    Default Re: gsm modem with 16f877a

    Mr Ioannis now i can send sms (i have 1 mistake rx and tx chang)but now i want to do read sms and high led.please help methank you

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,167

    Default Re: gsm modem with 16f877a

    This example subroutine is for Wavecom. You have to check the manual of your GSM device for the correct commands.
    Also this example supposes that the GSM device responds with ASCII characters and not with numbers. OK instead of 0 (zero).

    Code:
    GSM_Subroutine:
    HSerout ["AT+CMGL=",34,"ALL",34,13] 'Check if there is new SMS. 34 is for " symbol
    Hserin 5000,err,[wait(10,13,10),str command\2]
    if command[0]="O" then return	'If response was just OK, then there was no SMS
    if command[0]="+" then goto read_sms 'If response started with + sign then there was some sms
    
    err:
    return
    
    read_sms:
    Lcdout com,line1,"Reading SMS",rep " "\4
    for l=0 to 5:command[l]=0:next l    'Clear buffer
    GoSub Mobile_Number      'get mobile number from setup, to check correct admin number
    HSerout ["AT+CMGL=",34,"ALL",34,13]  '"ALL" is for Wavecom module. Read all SMS 
    ' Read Caller ID etc. The timeout value in the HSERIN statement is important.
    ' it takes some time before the phone replies to the AT+CMGL command
    HSerin 5000,ex_sms4,[wait("READ"),skip 4,waitstr command\10,skip 27,STR command\6\13] 'Number is waitstr command\10
    LCDOut com,line1,"Read 1 SMS",rep " "\4,com,line2,"Command: ",str command\6
    
    sms_delete:
    HSerout ["AT+CMGD=1,4",13]			'Delete all messages
    LCDOut com,line1,"Deleting SMS":pause 150
    HSerin 15000,ex_sms2,[wait("OK")]     'Wait for OK (null)
    LCDOut com,line1,"Deleted SMS ":Pause 1000
    GoTo lcd_cls
    
    ex_sms2:    'No new message or timeout error
    LCDOut com,line2,"Error",rep " "\11:Pause 1000
    GoTo sms_chk
    
    ex_sms3:
    LCDOut com,line2,"SMS Check Error":Pause 1000
    GoTo sms_delete
    
    ex_sms4:    'Wrong Number!
    LCDOut com,line2,"Error phone Nbr":Pause 1000
    GoTo sms_delete
    I repeat again, study your GSM AT commands before attempting anything.
    Ioannis

  4. #4
    Join Date
    Nov 2007
    Location
    sri lanka
    Posts
    24

    Default Re: gsm modem with 16f877a

    Mr.Ioannis

    I HAVE FIND SOME CODE ABOUT AND I WROTE SOME CODE "AT+CMGD"
    I SEND TO MODEM TO SMS "A" BUT NOT TURN ON PORTB.6

    WHAT'S THE WRONG THIS CODE HELP ME
    ' Def
    define OSC 4
    DEFINE HSER_SPBRG 25
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_BAUD 2400
    DEFINE HSER_CLROERR 1

    sms VAR BYTE[16]

    I VAR BYTE

    'Check sms

    begin:
    HIGH PORTB.7
    HSerout ["AT",13,10]' start comm
    HSERIN 2000,begin,[WAIT("OK")]
    LOW PORTB.7


    query:
    HSEROUT["AT+CMGL=",34,"REC READ",34,13,10]' filter for query
    HSERIN 5000,query,[WAIT("REC READ"),skip 41, STR sms\16\13]
    HIGH PORTB.5
    PAUSE 200
    LOW PORTB.5
    I=0

    WHILE I <> 13' count until 13
    if sms[i]=$44 THEN ' searching for letter A ?
    GOTO turnon:
    ELSE
    GOTO back
    I=I+1
    ENDIF
    WEND
    turnon:
    High PortB.6
    pause 1000
    HSerout ["AT+CMGD=1",13,10]
    low portb.6
    GOTO QUERY
    back:
    HIGH PORTB.4
    HSerout ["AT+CMGD=1",13,10]
    PAUSE 100
    LOW PORTB.4
    GOTO QUERY
    END

    xxxxx.

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,167

    Default Re: gsm modem with 16f877a

    Are you sure the x y z modem that you have not study yet, is working at 2400 ?

    I am sorry but cannot guess. Nor I have the magic ball to tell me what you have, how it must be set-up. It is your job to do it.

    Ioannis

  6. #6
    Join Date
    Feb 2010
    Posts
    17

    Default Re: gsm modem with 16f877a

    Hi,
    First make sure you connect the pic rx and tx trough 10k resitor to the modem's rx and tx pin, Then you need to tie the handhaking pins together on the modem side.
    Start with pin 7 and 8 tied together and see if u get some data if not then tie pins 4 AND 6.Most modems required handshaking by tieing these pins the modem will be always ready to send and receive other wise it will sit and wait. Good luck hope this will help.

  7. #7
    Join Date
    Nov 2007
    Location
    sri lanka
    Posts
    24

    Default Re: gsm modem with 16f877a

    my sms project
    Name:  DSC05877.JPG
Views: 4812
Size:  35.2 KB
    3 input and 3 out put

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