PDA

View Full Version : Sending AT Commands using SEROUT



stuart_penman
- 9th May 2008, 18:37
Hello!

I am trying to get a PIC16F876A to send an SMS message from a Nokia phone. I have used AT commands from Hyperterminal to send an SMS but how can I implement these from the PIC.

Can I just use?

SEROUT PORTB.2,N9600,[#AT+CMGF=1,10,13] 'sets text mode
SEROUT PORTB.2,N9600,[#AT+CSCA="XXX",10,13] 'replace XXX with message centre number
SEROUT PORTB.2,N9600,[#AT+CMGS="YYY",10,13] 'replace YYY with recipient's number
SEROUT PORTB.2,N9600,[#hello world,10,13] 'hello world is message to send

Also to send the message from hyperterminal you press 'Ctrl-Z.' How do I write this as an AT command?

Many thanks!

Stuart

Ioannis
- 9th May 2008, 19:40
Can I just use?

SEROUT PORTB.2,N9600,[#AT+CMGF=1,10,13] 'sets text mode



No! What is the # symbol doing in there? Please read your PBP manual on the Serial command syntax!

You need this:


SEROUT PORTB.2,N9600,["AT+CMGF=1",10,13] 'sets text mode

and respectively:


SEROUT PORTB.2,N9600,["AT+CSCA=XXX",10,13] 'replace XXX with message centre number
SEROUT PORTB.2,N9600,["AT+CMGS=YYY",10,13] 'replace YYY with recipient's number
SEROUT PORTB.2,N9600,["hello world",10,13] 'hello world is message to send



Also to send the message from hyperterminal you press 'Ctrl-Z.' How do I write this as an AT command?

Simply just send 26 (that is Control-Z) like this:


SEROUT PORTB.2,N9600,[26,10,13]

Ioannis

stuart_penman
- 9th May 2008, 20:38
Thanks very much!