PDA

View Full Version : hserin and sms controller



xxxxxx
- 8th March 2009, 21:29
hello
here is my problem, i want to read sms message from nokia phone and if sms message is present, activate some output pin on pic. here is some sample code that was faound on som previous thread on this forum


checksms:

HSerout ["AT",13,10]' start modem
Pause 1000

HSerout ["AT+CMGF=1",13,10]'set text mod
Pause 500

'hserout ["AT+CPMS=SM",13,10]'optional set memory location

loop:
HSerout ["AT+CMGL",13,10]'list new sms msg
pause 500

' read

HSerin 1800,loop,[wait("REC UNREAD"),skip 3,STR CALL\13,skip 4,STR GSMT\17,skip 6, STR GSMMSG\16\13]

if gsmmsg(1)=$41 THEN' msg sent to phone is leter A
HIGH PORTB.6
PAUSE 1000
ENDIF
GOTO LOOP
end


thx in advance for any help!!!!!!!!!!!!!

Ioannis
- 9th March 2009, 09:45
1. Get rid off the Pause 500 after HSerout ["AT+CMGL",13,10]'list new sms msg. Phone may answer ASAP and you will loose the string!

2. What problem do you have after this?

3. I suggest to check that phone accepts every command you send. Just to be sure...

Ioannis

xxxxxx
- 9th March 2009, 21:34
thx in advance, i use pic 16F887 and 4 MHz XT osc, i can send msg, delet it, but with reading is not going well, i noticed that teh voltage on rx line of pic is about 2.3 - 2.4 V, and i asume that is not sufficient. i tried with this code but nothing happends!


'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2009 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 20/02/2009 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
ansel=$00
anselh=$00
OUTPUT PORTB
PORTB=%00000000

' Def
define OSC 4
DEFINE HSER_SPBRG 25
DEFINE HSER_TXSTA 24h
DEFINE HSER_RCSTA 90h
DEFINE HSER_BAUD 9600
DEFINE HSER_CLROERR 1

sms VAR BYTE[16]

I VAR BYTE

HIGH PORTB.7
PAUSE 2000
LOW PORTB.7


' check sms

begin:
HSerout ["AT",13,10]' start comm
HSERIN 2000,begin,[WAIT("OK")]

textmod:
HSerout ["AT+CMGF=1",13,10]'set text mod
HSERIN 2000,textmod,[WAIT("OK")]

mem:
HSEROUT["AT+CPMS=",34,"ME",34,13,10]' mem location
HSERIN 2000,mem,[WAIT("OK")]

query:
'HSEROUT["AT+CMGL=",34,"REC READ",34,13,10]' filter for 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]

I=0

WHILE I <> 13' count until 13
if sms[i]=$44 THEN ' searching for letter A ?
GOTO turnon:
ELSE
GOSUB back:
I=I+1
ENDIF
WEND

goto query:
turnon:
High PortB.6
pause 1000
low portb.6
return
back:
RETURN

End

Ioannis
- 10th March 2009, 07:24
Can you put an LCD on a spare port of the PIC?

You could check that the commands are executed in the order you send and see up to where the program goes or fails.

How do you connect PIC to Mobile?

Ioannis

xxxxxx
- 10th March 2009, 07:59
i'm going to tried that!!! here is simple schematic of wiring pic and nokia!
the first one is from admin of www.elektronika.ba, but with this circuit i dont get sufficient voltage on rx pin....i'm gona give shot to the second one tonight it' from some spanish forum!

xxxxxx
- 10th March 2009, 08:09
and this is from www.atrox.at...as i mentioned before i assume the rx line of pic does'n responding, 2.4 V, and need it min 3.3V

xxxxxx
- 10th March 2009, 10:42
thx ioannis for idea, and i put a hex inverter (invert signal from phone twice) in tx phone to rx pic line and the program is now working. so it search letter A in first readed message in SM location and if it find it turn on led on portb.6


'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2009 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 20/02/2009 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
ansel=$00'konfigurisi AN pinove kao digital I/O
anselh=$00


' Definisanje
define OSC 4
DEFINE HSER_SPBRG 25
DEFINE HSER_TXSTA 24h
DEFINE HSER_RCSTA 90h
DEFINE HSER_BAUD 9600
DEFINE HSER_CLROERR 1
DEFINE LCD_BITS 4
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 4
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 5
DEFINE LCD_LINES 2

PORUKA VAR BYTE[16]

I VAR BYTE

HIGH PORTB.7
PAUSE 2000
LOW PORTB.7


' provjeri nove poruke

pocetak:
HSerout ["AT",13,10]' pocni komunikaciju

HSERIN 2000,pocetak,[WAIT("OK")]
LCDOUT $FE,1,"start"
pause 1000

textmod:
HSerout ["AT+CMGF=1",13,10]'postavi text mod
HSERIN 2000,textmod,[WAIT("OK")]

LCDOUT $FE,1,"text mod"
pause 1000

mem:
HSEROUT["AT+CPMS=",34,"SM",34,13,10]' ciljana memory lokacija
HSERIN 2000,mem,[WAIT("OK")]

LCDOUT $FE,1,"mem loc"
pause 1000

IP:
'HSEROUT["AT+CMGL=",34,"REC READ",34,13,10]' filter za query
HSEROUT["AT+CMGR=1",13,10]' filter za query

LCDOUT $FE,1,"query"

HSERIN 5000,IP,[WAIT("REC READ"),skip 41, STR PORUKA\16\13]
LCDOUT $FE,1,"analizing"

I=0

WHILE I <> 13' count till 13
if poruka[i]=$41 THEN ' searc leterr A....
GOTO UKLJUCI:
ELSE
GOSUB NAZAD:
I=I+1
ENDIF
WEND

goto ip:
UKLJUCI:
High PortB.6 ' turn on led
end
NAZAD:
RETURN

End

xxxxxx
- 10th March 2009, 10:47
is there any way to get data fom hserin or hserout statement to lcd?????

Ioannis
- 10th March 2009, 10:59
The Hserout/Hserin will NOT work with these circuits! Be careful also not to destroy your phone with this 3.3/5 volt adapters. I would suggest to test with the Serout2/Serin2 commands in invert mode.

Hserout/Hserin pressume that you have included inverters in your circuit (like the common MAX232, which obviously there are not).

I would use a 3.3 driver for the UART like MAX3232 for example.

Ioannis

Ioannis
- 10th March 2009, 11:03
is there any way to get data fom hserin or hserout statement to lcd?????

Have you used LCD before?

Ioannis

xxxxxx
- 10th March 2009, 13:18
The Hserout/Hserin will NOT work with these circuits! Be careful also not to destroy your phone with this 3.3/5 volt adapters. I would suggest to test with the Serout2/Serin2 commands in invert mode.

Hserout/Hserin pressume that you have included inverters in your circuit (like the common MAX232, which obviously there are not).

I would use a 3.3 driver for the UART like MAX3232 for example.

Ioannis

but it's working, i put a hex inverter 74LS04 and inverted the signal two times, 1 x 2 times logical not give 1, and put one zener didode 2v7 in tx line of phone!!!!so it's protected from over voltage!!!

xxxxxx
- 10th March 2009, 13:21
Have you used LCD before?

Ioannis

:rolleyes: i'm learnig, the idea is to show string from hserout, like "AT+CMGL" on lcd????

but not like this:

LCDOUT $FE,1,"AT+CMGL"

i want to catch up string and diplay it on lcd


thx for helping!!

--

www.mtskola.com

Ioannis
- 10th March 2009, 13:56
If the string is in the array e.g. my_string and your array say is 16 bytes in length, then do this:

LCDOUT $fe,$01,STR my_string\16

Ioannis

P.S. I suppose that all characters are in ASCII of course.

xxxxxx
- 10th March 2009, 14:16
If the string is in the array e.g. my_string and your array say is 16 bytes in length, then do this:

LCDOUT $fe,$01,STR my_string\16

Ioannis

P.S. I suppose that all characters are in ASCII of course.

thx i'm gona try it tonight after work :)

xxxxxx
- 10th March 2009, 21:51
If the string is in the array e.g. my_string and your array say is 16 bytes in length, then do this:

LCDOUT $fe,$01,STR my_string\16

Ioannis

P.S. I suppose that all characters are in ASCII of course.
and it's working i can list sms mesages and display it on lcd!!!! thx a lot ioannis

Ioannis
- 11th March 2009, 06:55
You are welcome!

Ioannis

phoenix_1
- 15th March 2009, 19:40
and this is from www.atrox.at...as i mentioned before i assume the rx line of pic does'n responding, 2.4 V, and need it min 3.3V

The Atronix work 100% ok.I use that with Nokia 6210 all the time.
You must use 19200 to comunicate with Nokia phones.

Regards Robert

Ioannis
- 16th March 2009, 09:18
At the first AT the device auto syncs to the baud rate. Usually the 9600 is the default.

No 19200 as standard.

Ioannis

camolas
- 25th March 2009, 00:37
Hi,

Nokia 7110 only work for me in 19600 bauds...

xxxxxx
- 22nd April 2009, 00:37
'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2009 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 18/03/2009 *
'* Version : 3.0 *
'* Notes : lcd menu working fine, four temepratures in this *
'* : example, but u can easy update that, one phone *
'* : authorized number,response from phone works fine *
'* : *
'************************************************* ***************
'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Notice : Copyright (c) 2009 *
'* : All Rights Reserved *
'* Date : 21/04/2009 *
'* Version : 2.0 *
'* Notes : pic16F887, lcd 2X16 and ds1820 digital thermo. *
'* : for remote (SMS) control of biomase heating device*
'* : with nokia 6210 and DL3P from www.atrox.at and *
'* : with help from author of www.elektronika.ba,and Ioannis *
'* Autor : Muamer Halilovic, www.mtskola.com *
'************************************************* ***************

'
'pic defines
'------------------------------------------------------------------------
@ DEVICE pic16F887, WDT_OFF ' Watchdog Timer
@ DEVICE pic16F887, PWRT_ON ' Power-On Timer
@ DEVICE pic16F887, MCLR_ON ' Master Clear Options (Internal)
@ DEVICE pic16F887, BOD_ON ' Brown-Out Detect
@ DEVICE pic16F887, LVP_OFF ' Low-Voltage Programming
@ DEVICE pic16F887, CPD_OFF ' Data Memory Code Protect
@ DEVICE pic16F887, PROTECT_OFF ' Program Code Protection
'
'konfigurisi AN pinove kao digital I/O, portd kao I
'------------------------------------------------------------------------
ansel=$00
anselh=$00
TRISD=$00
portd=$00
'
' Definisanje hser-a (transmit-recive) i lcd-a u 4 bitnom modu
'------------------------------------------------------------------------
define OSC 4
DEFINE HSER_SPBRG 25
DEFINE HSER_TXSTA 24h
DEFINE HSER_RCSTA 90h
DEFINE HSER_BAUD 9600
DEFINE HSER_CLROERR 1
DEFINE LCD_BITS 4
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 4
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 5
DEFINE LCD_LINES 2
'
'definisanje varijabli
'------------------------------------------------------------------------
high portd.7 ' aktiviranje uređaja
pause 1000
low portd.7

SYMBOL sel = PORTA.0 ' Sw 1 "trenutno stanje u objektu"
symbol res = porta.1 'sw 2 "meni"
SYMBOL enter = PORTA.2 ' Sw 3 "enter"

T1 VAR BYTE
T1=20



'----------------------------------------------------------------
' promjenjive
'----------------------------------------------------------------

MENU VAR BYTE ' zeljeni MENU
POSI VAR BYTE ' Pozicija na LCD
temp Var Word ' temperatura kao word
cr Var Byte ' ostatak
cpc Var Byte ' broji po stepenu C
ow Var PORTE.2 ' One-wire data pin
i var byte ' brojac
posttemp var word ' zeljena temperatura
PORUKA VAR BYTE[3] ' poruka kao array
TELBR VAR BYTE[12] 'broj kao array
TIME VAR BYTE [6] 'vrijeme kao array
grijanje var byte 'grijanje kao bajt za ukljucenje i iskljucenje potrosaca
grijanj var byte 'grijanje kao bajt za ukljucenje i iskljucenje potrosaca
tmp var byte
tbr var byte 'predefinisani broj korinsika

IstaPoruka3 VAR byte 'varijabla za upoređivanje
IstaPoruka1 var byte 'varijabla za upoređivanje
istaporuka2 var byte 'varijabla za upoređivanje
broj var byte

x var byte 'brojac x
K VAR BYTE 'brojac k
L VAR BYTE 'brojac L
J VAR BYTE 'brojac J

'----------------------------------------------------------------
' incijalizacija
'----------------------------------------------------------------
'low portc.6
low porte.2
PAUSE 300 ' LCD inicijalizacija
LCDOUT $FE,1 ' ocisti LCD

MENU = 1 ' Inicijalizacija variablli
x=0
K=0
L=0
J=0

LCDOUT $FE,130," DOBRO DOSLI"
'lcdout $FE,$c0,128, "izaberite temp "
lcdout $FE,$c0,"enter"," "," sel"," "," temp"

'-------------------------------------------------------------------------------------
' meni switc select temp
'-------------------------------------------------------------------------------------



PAUSE T1
poc:
IF sel = 1 THEN
gosub sc1
else
goto poc
endif
izbor:
if res = 1 then 'ako je res pritisnut
LCDOUT $FE,1 'ocisti lcd
MENU = MENU + 1 'povecavaj vrijednost
gosub amenu 'idi na Amenu (odabir za prikaz na display)
pause 200
endif
IF MENU = 5 THEN MENU = 1

for i = 1 to 4
if menu = i and enter=1 then gosub sc

next i
GOTO izbor

'----------------------------------------------------------------------
'odabir za prikaz na displeju
'----------------------------------------------------------------------
AMENU:

SELECT CASE MENU

CASE 2
POSI = 129 : LCDOUT $FE,128,">" : LCDOUT $FE,POSI,"1."," 28.00" , " C"
POSI = 193 : LCDOUT $FE,POSI,"2."," 30.00" , " C"


CASE 3


POSI = 129 : LCDOUT $FE,128,">" : LCDOUT $FE,POSI,"2."," 30.00" , " C"
POSI = 193 : LCDOUT $FE,POSI,"3."," 32.00" , " C"
CASE 4


POSI = 129 : LCDOUT $FE,128,">" : LCDOUT $FE,POSI,"3."," 32.00", " C"
POSI = 193 : LCDOUT $FE,POSI,"4."," 34.00" , " C"

CASE 5


POSI = 129 : LCDOUT $FE,128,">" : LCDOUT $FE,POSI,"4."," 34.00", " C"
POSI = 193 : LCDOUT $FE,POSI,"1."," 28.00", " C"

END SELECT
RETURN

'---------------------------------------------------------------------
'prikaz izabrane temperature
'---------------------------------------------------------------------
sc:


select case menu

case 2

posttemp=$0AF0' postemp = 2800
LCDOUT $FE,1, "Max temp:","28.00 C"

pause 2000


case 3

posttemp=$0BB8
LCDOUT $FE,1, "Max temp:" , "30.00 C"

pause 2000


case 4

posttemp=$0C80
LCDOUT $FE,1, "Max temp:" , "32.00 C"

pause 2000

case 1

posttemp=$0D48
LCDOUT $FE,1, "Max temp:", "34.00 C"
pause 2000
end select

'goto main

xxxxxx
- 22nd April 2009, 00:38
'---------------------------------------------------------------------
' provjeri sms inbox
'---------------------------------------------------------------------
main:

p:
HSerout ["ATZ",13,10] ' pocni komunikaciju,resetuj modem!
HSERIN 4000,p,[WAIT("OK")]
tm:
HSerout ["AT+CMGF=1",13,10] 'postavi text mod
HSERIN 2000,tm,[WAIT("OK")]

m:
HSEROUT["AT+CPMS=",34,"SM",34,13,10] 'ciljana memory lokacija
HSERIN 2000,m,[WAIT("OK")]
ws:
gosub sc1 'odi provjeri temperaturu

HSEROUT["AT+CMGL",13,10] 'filter za query
LCDOUT $FE,1,"cekaj sms!"

HSERIN 5000,ws,[WAIT("REC UNREAD"),skip 3,str telbr\12,skip 12,str TIME\6,skip 8,STR PORUKA\3\13]'trazi unread
lcdout $FE,1,telbr[6],telbr[7],telbr[8],telbr[9],telbr[10],telbr[11]
pause 3000

tbr[6]="8"
tbr[7]="3"
tbr[8]="1"
tbr[9]="0"
tbr[10]="x"'your phone number last two digits, oli zadnje dvije cifre vaseg broja
tbr[11]="y"

broj=1
for x=6 to 11
if TELBR[x]<>tbr[x] then broj=0
next x
lcdout $FE,$c0,tbr[6],tbr[7],tbr[8],tbr[9],tbr[10],tbr[11]
pause 2000

IF broj=0 then gosub s4


grijanje[1]="U" 'turn on heating
grijanje[2]="G"

istaporuka2=1
FOR K=0 to 1
if poruka[K+1]<>grijanje[K+1] then istaporuka2=0
next K

if istaporuka2=1 then gosub s1 'ako se sve poklapa idi na slanje poruka
'ukljucene poreosaca

grijanj[1]="I" 'turn off heating
grijanj[2]="G"


IstaPoruka1=1
FOR L=0 to 1
if poruka[L+1]<>grijanj[L+1] then IstaPoruka1=0 'ako se slova iz naredbe ne poklapaju
next L 'istaporuk1=0

if IstaPoruka1=1 then gosub s2 'ako se sve poklapa idi na slanje poruka
'iskljucenje poreosaca



tmp[1]="T" 'ask for temperature in object
tmp[2]="P"


IstaPoruka3=1
FOR J=0 to 1
if poruka[J+1]<>tmp[J+1] then IstaPoruka3=0 'ako se slova iz naredbe ne poklapaju
next j 'istaporuk1=0

if IstaPoruka3=1 then gosub s3 'ako se sve poklapa idi na slanje poruka
'temperatura u objektu

' ------------------------------------------------------------
' brisanje poruke iz memeorije
' ------------------------------------------------------------
mm:
HSEROUT["AT+CPMS=",34,"SM",34,13,10] 'ciljana memory lokacija
HSERIN 2000,mm,[WAIT("OK")]

d:
HSEROUT["AT+CMGD=1",13,10] 'brisi poruku iz mem loc SM sa indexom 1
HSERIN 2000,d,[WAIT("OK")]
LCDOUT $FE,1,"sms izbrisan!"
pause 1500
GOTO ws




'subrutines
'---------------------------------------------------------------

'
'subrutine za on/off-i potrosca i obavjest korisnika o poduzetoj akciji
'i provjeru pristigle poruke
'---------------------------------------------------------------
s2:

if IstaPoruka1=1 then low portd.0
LCDOUT $FE,1,"isklj grijanje!"
HSerout ["AT",13,10]
Pause 1000
HSerout ["AT+CMGF=1",13,10] 'Postavi Text Mode
Pause 1000
HSerout ["AT+CMGS=",34,"+387618310xx",34,",129",13,10]
pause 500
HSerout [str poruka\3,str time\6,10,13]
s21:
HSerout [26]
hserin 6000,s21,[WAIT("OK")]
return

s1:

if istaporuka2=1 then high portd.0
LCDOUT $FE,1,"uklj grijanje!"
HSerout ["AT",13,10]
Pause 1000
HSerout ["AT+CMGF=1",13,10] 'Postavi Text Mode
Pause 1000
HSerout ["AT+CMGS=",34,"+387618310xx",34,",129",13,10]
pause 500
HSerout [str poruka\3,str time\6,13,10]
s11:
HSerout [26]
hserin 6000,s11,[WAIT("OK")]
return


'--------------------------------------------------------------
'temperatura sa ds1820
'--------------------------------------------------------------

sc1:

OWOut ow, 1, [$CC, $44] ' pocni temp konverziju

wc:
OWIn ow, 4, [cr] ' provjeri da'l se jos konvertuje
If cr = 0 Then wc
OWOut ow, 1, [$CC, $BE] ' ocitaj temp
OWIn ow, 0, [temp.LOWBYTE, temp.HIGHBYTE, Skip 4, cr, cpc]
' izracunaj temp u C na 2 decimale
temp = (((temp >> 1) * 100) - 25) + (((cpc - cr) * 100) / cpc)

Lcdout $fe, 1,"Trenutna temp:"' prikazi temp
lcdout $FE,$c0,128,DEC (temp / 100), ".", DEC2 temp, " C"'"izaberite temp "

if temp >= posttemp then gosub s3 ' ako je uslov ispunjen salji upozorenje

pause 2000
' goto sc1
return
'-----------------------------------------------------------------
'prekoracenje temperature salji sms s3 pozorenja i pogresan korisnik s4
'-----------------------------------------------------------------

s3:
LCDOUT $FE,1, "Salji temp!"
HSerout ["AT",13,10]
Pause 1000
HSerout ["AT+CMGF=1",13,10] 'Postavi Text Mode
Pause 1000
HSerout ["AT+CMGS=",34,"+387618310xx",34,",129",13,10]
pause 500
HSerout ["Temp:",dec (temp/100),10,13]

s31:
HSerout [26]
hserin 6000,s31,[WAIT("OK")]
return


s4:
LCDOUT $FE,1,"nemate prava!"
HSerout ["AT",13,10]
Pause 1000
HSerout ["AT+CMGF=1",13,10] 'Postavi Text Mode
Pause 1000
HSerout ["AT+CMGS=",34,str telbr\12,34,",129",13,10]
pause 500
HSerout ["nemate prava",str time\6,13,10]
s12:
HSerout [26]
hserin 6000,s12,[WAIT("OK")]
goto mm
End

Ioannis
- 22nd April 2009, 07:00
Do you have any problem with this program, or ist an example?

I have say to that is long enough! I have a little difficulty followng the s1, s12 named subs. Better use names to understand after a month what this sub do.

Ioannis

xxxxxx
- 22nd April 2009, 08:11
Do you have any problem with this program, or ist an example?

I have say to that is long enough! I have a little difficulty followng the s1, s12 named subs. Better use names to understand after a month what this sub do.

Ioannis

its a example, but everything is working just fine, thos subs s1 to s4 is mesages for users!!!turn on heating, turn off heating, temperature in object and u dont have autorizathion for device!!! and once again thx for help!!!

Ioannis
- 22nd April 2009, 08:41
You are welcome. Thanks for posting your work too.

Ioannis

Ioannis
- 23rd May 2009, 17:24
After a lot of experimenting with the SMS subject, I noticed all by chance, that when my provider sent an SMS for advertisment purposes, the program could not handle it properly because in Hserin line to get the SMS, a 10 digit number was expected and not the 4 digit one.

Keep in mind that the "defaults" may not always be default enough!

Here is my test subroutine:


read_sms:
Lcdout com,line1,"Reading SMS"
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"),wait("+30"),str cc_phone\10,wait(44,44,34),SKIP 23,STR array\15\13] 'Number is waitstr command\10
LCDOut com,1,"Read 1 SMS"
pause 1000
sms_delete:
LCDOut com,1,"Deleting SMS"
HSerout ["AT+CMGD=1,4",13] 'Delete all messages
HSerin 19000,ex_sms2,[wait("OK")] 'Wait for OK (null)
LCDOut com,line1,"Deleted SMS "
Pause 1000
return
ex_sms2: 'No new message or timeout error
LCDOut com,line2,"Error",rep " "\11:Pause 1000
return
ex_sms4: 'Wrong Number!
LCDOut com,line2,"Error phone Nbr":Pause 1000
goto sms_delete


At the 3rd command line where HSerin 5000,ex_sms4,[wait... is executed, the command waits for +30 which is the country code for Greece, then I get 10 digits for the phone that is sending the SMS.

But if the sender has only 4 digits I now through the timeout, jump to ex_sms4 and after an LCD message, the new and irrelevant SMS is deleted.


Hope this helps all that deal with SMS stuff.

Ioannis

ScaleRobotics
- 10th February 2010, 15:49
Hserout/Hserin pressume that you have included inverters in your circuit (like the common MAX232, which obviously there are not).

I would use a 3.3 driver for the UART like MAX3232 for example.


The above was an older post. Since then, a way to invert the hardware serial port has been spotted in the 400+ page datasheets of the PIC18 devices.......
See http://www.picbasic.co.uk/forum/showthread.php?t=10361 for a little more information.

To command it to do so:


BSF BAUDCON,RXDTP
BSF BAUDCON,TXCKP


Pretty cool stuff. I have tried it on a few projects, including a bootloader, and it works great. Nice to eliminate the max232 hardware when you can.