PDA

View Full Version : HELP ME, SMS controlled relay using PIC



pazko1125
- 25th September 2008, 08:41
hello everyone,

my project is this, a message should trigger a relay, i only need one relay for an alarm.

my problem is that i don't know how to read the message using PIC and what AT command should i use, what PIC should i use to read the SMS, what cellphone should i use? to be honest i have only a little experience about PIC.

so please could anyone help me realize this project. any tutorial or guide will be great help for me to understand on where should i begin. i also need a circuit diagram and program code if possible.

thanks in advance.

aratti
- 25th September 2008, 17:56
Read the below given link it will be a good start

www.developershome.com/sms/howToSendSMSFromPC.asp

pazko1125
- 26th September 2008, 05:34
thanks for the link, ill already read it. it gave me an idea on how to communicate the cellphone using PC but i need codes in using pic.

Ioannis
- 26th September 2008, 09:15
What do you mean by 'codes in using pic'? A ready made program?

Please have a look at the link:

http://www.picbasic.co.uk/forum/forumdisplay.php?s=&f=19&page=1&pp=40&sort=lastpost&order=desc&daysprune=-1

and specially:

http://www.picbasic.co.uk/forum/showthread.php?t=8493
http://www.picbasic.co.uk/forum/attachment.php?attachmentid=859&d=1145772480

(credits to charudatt)

Ioannis

P.S. Next time give more details, like your PIC type, your IDE and you up to this moment program you have written.

pazko1125
- 27th September 2008, 07:35
What do you mean by 'codes in using pic'? A ready made program?

Please have a look at the link:

http://www.picbasic.co.uk/forum/forumdisplay.php?s=&f=19&page=1&pp=40&sort=lastpost&order=desc&daysprune=-1

and specially:

http://www.picbasic.co.uk/forum/showthread.php?t=8493
http://www.picbasic.co.uk/forum/attachment.php?attachmentid=859&d=1145772480

(credits to charudatt)

Ioannis

P.S. Next time give more details, like your PIC type, your IDE and you up to this moment program you have written.

yes, if possible can u give me a ready made program. i seen a lot of sample program in the forum but really i can't understand the initialization, and how to send AT commands using PIC. i already tried sending AT commands using hyper terminal and it works and now my problem is on how to use the PIC to send AT commands. thanks for the links. hope you can help me.

skimask
- 27th September 2008, 07:49
yes, if possible can u give me a ready made program.
Did you even look at the links above? Looks to me like 'ready made'...


i seen a lot of sample program in the forum but really i can't understand the initialization, and how to send AT commands using PIC. i already tried sending AT commands using hyper terminal and it works and now my problem is on how to use the PIC to send AT commands. thanks for the links. hope you can help me.

Maybe you should start off by making a PIC do something simple like making an LED blink or something along those lines before trying to tackle sending/receiving serial port data....much less trying to talk to a cell phone. I mean... How far into PICs are you? How much stuff have you built? Have you answered any of the questions Ioannis asked two posts above? We don't know what you're dealing with...

pazko1125
- 29th September 2008, 02:50
Did you even look at the links above? Looks to me like 'ready made'...



Maybe you should start off by making a PIC do something simple like making an LED blink or something along those lines before trying to tackle sending/receiving serial port data....much less trying to talk to a cell phone. I mean... How far into PICs are you? How much stuff have you built? Have you answered any of the questions Ioannis asked two posts above? We don't know what you're dealing with...

i don't really have idea on what PIC should i use in this project. i have used a PIC16F84a before but only for blinking and if statement for the program. i haven't done project dealing with strings and variables yet. so can u give some sample coding or tutorials to study with. thanks.

skimask
- 29th September 2008, 03:25
i don't really have idea on what PIC should i use in this project.
Totally up to you...


i have used a PIC16F84a before but only for blinking and if statement for the program.
It's a start...


i haven't done project dealing with strings and variables yet.
Maybe you should...


so can u give some sample coding or tutorials to study with. thanks.
http://darreltaylor.com/files/ROFL.gif

Question is....Can you use the Search function near the top of this page? Or just maybe troll the forums for some pre-made code...

pazko1125
- 29th September 2008, 07:14
Totally up to you...


It's a start...


Maybe you should...


http://darreltaylor.com/files/ROFL.gif

Question is....Can you use the Search function near the top of this page? Or just maybe troll the forums for some pre-made code...

yes, i've seen charudatt's code. is it also applicable to mobile phone like sony ericson t610 bec it uses a modem and i can't find a modem here. thanks

Ioannis
- 29th September 2008, 07:39
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

aratti
- 29th September 2008, 12:15
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.

pazko1125
- 30th September 2008, 03:22
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

aratti
- 1st October 2008, 11:24
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

pazko1125
- 2nd October 2008, 06:36
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.


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

aratti
- 2nd October 2008, 15:26
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