HELP ME, SMS controlled relay using PIC


Closed Thread
Results 1 to 15 of 15

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    My suggestion would be to find a phone with AT-command support like many Nokia's and other brands do. Erricson or Siemens of the old school I recall use only PDU format.

    Ioannis

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


    Did you find this post helpful? Yes | No

    Default

    Since you said to have already tested a working system using hyperterminal, you should know the basic AT commands!

    First of all you will need a phone that is capable of text mode. You will easily check your phone
    if is capable of text mode, connecting it to your PC and with hyperterminal send the following AT command "AT+CMGF=1" if answer will be "OK" then you can have a chance to complete your project, if the answer you will obtain will be "ERROR" then your phone use only the PDU mode which need a lot of decoding before you can read the message received. So search a phone that has the text mode.

    Before to connect the phone to any PIC device you need to interface the RS232 signal to a TTL in/out this is easily solved using the MAXIM 232

    When your hardware is ready you should program your pic using the same AT commands you have used experimenting with hyperterminal as you said.

  3. #3
    Join Date
    Sep 2008
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by aratti View Post
    Since you said to have already tested a working system using hyperterminal, you should know the basic AT commands!

    First of all you will need a phone that is capable of text mode. You will easily check your phone
    if is capable of text mode, connecting it to your PC and with hyperterminal send the following AT command "AT+CMGF=1" if answer will be "OK" then you can have a chance to complete your project, if the answer you will obtain will be "ERROR" then your phone use only the PDU mode which need a lot of decoding before you can read the message received. So search a phone that has the text mode.

    Before to connect the phone to any PIC device you need to interface the RS232 signal to a TTL in/out this is easily solved using the MAXIM 232

    When your hardware is ready you should program your pic using the same AT commands you have used experimenting with hyperterminal as you said.
    thanks. yes it support text mode.
    if i send this command using PIC, how can i get the message? do i have to make a variable for it or is it already on the memory?

    SEROUT2 TXPIN, BAUD, ["AT+CMGR=1"]
    +CMGR: "REC READ","+31625044454",,"07/07/05,09:56:03+08" 'phones reply
    Test message 1

    can u give a circuit diagram for that. i have circuit diagram here from edaboard.com and i don't know if it will work.

    http://www.edaboard.com/ftopic328792.html

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


    Did you find this post helpful? Yes | No

    Default

    yes you will need variables to store the modem answer!

    Remember to add 13 at the end of the at command SEROUT2 TXPIN, BAUD, ["AT+CMGR=1",13]

    schematic for you project is rather simple because you will use only one pin for output to drive your rele. Since the rele will work at 12 volts and it will require minimum 100 mA you will use a transitor to interface it. I suggest you to use one ULN2803 which is an array of 8 transistor ready for ttl interfacing so you can connect it directly to your pic. Connect all the array, perhaps later you will need an extra rele. Check the data sheet for the other connections.

    In writing the software you will need to set up your phone first of all.
    ReadTxt:
    SEROUT TXPIN, BAUD, ["AT+CMGF=1",13]
    SERIN RXPIN, BAUD,5000,ReadTxt, ["OK"],Data

    if Data=10 or Data=13 then JumpOut
    pause 5000
    goto ReadTxt

    JumpOut:
    ModemOn=1

    This routine will set your phone in text mode and will set the variable ModemOn to 1. This is very important because when you will switch of your system I will find this variable very useful.

    Second thing you will net is to set the memory place where to read the incoming messages

    SEROUT TXPIN, BAUD, ["AT+CPMS=MT",13]

    Pause 10000


    Now you are ready to check your phone for the presence of sms

    Loop:

    SEROUT TXPIN, BAUD, ["AT+CMGF=1",13]
    SERIN2 RXPIN, BAUD,5000,Loop, [wait("^SMGR:"),str Data\5
    if Data[1]=48 and Data[4]=48 then Loop

    SERIN2 RXPIN, BAUD,5000,NoSms, [wait("XYZ"),str Data\9

    do here your decoding and actions


    NoSms:'remove SMS

    SEROUT2 TXPIN, BAUD, ["AT+CMGD=1",13]
    Pause 1000
    goto Loop


    Hope it will help

    Alberto

  5. #5
    Join Date
    Sep 2008
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    alberto,

    thank you for the coding. just one favor, can you put some comments on this coding. i think it stores the mesage it receive but i can't configure out how it works. thanks again.
    Quote Originally Posted by aratti View Post
    Loop:

    SEROUT TXPIN, BAUD, ["AT+CMGF=1",13]
    SERIN2 RXPIN, BAUD,5000,Loop, [wait("^SMGR:"),str Data\5
    if Data[1]=48 and Data[4]=48 then Loop

    SERIN2 RXPIN, BAUD,5000,NoSms, [wait("XYZ"),str Data\9

    do here your decoding and actions

    NoSms:'remove SMS

    SEROUT2 TXPIN, BAUD, ["AT+CMGD=1",13]
    Pause 1000
    goto Loop

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


    Did you find this post helpful? Yes | No

    Default

    Loop:

    SEROUT2 TXPIN, BAUD, ["AT+CMGF=1",13] (here you call for a sms)

    SERIN2 RXPIN, BAUD,5000,Loop, [wait("^SMGR:"),str Data\5 ( Here you wait for the answer "^SMGR:" data[1] and data[4] are zero then no sms are present so you return to loop)

    if Data[1]=48 and Data[4]=48 then Loop

    SERIN2 RXPIN, BAUD,5000,NoSms, [wait("XYZ"),str Data\9] ( here you have skipped the if statement, so you have a sms , you wait for "XYZ" which is your password to be sure is your massage . following your pass you should write the coding massage. Remember to write a couple of word [any things you like minimum 10 characters] at the beginning of your massage. Any sms received that does not contain your pass will be ignored)

    do here your decoding and actions

    NoSms:'remove SMS

    SEROUT2 TXPIN, BAUD, ["AT+CMGD=1",13] (Here you delete from phone memory the received sms)
    Pause 1000
    goto Loop

    Hope to have cleared

    Alberto

Similar Threads

  1. SMS via pic
    By kenandere in forum GSM
    Replies: 15
    Last Post: - 10th March 2010, 10:00
  2. Pic to relay
    By ruijc in forum General
    Replies: 4
    Last Post: - 8th November 2007, 19:03
  3. Serial Relays
    By tazntex in forum General
    Replies: 3
    Last Post: - 17th May 2007, 17:42
  4. Replies: 22
    Last Post: - 9th April 2007, 15:25
  5. SMS decoding / encoding using PIC!
    By bitmaniac in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 19th March 2004, 07:03

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