hserin and sms controller


Closed Thread
Results 1 to 26 of 26
  1. #1
    Join Date
    Mar 2009
    Posts
    48

    Default hserin and sms controller

    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!!!!!!!!!!!!!

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,796


    Did you find this post helpful? Yes | No

    Default

    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

  3. #3
    Join Date
    Mar 2009
    Posts
    48


    Did you find this post helpful? Yes | No

    Default thx ionnis i appreciate for your reply

    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!

    Code:
    '****************************************************************
    '*  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

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


    Did you find this post helpful? Yes | No

    Default

    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

  5. #5
    Join Date
    Mar 2009
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    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!
    Attached Images Attached Images   

  6. #6
    Join Date
    Mar 2009
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    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
    Attached Images Attached Images  

  7. #7
    Join Date
    Mar 2009
    Posts
    48


    Did you find this post helpful? Yes | No

    Default thx

    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
    Code:
    '****************************************************************
    '*  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

  8. #8
    Join Date
    Mar 2009
    Posts
    48


    Did you find this post helpful? Yes | No

    Default 1 question

    is there any way to get data fom hserin or hserout statement to lcd?????

  9. #9
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,796


    Did you find this post helpful? Yes | No

    Default

    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

  10. #10
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,796


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by xxxxxx View Post
    is there any way to get data fom hserin or hserout statement to lcd?????
    Have you used LCD before?

    Ioannis

  11. #11
    Join Date
    Mar 2009
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ioannis View Post
    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!!!

  12. #12
    Join Date
    Mar 2009
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ioannis View Post
    Have you used LCD before?

    Ioannis
    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
    Last edited by xxxxxx; - 10th March 2009 at 14:34.

  13. #13
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,796


    Did you find this post helpful? Yes | No

    Default

    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.

  14. #14
    Join Date
    Mar 2009
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ioannis View Post
    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

  15. #15
    Join Date
    Mar 2009
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ioannis View Post
    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

  16. #16
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,796


    Did you find this post helpful? Yes | No

    Default

    You are welcome!

    Ioannis

  17. #17
    Join Date
    May 2007
    Location
    Republic Serbia
    Posts
    105


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by xxxxxx View Post
    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

  18. #18
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,796


    Did you find this post helpful? Yes | No

    Default

    At the first AT the device auto syncs to the baud rate. Usually the 9600 is the default.

    No 19200 as standard.

    Ioannis

  19. #19


    Did you find this post helpful? Yes | No

    Default

    Hi,

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

  20. #20
    Join Date
    Mar 2009
    Posts
    48


    Did you find this post helpful? Yes | No

    Default simple device for sms controll of biomas heating device

    Code:
    '****************************************************************
    '*  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

  21. #21
    Join Date
    Mar 2009
    Posts
    48


    Did you find this post helpful? Yes | No

    Default rest of code

    Code:
    '---------------------------------------------------------------------
    ' 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

  22. #22
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,796


    Did you find this post helpful? Yes | No

    Default

    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

  23. #23
    Join Date
    Mar 2009
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ioannis View Post
    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!!!

  24. #24
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,796


    Did you find this post helpful? Yes | No

    Default

    You are welcome. Thanks for posting your work too.

    Ioannis

  25. #25
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,796


    Did you find this post helpful? Yes | No

    Default

    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:
    Code:
    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

  26. #26
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default How to invert hardware serial port

    Quote Originally Posted by Ioannis View Post
    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:
    Code:
    	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.
    Last edited by ScaleRobotics; - 10th February 2010 at 16:58.

Similar Threads

  1. Replies: 11
    Last Post: - 19th August 2009, 16:23
  2. problem with the GSM controller
    By Dariolo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 30th May 2009, 21:33
  3. Replies: 0
    Last Post: - 21st May 2009, 01:58
  4. parsing string from hserin
    By xxxxxx in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 2nd April 2009, 19:42
  5. Reading a SMS to an array
    By KA5MAL in forum GSM
    Replies: 3
    Last Post: - 17th June 2008, 18:24

Members who have read this thread : 1

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