The Godfather talking
Share your stuff or I will make you regret it.
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 27, 2024, 09:42:01 21:42


Login with username, password and session length


Pages: [1]
Print
Author Topic: Send and receive SMS with 16F628 and PICBASIC  (Read 31174 times)
0 Members and 1 Guest are viewing this topic.
kalpakchiev
Active Member
***
Offline Offline

Posts: 137

Thank You
-Given: 34
-Receive: 68



« on: December 30, 2007, 02:50:37 02:50 »

'Program for 2 inputs & GSM ERICSSON 1018S CPU PIC16F628
'Íàñòðîéêà:
'Íàòèñêà ñå RESET  (äæúìïåðà íàêúñî) è ñå çàäúðæà, íàòèñêà ñå PROG è ñå çàäúðæà, îòïóñêà ñå
'  RESET è ñëåä òîâà ñå îòïóñêà PROG
'Âñåêè ïîðåäåí íîìåð íà ÑÌÑ, êîéòî ùå ñå èçïðàùà (èëè íå) ñå âèçóàëèçèðà ñúñ ñúîòâåòíèÿ
'  áðîé ïðåìèãâàíèÿ. Àêî å íåàêòèâíî - 1 ïðåìèãâàíå, àêî å àêòèâíî - 2 ïðåìèãâàíèÿ.
'Ñëåä òîâà çà îêîëî 3 ñåêóíäè ñâåòîäèîäà ìèãà áúðçî, êîåòî îçíà÷àâà, ÷å ùå ñå âúâåæäà
'  íîâà ñòîéíîñò çà ñúîòâåòíèÿ ÑÌÑ. Àêî ñå íàòèñíå áóòîíà â òîçè èíòåðâàë ñå àêòèâèðà
'  èçïðàùàíåòî íà ÑÌÑ ñ òîçè íîìåð, â ïðîòèâåí ñëó÷àé ñå äåàêòèâèðà. Ïî òîçè íà÷èí
'  ñå âúâåæäà çà âñè÷êè ÑÌÑ êîíôèãóðàöèÿ äàëè äà ñå èçïðàùàò èëè íå.
'Ñëåä âúâåæäàíåòî íà ñòîéíîñò çà 8-ìèÿ ÑÌÑ ñâåòîäèîäà ïðåìèãâà áúðçî è î÷àêâà âúâåæäàíå
'  çà èçïðàùàíå íà ÑÌÑ ÒÅÑÒ çà ïúðâèÿ íîìåð (ïàê ïî ñúùèÿ íà÷èí) è íàêðàÿ âúâåæäàíå çà èçïðàùàíå
'  íà ÑÌÑ ÒÅÑÒ íà âòîðèÿ íîìåð.
'Ñëåä êðàÿ íà òîçè ïðîöåñ ñâåòîäèîäà ñâåòè ïîñòîÿííî è çà äà ñå ñòàðòèðà ïðîöåñîðà
'  ñå íàòèñêà RESET
'Àêî â ïðîöåñà íà ðàáîòà (íå â ðåæèì ïðîãðàìèðàíå) ñå íàòèñíå PROG çà ïîâå÷å îò
'  1 ñåê. ñå íóëèðà òàéìåðà çà òåñò è ñå èçïðàùàò ÑÌÑ ÒÅÑÒ íà ïðîãðàìèðàíèòå òåëåôîíè
'  (íåçàâèñèìî äàëè å ðàçðåøåíî èëè íå!)
'Íîìåðà íà ÑÌÑ-è è òåëåôîíè:
'1-OPEN çà ÖÅÍÒÚÐ, 2-CLOSE çà ÖÅÍÒÚÐ, 3-ALARM çà ÖÅÍÒÚÐ, 4-Âúçò. ALARM çà öåíòúðà, 9-TEST çà ÖÅÍÒÚÐ
'5-OPEN çà ÊËÈÅÍÒ, 6-CLOSE çà ÊËÈÅÍÒ, 7-ALARM çà ÊËÈÅÍÒ, 8-Âúçò. ALARM çà ÊËÈÅÍÒ, 10-TEST çà ÊËÈÅÍÒ
'1-Íîìåð íà ÖÅÍÒÚÐ, 2-Íîìåð íà ÊËÈÅÍÒ

DEFINE NO_CLRWDT 1 'Forces manual use of CLRWDT
OPTION_REG.7=0           ' To enable the weak pullups on PORTB
CMCON = 7                ' ALL PORTS DIGITAL
@ device intrc_osc,wdt_off,pwrt_on,mclr_off,bod_off,protect_on

'ÊÎÍÑÒÀÍÒÈ
ZoneDelay     con 200 'Âðåìå â ìñåê. çà êîåòî çîíàòà ìîæå äà âàðèðà
Zones         Con %00110000 'Çîíèòå, êîèòî íè èíòåðåñóâàò ïðè ïðîìÿíà
Ser_Mode      con 16468
Ser_Mode_Deb  con 16468
PhoneLoc     con 3
MaxB         con 80 'Ìàêñèìëíà äúëæèíà íà Buffer
MaxRead      con 255 'Ìàêñèìàëíî âðåìå â ìñåê. çà ÷åòåíå îò ñåðèíèÿ ïîðò
Data @0,%01000100,%00000010,168

'ÈÇÕÎÄÈ                                         
TX_PIC    Var  PortA.0
LED       Var  PortB.0

TrisA=%00010000
TrisB=%11111110

'ÂÕÎÄÎÂÅ
Jump       var PortB.6 'ìîæå äà å îïðîâîäåíî è êàòî ÐÅÑÅÒ
RX_PIC     Var PortA.4
'OpenClose Var PortB.4
'Alarm     Var PortB.5
'Zone3     var PortB.7
Buton      var PortB.2

'VARIABLES
Char       var byte
I          var byte
I1         Var Byte
J          var Byte
J1         Var Byte
Buffer     Var Byte [MaxB]
LenB       Var Buffer[0] 'Äúëæèíà íà Buffer
Phone      var Byte[10]
CLIPPhone  var byte[10]
Pos        var byte
Stat       Var Byte
Alarm      Var Stat.5
OpenClose  Var Stat.4
Zone3      var Stat.7

TmpByte         var byte
Config_1        Var Byte
OpenClose_1_C   var config_1.0
OpenClose_0_C   var config_1.1
Alarm_1_C       Var Config_1.2
Alarm_0_C       var Config_1.3
OpenClose_1_K   var config_1.4
OpenClose_0_K   var config_1.5
Alarm_1_K       var config_1.6
Alarm_0_K       Var Config_1.7
Config_2        var byte
SMS_Test_C      var Config_2.0
SMS_Test_K      Var Config_2.1
Seconds         var byte
Minutes         var byte
Hours           var byte
Time_Limit      Var Byte
SMS_No          var Byte
Result          Var byte

ButonVal        Var bit
Bit_Val         Var bit 

'1-OPEN çà ÖÅÍÒÚÐ, 2-CLOSE çà ÖÅÍÒÚÐ, 3-ALARM çà ÖÅÍÒÚÐ, 4-Âúçò. ALARM çà öåíòúðà, 9-TEST çà ÖÅÍÒÚÐ
'5-OPEN çà ÊËÈÅÍÒ, 6-CLOSE çà ÊËÈÅÍÒ, 7-ALARM çà ÊËÈÅÍÒ, 8-Âúçò. ALARM çà ÊËÈÅÍÒ, 10-TEST çà ÊËÈÅÍÒ
Phone_No   Var Byte
'1-Íîìåð íà ÖÅÍÒÚÐ, 2-Íîìåð íà ÊËÈÅÍÒ, 3-Ðåçåðâåí ÍÎÌÅÐ

INIT:
 Clear
 Pause 250:Led=0:Read 0,Config_1:read 1,Config_2:read 2,Time_limit
 If Buton=0 Then 'PROGRAM MODE
  while Buton=0
  wend
  for i=0 to 7
   Gosub Vis_I
   Bit_Val=config_1.0:gosub Visual_Bit
   gosub ReadButon
   config_1.0=Butonval
  next i
  write 0,config_1
  Led=1:Pause 100:Led=0:pause 200:Led=1:pause 100:Led=0:pause 200:Led=1:pause 100:Led=0:pause 2000
  for i=0 to 1
   Gosub Vis_I
   Bit_Val=config_2.0:gosub Visual_Bit
   gosub ReadButon
   config_2.0=Butonval
  next i
  write 1,config_2
  Led=1:Pause 50:end   
 endif 'Buton=0 end PROGRAM MODE
MAIN: 'Normal ENTRY 
 Pause 250 
 serout2 tx_pic,Ser_mode,["AT",13]:gosub ReadBuff
 serout2 tx_pic,Ser_mode,["ATZ",13]:gosub ReadBuff
 serout2 tx_pic,ser_mode,["AT+CRC=1",13]:gosub ReadBuff
 Stat=PortB'Ñúõðàíÿâàíå ñúñòîÿíèåòî íà PortB
 
MAIN_LOOP:
if Jump=0 Then
 While Jump=0
 wend
 goto INIT 'Òîâà âåðîÿòíî å ÐÅÑÅÒ (õàðäóåðåí)
endif 'Jump=0
if Buton=0 Then
 pause 1000
 if Buton=0 Then
  while Buton=0
  wend
   seconds=0:minutes=0:hours=0 
   Phone_no=1:sms_no=9
   Gosub Send_SMS 'TEST çà ÖÅÍÒÚÐ
   Phone_no=2:sms_no=10
   Gosub Send_SMS 'TEST çà ÊËÈÅÍÒ   
 endif
endif  'Buton=0
toggle LED
Serin2 RX_PIC,ser_mode,250,Time,[Char]
If Char="+" Then PROCEED
Time:
 Seconds=Seconds+1
 If Seconds>=240 Then 'Èçòåêëà ìèíóòà? MUST BE 240
   Seconds=0
   Minutes=Minutes+1
   If Minutes>=60 Then 'Èçòåêúë ÷àñ?
    Minutes=0
    Hours=Hours+1
    If hours>=time_limit Then
     seconds=0:minutes=0:hours=0
     if Sms_Test_C Then
      Phone_no=1:sms_no=9
      Gosub Send_SMS 'TEST çà ÖÅÍÒÚÐ
     endif 'SMS_TEST çà Öåíòúð
     if Sms_Test_K Then     
      Phone_No=2:SMS_No=10
      Gosub Send_SMS 'TEST çà ÊËÈÅÍÒ     
     endif 'SMS_TEST çà ÊËÈÅÍÒ
   endif 'Hours
  EndIf 'Minutes
 EndIf 'Seconds   
 result=Stat^PortB'Àêî èìà ïðîìÿíà ïîíå â åäèí ïèí òî Result<>0
 Result=Result&zones' Èíòåðåñóâàò ìå ñàìî PortB.5 & PortB.4
 if result Then 'Èìà ïðîìÿíà ïîíå â åäèí ïèí îò èíòåðåñóâàùèòå íè çîíè
  pause ZoneDelay
  tmpbyte=stat^PortB    'Íîâà ñíèìêà
  tmpbyte=tmpbyte&zones 'íà èíòåðåñóâàùèòå íè çîíè
  if result<>tmpbyte Then MAIN_LOOP'Ôàëøèâî ñðàáîòâàíå
  Goto ZONE_Chanched
 endif
goto MAIN_LOOP

ZONE_Chanched:
 Stat=PortB
 if result.5 Then
  if Alarm=0 Then
    if Alarm_1_C Then
     phone_no=1:Sms_no=3:Gosub Send_SMS
    endif
    if Alarm_1_K Then
     phone_no=2:Sms_no=7:Gosub Send_SMS
    endif 
   else
    if Alarm_0_C Then
     phone_no=1:Sms_no=4:Gosub Send_SMS
    endif
    if Alarm_0_K Then
     phone_no=2:Sms_no=8:Gosub Send_SMS
    endif 
  endif 'Alarm=0
 endif 'Result.5 ò.å. âõîä 2 (PGM2)
 if Result.4 Then
  if OpenClose=1 then
    if OpenClose_1_C Then
     phone_no=1:sms_no=1:gosub Send_SMS
    endif
    if OpenClose_1_K Then
     Phone_no=2:SMS_No=5:Gosub Send_SMS
    endif
   else
    if OpenClose_0_C Then
     phone_no=1:sms_no=2:gosub Send_SMS   
    endif
    if OpenClose_0_K Then
     Phone_No=2:SMS_No=6:Gosub Send_SMS
    endif 
  endif 'OpenClose=1   
 endif
goto MAIN_LOOP

PROCEED:
 gosub ReadBuff
HangUp:
 Serout2 TX_PIC,ser_mode,["AT+CHUP",13]:gosub ReadBuff
 Serout2 TX_PIC,Ser_mode,["AT+CKPD=",34,"EE",34,",1",13]:gosub ReadBuff
Goto MAIN_Loop
'*********************************************************************
Send_SMS:'Ïàðàìåòðè Phone_No (1,2), SMS_No (1,10)
Serout2 TX_PIC,Ser_mode,["AT+CKPD=",34,"<"]:pause 50
serout2 TX_PIC,Ser_Mode,["<"]:Pause 50
serout2 TX_PIC,Ser_Mode,["S"]:Pause 50
Serout2 TX_PIC,Ser_Mode,[">"]:Pause 50
serout2 TX_PIC,Ser_Mode,["S"]:pause 50
for I=1 To Sms_no
 serout2 TX_PIC,ser_mode,[">"]:Pause 50
next i
serout2 TX_PIC,ser_mode,["SS<"]
for I=1 To phone_no
 serout2 TX_PIC,Ser_mode,[">"]
next i
serout2 TX_PIC,Ser_mode,["S",34,",2",13]:Gosub ReadBuff
Pause 15000 
Serout2 TX_PIC,Ser_mode,["AT+CKPD=",34,"E",34,",1",13]:gosub ReadBuff
RETURN
'*********************************************************************
ReadBuff: 'Èç÷èòàíå íà ñèìâîëèòå îò ñåðèéíèÿ ïîðò íà òåëåôîíà. Ðåçóëòàò:
          'LenB - äúëæèíà íà áóôåðà, Buffer - ñàìèòå ñèìâîëè
   I=1:LenB=0
   While I<MaxB
     Serin2 RX_PIC,Ser_Mode, MaxRead,Buffer_OK,[Char]
     Buffer=Char
     LenB=I
     I=I+1
   Wend
 Clean_RX:
   Serin2 RX_PIC,Ser_Mode, MaxRead,Buffer_OK,[Char]
   Goto Clean_RX
 Buffer_OK:
Return
'*********************************************************************
Vis_I:
 I1=I+1:Led=0
 For J=1 to I1
  Led=1:Pause 300:Led=0:Pause 500
 next J
 Pause 1500
Return
'*********************************************************************
ReadButon:
  Butonval=0
  For J=1 To 80
  toggle Led
   If Buton=0 Then
    while Buton=0
    wend
    butonval=1
    goto End_sub
    return
   endif
   pause 50
  next J
  End_Sub:
  Led=0:pause 1000   
return
'********************************************************************* 
Visual_Bit:
   Led=0
   if bit_val then
     Led=1:Pause 1000:led=0:pause 300:led=1
    else
     Led=1:
   endif
   pause 1000:Led=0:pause 2000
return
'********************************************************************* 
Logged

A known mistake is better than an unknown truth.
Roshan
Newbie
*
Offline Offline

Posts: 17

Thank You
-Given: 5
-Receive: 2


« Reply #1 on: December 30, 2007, 06:13:21 06:13 »

Hi !

I can read only english not like this

'  íîâà ñòîéíîñò çà ñúîòâåòíèÿ ÑÌÑ. Àêî ñå íàòèñíå áóòîíà â òîçè èíòåðâàë ñå àêòèâèðà
'  èçïðàùàíåòî íà ÑÌÑ ñ òîçè íîìåð, â ïðîòèâåí ñëó÷àé ñå äåàêòèâèðà. Ïî òîçè íà÷èí
'  ñå âúâåæäà çà âñè÷êè ÑÌÑ êîíôèãóðàöèÿ äàëè äà ñå èçïðàùàò èëè íå.
'Ñëåä âúâåæäàíåòî íà ñòîéíîñò çà 8-ìèÿ ÑÌÑ ñâåòîäèîäà ïðåìèãâà áúðçî è î÷àêâà âúâåæäàíå


i have program which can send sms to any predefined number. It is written in proton & mcu pic16f877a if you interested then i can post program here.

Ros
Logged
alpaslan
Junior Member
**
Offline Offline

Posts: 62

Thank You
-Given: 6
-Receive: 48


« Reply #2 on: December 30, 2007, 07:37:43 07:37 »

Roshan,

What a strange question or suggestion you make?  Of course if you have any body will use it. For example me. Still interesting subject it is. Please upload your work.

Thanks.
Logged
kalpakchiev
Active Member
***
Offline Offline

Posts: 137

Thank You
-Given: 34
-Receive: 68



« Reply #3 on: December 30, 2007, 11:31:13 11:31 »

Sorry about this, all coments are in bulgarian language (code page 1251), if you are interested i can explain about the program
Logged

A known mistake is better than an unknown truth.
bbarney
Moderator
Hero Member
*****
Offline Offline

Posts: 2429

Thank You
-Given: 405
-Receive: 545


Uhm? where did pickit put my mute button


« Reply #4 on: December 30, 2007, 04:06:13 16:06 »

That would be great.you can see the the problem when you post code like that,we get all kinds of post's saying the same thing I can't read that so please fix it before posting it because if we can't read it ,it's not much good to us non-bulgarian's Grin
thank's
Logged

Ever wonder why Kamikaze pilot's wore helmet's ?
jeanninemtv
Senior Member
****
Offline Offline

Posts: 311

Thank You
-Given: 57
-Receive: 25


« Reply #5 on: December 30, 2007, 09:00:50 21:00 »

one question:

i have a nokia 1112 cellphone..

how can i use at commands with this cellphone...

i dont find the connector or pins.... to do that
Logged
KhaledLotfy
Junior Member
**
 Muted
Offline Offline

Posts: 39

Thank You
-Given: 19
-Receive: 8


« Reply #6 on: December 30, 2007, 09:51:48 21:51 »

kalpakchiev
will you please write your comments in English for all of us
Regards
Khaled
Logged
forter
Active Member
***
Offline Offline

Posts: 139

Thank You
-Given: 1051
-Receive: 28


« Reply #7 on: January 05, 2008, 09:40:00 09:40 »

I am very intrestinf this things, and because I am agree with bbarney,
It is forum and if you wish, that all people in this forum can fully understand you, you must speaking on common language. In that case - it is english.
Please translate all in  it/
 
Logged
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1203

Thank You
-Given: 554
-Receive: 409



« Reply #8 on: January 05, 2008, 10:33:46 10:33 »

Hi !

i have program which can send sms to any predefined number. It is written in proton & mcu pic16f877a if you interested then i can post program here.

Ros

Can you upload it then Roshan and sahre it with us

wizpic
Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
Roshan
Newbie
*
Offline Offline

Posts: 17

Thank You
-Given: 5
-Receive: 2


« Reply #9 on: January 07, 2008, 12:49:08 12:49 »

Hi below is my program which will send sms when sw is on & sw if off with date & time stamp.

Code:
Device 16F877A
XTAL 4
Config xt_osc,pwrte_on,wdt_off,boden_off,lvp_off,debug_off
'------------------------------------------------
Declare LCD_DTPIN PORTD.4
Declare LCD_ENPIN PORTD.3
Declare LCD_RSPIN PORTD.2
Declare LCD_LINES 2
Declare LCD_TYPE alpha
Declare LCD_INTERFACE 4
'-------------------------------------------------
Symbol sw PORTB.7
Symbol main_in PORTA.0
Symbol rst PORTE.2
Symbol clk PORTE.0
Symbol dta PORTE.1
Declare KEYPAD_PORT PORTB
Declare SDA_PIN PORTD.0
Declare SCL_PIN PORTD.1
Symbol control_write %10100001
Symbol control_read %10100000
'--------------------------------------------------
HSERIAL_BAUD = 9600 ' Set baud rate to 9600
HSERIAL_RCSTA = %10010000       ' Enable serial port and continuous receive
HSERIAL_TXSTA = %00100100       ' Enable transmit and asynchronous mode
'bit-5 is transmit enable bit
HSERIAL_CLEAR = On ' Enable Error clearing on received cha

'---------------------------------------------------
Dim t[3] As Byte
Dim center [13] As Byte
Dim mobile [13] As Byte
Dim sec As Byte
Dim mint As Byte
Dim hour As Byte
Dim date As Byte
Dim month As Byte     
Dim year As Byte
Dim day As Byte
Dim var1 As Byte
Dim var2 As Byte
Dim keyres As Byte
Dim temp As Byte
Dim wp As Byte
Dim keydata As Byte
Dim sms_counter As Byte
Dim sec_old As Byte
Dim keyres1 As Byte
'------------------------
DelayMS 200
ALL_DIGITAL true
PORTB_PULLUPS On
TRISA = %11111111
TRISB = %11111111
TRISC = %10111111
TRISD = %00000000
TRISE = %00000000
Clear OPTION_REG.6                             
'---------------------------------------------------
DelayMS 100
Clear PORTA
Clear PORTB
Clear PORTC
Clear sms_counter
Clear sec_old

'-------------------------------------------------
Print Cls,"SMS based data"
Print At 2,1,"logger systems"
DelayMS 1500
'
'-------------------------------------------------
For var1 = 1 To 7 Step 1
    Select var1
   
    Case 1
    Print Cls,"Enter Year"
   
    Case 2
    Print Cls,"Enter Month"
   
    Case 3
    Print Cls,"Enter Date"
   
    Case 4
    Print Cls,"Enter Hours"
   
    Case 5
    Print Cls,"Enter Minutes"
   
    Case 6
    Print Cls,"Enter Seconds"
   
    Case 7
    Print Cls,"Enter Day"
   
    End Select
   
   
   
    For var2 = 1 To 2 Step 1

pay:
    GoSub find_key
    If keyres > 9 Then GoTo pay
    Print At 2,var2,@keyres
    t[var2] = keyres
    DelayMS 500
    Next
    Call convert1
   
             Select var1
             
             Case 1
             year = temp
             
             Case 2
             month = temp
             
             Case 3
             date = temp

             Case 4
             hour = temp
             
             Case 5
             mint = temp
             
             Case 6
             sec = temp
             
             Case 7
             day = temp
             End Select
             DelayMS 250
             
             Next
'-------------------------------
             wp = $80
'**************************************             
'set ht1380 rtc with current data & time
'clear write protect bit
'**************************************
'before setting new data user have to reset rtc
Set rst
SHOut dta,clk,lsbfirst,[$8E,0]
Clear rst
DelayUS 10
Set rst
SHOut dta,clk,lsbfirst,[$80,0]
Clear rst
DelayUS 10
Set rst
SHOut dta,clk,lsbfirst,[$be,sec,mint,hour,date,month,day,year,wp]
Clear rst
DelayMS 10
'----------------------------------
 
'now we will ask for message center number
Print Cls,"Enter Message"
Print At 2,1,"Center Number"
DelayMS 1000
Print Cls,"Center Number"
center[0] = "+"


For var1 = 1 To 12 Step 1

m1:
          GoSub find_key
          If keyres > 14 Then GoTo m1
          If keyres = 14 Then
                    Dec var1
                    GoTo pg1
                    EndIf
         
          Print At 2,var1,@keyres
          GoSub convertdata
          center[var1] = keyres1
pg1:         
          DelayMS 500
          Next

         

Print Cls,"Message center"
Print At 2,1,"Number stored"
DelayMS 1000

'---------------------------------------------
Print Cls,"Ent. Destination"
Print At 2,1,"Mobile Number"
DelayMS 1000
Print Cls,"Mobile Number"         
mobile[0] = "+"

For var1 = 1 To 12 Step 1

m2:
          GoSub find_key
          If keyres > 14 Then GoTo m2
          If keyres = 14 Then
                    Dec var1
                    GoTo pg
                    EndIf
          Print At 2,var1,@keyres
          GoSub convertdata
          mobile[var1] = keyres1
          pg:
          DelayMS 500
          Next



Print Cls,"Destination"
Print At 2,1,"Number stored"
DelayMS 1000


         
         


pay1:
          DelayMS 200   
   
    GoSub get_time
   
    If sec_old = sec Then GoTo pay1
    Print Cls,HEX2 date,"/",HEX2 month,"/",HEX2 year
    Print At 2,1,HEX2 hour,":",HEX2 mint,":",HEX2 sec
    sec_old = sec

    If main_in = 1 Then GoTo pay1
   
    DelayMS 500
   
   

iop:
   


'-----------------------------------
Set INTCON.3        'enable rb port change interrupt

main:
main1:
Clear INTCON.0         'rb port change flag
TRISB = %11111111
DelayMS 250

'----------------------------------
       Sleep                                                               
       DelayMS 100
       GoSub get_time
       
       
loop1:

Print Cls,"AT"
HSerOut ["AT",13]
'send at at command with carriage return to gsm module
'if returns = ok then response back ok


HSerIn 5000,sms,[Wait("OK")]
'wait for 5 second to response ok
'if time out then go back to retry sms
'
'if gsm module ok then respone is ok else error or no response
'if error comes then it will jump to sms label to show error         
Print At 2,1,"OK"
DelayMS 100


HSerOut ["AT+CMGF=1",13]

'send command to gsm for text mode
HSerIn 5000,sms,[Wait("OK")]

DelayMS 100
'wait for 5 second to response ok else jump to sms label
'

HSerOut ["AT+CSCA=",34,Str center,34]
HSerOut [13]

'here we send the message center number & wait for ok
HSerIn 5000,sms,[Wait("OK")]
'wait for ok response

DelayMS 500


HSerOut ["AT+CMGS=",34,Str mobile,34]

'here is desitnation number
HSerOut [13]

HSerIn 5000,sms,[Wait(">")]

DelayMS 500

If sw = 1 Then

HSerOut["Switch is open "]
'HSerOut[26]
Else
HSerOut["Switch is close "]
'hserout[26]
EndIf


HSerOut[" Date is ",HEX2 date,"/",HEX2 month,"/",HEX2 year]
HSerOut[" Time is ",HEX2 hour,":",HEX2 mint,":",HEX2 sec]
HSerOut[" SMS Retry ",DEC3 sms_counter]
HSerOut[" Roshan",26]

HSerIn 5000,sms,[Wait("+CMG")]

Clear INTCON.1
Clear sms_counter
Print Cls,"Message sent"
DelayMS 500
GoTo main1





     
                                                           

'------------------------------------   
get_time:
Set rst
SHOut dta,clk,lsbfirst,[$BF]
SHIn dta,clk,lsbpre,[sec,mint,hour,date,month,day,year,wp]
Clear rst
Return
'------------------------------------
find_key:
keydata = InKey
keyres = LookUpL keydata,[14,0,15,255,7,8,9,255,4,5,6,255,1,2,3,16,16]
Return
'-------------------------------------
convertdata:
keyres1 = LookUpL keyres,["0","1","2","3","4","5","6","7","8","9"]
Return
'------------------------------------
convert1:
Clear STATUS.0
t[1]=t[1]<<4
temp = t[1]+t[2]
Return
'----------------------------------------------------------

sms:
Print Cls,"1st problem"
DelayMS 1000
Cls
Inc sms_counter
If sms_counter < 10 Then

GoTo loop1
Else
GoTo main
EndIf




cose is written in pds & working fine.

Roshan
Logged
lillbear
Senior Member
****
Offline Offline

Posts: 276

Thank You
-Given: 223
-Receive: 182



« Reply #10 on: January 07, 2008, 06:43:45 18:43 »

Nice, but wheres schematics?  Grin
Logged
Roshan
Newbie
*
Offline Offline

Posts: 17

Thank You
-Given: 5
-Receive: 2


« Reply #11 on: January 08, 2008, 08:03:09 08:03 »

Hi

Circuit is attached use isis to open it.

Posted on: January 08, 2008, 09:01:02 09:01 - Automerged

i attached zip but where is zip file it does not show mw I reied two times.
Logged
forter
Active Member
***
Offline Offline

Posts: 139

Thank You
-Given: 1051
-Receive: 28


« Reply #12 on: January 08, 2008, 09:17:21 09:17 »

Hi, all!
Please note, Roshan used PIC 877, not 628!
Logged
Roshan
Newbie
*
Offline Offline

Posts: 17

Thank You
-Given: 5
-Receive: 2


« Reply #13 on: January 09, 2008, 12:51:36 12:51 »

877 & 628 both have usart & can be used by little modification.

Roshan
Logged
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1203

Thank You
-Given: 554
-Receive: 409



« Reply #14 on: January 09, 2008, 10:20:40 22:20 »

Roshan I take it that is not the full code ?  Huh

Has I see you used interrupts and the Eread/Ewrite commands are missing for when you store data.  Smiley

Would you share the full code ?  Cool

PM me if you want with code  Wink  Lips sealed

Your code has proved to be very useful to me, I have picked up some great tips and some of the code I can use  Grin
I did wonder how I could input data via key pad so if you entered 23456 and it stores it has 23456,

My project it to use some of your code to make a data type logger where i can enter numbers and have a store button to store it then upload it into excel hope you don't mind  Wink Grin
 

wizpic
« Last Edit: January 09, 2008, 10:26:33 22:26 by Wizpic » Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
Roshan
Newbie
*
Offline Offline

Posts: 17

Thank You
-Given: 5
-Receive: 2


« Reply #15 on: January 14, 2008, 01:59:27 13:59 »

Dear WIZPIC,

I am using keypad for rtc. When user will lost power then he can enter date & time via 4*3 keypad.

Roshan
Logged
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1203

Thank You
-Given: 554
-Receive: 409



« Reply #16 on: January 14, 2008, 06:11:50 18:11 »

Dear WIZPIC,

I am using keypad for rtc. When user will lost power then he can enter date & time via 4*3 keypad.

Roshan

I can see that and have simed it in proteus but you never answered the question about the interrupts or saving the data to eprom

wizpic
Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
Roshan
Newbie
*
Offline Offline

Posts: 17

Thank You
-Given: 5
-Receive: 2


« Reply #17 on: January 15, 2008, 06:04:05 06:04 »

Dear Wizpic,

i am also test it in isis & working ok.

pls. check my program carefully i am not using interrupt in my program.

i have declared scl & sda in my program but i am not using currently. There is future options. When my program want to send sms & if any reason ( due to network failure etc.) program failed to send sms then it will store sw ( date & time stamp) information in eeprom & try after 10 minutes until finished process.

Roshan
Logged
mohsaid55
Newbie
*
Offline Offline

Posts: 7

Thank You
-Given: 0
-Receive: 1


« Reply #18 on: January 15, 2008, 06:50:06 18:50 »

I want to send and receive sms using pic16f877 and Nokia 6210 any idea?code?circuit?
Logged
glenjoy
Newbie
*
 Muted
Offline Offline

Posts: 11

Thank You
-Given: 2
-Receive: 6


« Reply #19 on: January 17, 2008, 01:25:20 01:25 »

It will be hard for pic to perform full sms receive and send, they only have very small scratchpad.
Logged
mohsaid55
Newbie
*
Offline Offline

Posts: 7

Thank You
-Given: 0
-Receive: 1


« Reply #20 on: January 23, 2008, 12:48:56 12:48 »

After googling i found code that send and recieve sms by  Using the PIC16F877 and Siemens S25 GSM-phone can any one modify it to use with Nokia 6210 the code:
DEVICE WDT_OFF & PWRT_OFF  & PROTECT_OFF

' ***** Define Oscillator speed in MHz, default is 4 MHz xtal.
Define OSC 8         '3 (3.58) 4 8 10 12 16 20 24 25 32 33 40

' ***** Define LOADER_USED to allow use of the boot loader
'Define   LOADER_USED   1    'this will not affect normal program operation.

' ***** Define LCD registers and bits
Define LCD_DREG PORTD
Define LCD_DBIT 4
Define LCD_RSREG PORTE
Define LCD_RSBIT 0
Define LCD_EREG PORTE
Define LCD_EBIT 1

' ***** Define ADCIN parameters
Define adc_bits 10    ' Set number of bits in result
Define ADC_CLOCK 3    ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50

' ****create the variables
advalue  var Word    'mesured value for Voltmeter input
rs232t   var PortA.5 'TXD to GSM-phone
rs232r   var PortA.4 'RXD from GSM-phone
Sensor_1 var PortC.0 'Sensor-1
Sensor_2 var PortC.1 'Sensor-2
Sensor_3 var PortC.2 'Sensor-3
Config_Sw var PortC.3 'Config switch
Output_1 var PortB.0 'Output-1
Output_2 var PortB.1 'Output-2
Output_3 var PortB.2 'Output-3
Output_4 var PortB.3 'Output-4

Msg_nr_Sent var bit[4]
Msg_nr var byte
SDin  var word
Timer1 var bit
Msec_Timer1 var word
Sec_Timer1 var byte
Min_Timer1 var byte
Cnt var byte
Cnt2 var word

' ****create the constants
Baud  con 32 '19200,8,N,1 (true, driven) (SIEMENS S25)     
cm    con 44 'comma (,)
qt    con 34 'quote (")
Timer1_Time con 60 '60 min.

'****** set port direction to inputs/outputs
ADCON1 = %10000100   'make PORTA.0,1,3 analog, PORTA.2,4,5 digital, and right justify result
TRISA = %011111      'make PORTA.5 pin output PORTA.1,2,3,4 pins input
TRISB = %11110000    'make PORTB.0,1,2,3 pins output, PORTB.4,5,6,7 pin input
TRISC = %11111111    'make PORTC all input
TRISD = %00001111    'make PORTD.4,5,6,7 pins outputs, PORTD.0,1,2,3 pin input
TRISE = %100         'make PORTE.0,1 pins output, PORTE.2 pin input

'****** initialize
PORTA = 0 : PORTA.5 = 1 'turn off PORTA pins, and SEROUT2 bug fix Smiley
PORTB = $ff 'turn off PORTB pins,
PORTC = 0 'turn off PORTC pins,
PORTD = 0 'turn off PORTD pins,
PORTE = 0 'turn off PORTE pins,

Msg_nr_Sent[1] = 0
Msg_nr_Sent[2] = 0
Msg_nr_Sent[3] = 0

PAUSE 500   'wait for LCD init.
'gosub Reset_Timer1

Cnt2 = 0
Main:
   pause 1
   'gosub Update_Timer1
   Cnt2 = Cnt2 + 1
   Select case Cnt2
      case 1
         LCDOut $fe,1,"-<< PIC-SMS >>-",$fe,$c0,"(C)F-San"
      case 3000
         gosub Check_SIM
         LCDOut $fe,1,"CHECKING: SMS &",$fe,$c0,"..SENSOR inputs"
         gosub Chk_Incoming_SMS
      case 6000       
         gosub Disp_BATT_Voltage
      case 9000       
         Cnt2 = 0
   end select
   gosub Chk_Sensors
goto Main

Chk_Sensors:
   Msg_nr = 0
   if (Sensor_1 = 0) and (Msg_nr_Sent[1] = 0) then Msg_nr = 1 'is this message sent prev.?
   if (Sensor_2 = 0) and (Msg_nr_Sent[2] = 0) then Msg_nr = 2
   if (Sensor_3 = 0) and (Msg_nr_Sent[3] = 0) then Msg_nr = 3
   if Config_Sw = 0 then Write_Config
   if Msg_nr > 0 then
      gosub Check_SIM
      gosub Send_SMS
   endif
return

Check_SIM:
  SerOut2 rs232t,Baud,["AT+CMGF=0",13]
  SerIn2 rs232r,Baud,500,SIM_Error,[wait("OK")]
Return

SIM_Error: 
  LCDOut $fe,1,"NO RESPONS!",$fe,$c0,"CHECK SIM/PHONE"
  Pause 3000
Goto Main

Update_Timer1:
   Msec_Timer1 = Msec_Timer1 + 1   'count msec.
   if Msec_Timer1 >= 1000 then
      'one second elapsed
      Msec_Timer1 = 0
      Sec_Timer1 = Sec_Timer1 + 1 'count sec.   
      if Sec_Timer1 >= 60 then
         'one minute elapsed
         Sec_Timer1 = 0     
         Min_Timer1 = Min_Timer1 + 1 'count min.
         if Min_Timer1 >= Timer1_Time then
            Min_Timer1 = 0       
            Timer1 = 1
         endif
      endif
   endif
return

Reset_Timer1:
   Timer1 = 0
   Msec_Timer1 = 0
   Sec_Timer1  = 0
   Min_Timer1  = 0
return

Disp_BATT_Voltage:
   'This part measures voltage (0-5VDC) and display on LCD with 2 decimal places,
   'uses the */ operator to scale the ADC result from 0-1023 to 0-500. 
   'The */ performs a divide by 256 automatically, allowing math which
   'would normally exceed the limit of a word variable.   
   '
   ' Connect analog input to channel-0 (RA0)
   ADCIN 0, AdValue            ' Read channel 0 to adval (0-1023)
   AdValue = (AdValue */ 500)>>2      ' equates to: (adval * 500)/1024
   'Voltage divider
   '+12Vo---|33K|---o---|5K-Pot|---oGND
   AdValue = AdValue' * 10
   '$fe, 1 = Clear LCD,   $fe, $c0 = Move to line 2
   LCDOut $fe, 1, "BATT.Voltage:", $fe, $c0, "DC Volts= ", DEC (AdValue/100), ".", DEC2 AdValue 'Display the decimal value 
return

Send_SMS:
   LCDOut $fe,1,"SENDING SMS..",$fe,$c0,"SENSOR-",dec Msg_nr," ACTIV."
   SerOut2 rs232t,Baud,["AT+CMSS=",dec Msg_nr,13]
   SerIn2 rs232r,Baud,10000,No_Resp,[wait("OK")]
   LCDOut $fe,$c0,"MESSAGE SENT OK."
   pause 3000
   Msg_nr_Sent[Msg_nr] = 1 'Don't Send this Message again.
return

Write_Config:
   LCDOut $fe,1,"INS. MASTER SIM",$fe,$c0,"then Press Conf."
   gosub Config_Loop
   gosub Check_SIM
   gosub Clear_SMS_Memories
   gosub Save_Master_SMS
   gosub Write_Phone_Book
   LCDOut $fe,1,"INS. SLAVE SIM",$fe,$c0,"then Press Conf."
   gosub Config_Loop
   gosub Check_SIM
   gosub Clear_SMS_Memories
   gosub Save_Slave_SMS
GOTO LCD_Cls

Config_Loop:
   if Config_Sw = 0 then Config_Loop
   cnt2 = 0
   while (Cnt2 < 9000) and (Config_Sw = 1)'wait 1.5 min.
      pause 10
      cnt2 = cnt2 + 1
   wend
   if Cnt2 = 9000 then LCD_Cls
Return

Clear_SMS_Memories:
   LCDOut $fe,1,"CLEAR SMS MEMORY"
   Cnt = 0
   while Cnt < 5 'Erase SMS mem. locations (1..5)
      SerOut2 rs232t,Baud,["AT+CMGD=",dec (Cnt+1),13]
      SerIn2 rs232r,Baud,1000,No_Resp,[wait("OK")]
      LCDOut $fe,$c0,"MEM: ",dec (Cnt+1),"/5"
      Pause 500
      Cnt = Cnt + 1
   wend   
Return

Save_Master_SMS:
   LCDOut $fe,1,"WRITING SMS MSG."
   Cnt = 0
   while Cnt < 2
      SerOut2 rs232t,Baud,["AT+CMGW=26",13] 'PDU length
      SerIn2 rs232r,Baud,500,No_Resp,[wait(">")]
      'Project/SLAVE GSM-phone number, int.format: "7421436587" = "+47 12345678", (+47 is norwegian + 8 numbers)
      SerOut2 rs232t,Baud,["0011FF0A91","7421436587","0000A7","0E","D4BADC"]
      if Cnt = 00 then SerOut2 rs232t,Baud,["FD341"]  'TurnOFF(1-4,A)
      if Cnt = 01 then SerOut2 rs232t,Baud,["DD7A3"]  'Turn-ON(1-4,A)
      SerOut2 rs232t,Baud,["A51B1168D154C01",26,13]
      SerIn2 rs232r,Baud,1000,No_Resp,[wait("OK")]
      LCDOut $fe,$c0,"MASTER-MSG: ",dec (Cnt+1),"/2"
      Pause 500
      Cnt = Cnt + 1
   wend
return

Write_Phone_Book:
   LCDOut $fe,1,"WRITING PH. BOOK",$fe,$c0,"-< PIC-SMS >-"
   pause 2000 'Project/SLAVE GSM-phone number, int.format, (+47 is norwegian + 8 numbers)
   SerOut2 rs232t,Baud,["AT+CPBW=1",cm,qt,"+4712345678",qt,cm,"145",cm,qt,"-< PIC-SMS >-",qt,13]
   SerIn2 rs232r,Baud,1000,No_Resp,[wait("OK")]
return

Save_Slave_SMS:
   LCDOut $fe,1,"WRITING SMS MSG."
   Cnt = 0
   while Cnt < 3
      SerOut2 rs232t,Baud,["AT+CMGW=57",13] 'PDU length
      SerIn2 rs232r,Baud,500,No_Resp,[wait(">")]
      'MASTER GSM-phone number, int.format: "7478563412" = "+47 87654321", (+47 is norwegian + 8 numbers)
      SerOut2 rs232t,Baud,["0011FF0A91","7478563412","0000FF","32","416650DA0C81A665F7FC2D6F"]'ALARM!
      if Cnt = 00 then SerOut2 rs232t,Baud,["C5"]'Sensor-1 activated.
      if Cnt = 01 then SerOut2 rs232t,Baud,["C9"]'Sensor-2 activated.
      if Cnt = 02 then SerOut2 rs232t,Baud,["CD"]'Sensor-3 activated. -<< Sent by PIC-SMS >>-
      SerOut2 rs232t,Baud,["40E1313D6D0FD3CB6417A8C5E381A665371D24CE83A0C9616BDA9C827CBE16",26,13]     
      SerIn2 rs232r,Baud,2000,No_Resp,[wait("OK")]
      LCDOut $fe,$c0,"SLAVE-MSG: ",dec(Cnt+1),"/3"
      Pause 500
      Cnt = Cnt + 1
   wend
return

No_Resp:
   LCDOut $fe,$c0,"-<< No response!"

LCD_Cls:
   Pause 1000
   LCDOut $fe,1
GoTo Main

Send_AT_CMGR:
   SerOut2 rs232t,Baud,["AT+CMGR=4",13] 'Request first SMS
return

Chk_Incoming_SMS:
   gosub Send_AT_CMGR
   SerIn2 rs232r,Baud,500,Incoming_MSG,[wait(",,0")]
return '(Siemens S25, "+CMGR: 0,,0" mem.location empty)

Incoming_MSG:   
   LCDOut $fe,1,"INCOMING SMS.."
   SDin = 0

Chk_Phone_nr:   
   pause 1000
   gosub Send_AT_CMGR
   SerIn2 rs232r,Baud,1000,Wrong_NR,[wait("7478563412")]   'Wait for the correct number, Master GSM.phone nr.

Chk_TurnON:   
   pause 1000
   gosub Send_AT_CMGR
   SerIn2 rs232r,Baud,1000,Chk_TurnOFF,[wait("D4BADCDD7A3A51B1168D154C"),hex4 SDin] 'Wait for "Turn-ON(1-4,A),n"
goto Outputs_ON                           

Chk_TurnOFF:                                       
   pause 1000
   gosub Send_AT_CMGR
   SerIn2 rs232r,Baud,1000,Wrong_ID,[wait("D4BADCFD341A51B1168D154C"),hex4 SDin]      'Wait for "TurnOFF(1-4,A),n"
goto Outputs_OFF

Outputs_ON:
   select case SDin
      case 50432 '1
         Output_1 = 0
         LCDOut $fe,$c0,"Output-1: ON"
         GoTo Command_OK
      case 51456 '2
         Output_2 = 0
         LCDOut $fe,$c0,"Output-2: ON"
         GoTo Command_OK
      case 52480 '3
         Output_3 = 0
         LCDOut $fe,$c0,"Output-3: ON"
         GoTo Command_OK
      case 53504 '4
         Output_4 = 0
         LCDOut $fe,$c0,"Output-4: ON"
         GoTo Command_OK
      case 34049,1281 'a,A
         Output_1 = 0  : pause 1
         Output_2 = 0  : pause 1
         Output_3 = 0  : pause 1
         Output_4 = 0  : pause 1
         LCDOut $fe,$c0,"All Outputs: ON"
         GoTo Command_OK
      case else
         goto Wrong_ONcmd
   end select

Outputs_OFF:
   select case SDin
      case 50432 '1
         Output_1 = 1
         LCDOut $fe,$c0,"Output-1: OFF"
         GoTo Command_OK
      case 51456 '2
         Output_2 = 1
         LCDOut $fe,$c0,"Output-2: OFF"
         GoTo Command_OK
      case 52480 '3
         Output_3 = 1
         LCDOut $fe,$c0,"Output-3: OFF"
         GoTo Command_OK
      case 53504 '4
         Output_4 = 1
         LCDOut $fe,$c0,"Output-4: OFF"
         GoTo Command_OK
      case 34049,1281 'a,A
         Output_1 = 1  : pause 1
         Output_2 = 1  : pause 1
         Output_3 = 1  : pause 1
         Output_4 = 1  : pause 1
         LCDOut $fe,$c0,"All Outputs: OFF"
         GoTo Command_OK
      case else
         goto Wrong_OFFcmd
   end select
 
Command_OK:
   Pause 1000
goto Delete_SMS

Wrong_NR:
   LCDOut $fe,$c0,"Wrong Phone-NR."
goto Delete_SMS

Wrong_ID:
   LCDOut $fe,$c0,"Wrong ID."
goto Delete_SMS


Wrong_ONcmd:
   LCDOut $fe,$c0,"Wrong ON Cmd."
goto Delete_SMS

Wrong_OFFcmd:
   LCDOut $fe,$c0,"Wrong OFF Cmd."

Delete_SMS:
   Pause 1000
   LCDOut $fe,$c0,"Deleting SMS MSG"
   Pause 1000
   SerOut2 rs232t,Baud,["AT+CMGD=4",13]
   SerIn2 rs232r,Baud,1000,No_Resp,[wait("OK")]
   LCDOut $fe,$c0,"MSG. Deleted    "
return

end


Posted on: January 22, 2008, 01:58:25 13:58 - Automerged

any help please!!!!I want do thise project using nokia 6210
Logged
o_cientista
Newbie
*
Offline Offline

Posts: 9

Thank You
-Given: 1
-Receive: 4


« Reply #21 on: February 07, 2008, 03:41:29 15:41 »

SEE THIS PROGRAM. MONITOR IS ONE SENSOR AND A ENVIA SMS CASE IS OPEN THE SENSOR. In contrast YOU CAN DESLIGA The SIRENE ENVIANDO THIS SMS "S0" OR POWER ON \ POWER OF TWO RELES USING SMS
L1 = POWER ON RELE1
D1 = POWER OF RELE1
L2 = POWER ON RELE2
D2 = POWER OF RELE2
SO YOU HAVE TO SEND "L1" EG POIS PROGRAM TEST MESSAGE IN THE SIZE OF TYPE CARACTER
HAVE THE PROGRAM CODIFICADOR SMS, PINOUT MORE ROUND OF CABLE PHONE.

'*********************************************************************
' COMPILADOR USA PICBASIC IN PRO AND MC The PIC16F628 LCD 16X2
' MOBILE TESTEDO USED IN A60 SIEMENS C55

ASM DEVICE WDT_OFF&PWRT_ON&MCLR_OFF&BOD_OFF&LVP_OFF ENDASM
DEFINE OSC 20
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 3
'************************ Set-pin I / O **********************
TX VAR PORTB.2
RX VAR PORTB.1
Sensor_1 VAR PORTA.3
Sensor_2 VAR PORTA.4
SAIDA_1 VAR PORTA.1
SAIDA_2 VAR PORTA.0
SIRENE VAR PORTA.2
'************************ Variables of the memory Ram***************
CONT_S1 VAR BIT
SMS VAR BYTE
F_S VAR BYTE[12]
BF VAR BYTE[54]
'**************************** Constants ****************************
Baud CON 32 '188=4800,8,N,1 | 84=9600,8,N,1 | 32=19200,8,N,1
ASPAS CON 34
'******************** Configuarcao the pin I / O ****************
CMCON = 7
TRISA = %11000
PORTA = 0
'******************** Screen presentation************************
LCDOut $fe,1,"<<<Alarme GSM>>>",$fe,$c0,"de: Jesus Aguiar"
Pause 3000
'****************** Inicialiaza the phone***************************
INICIO:
sirene=1
pause 500
sirene=0
pause 500
sirene=1
pause 500
sirene=0
pause 500
LCDOut $fe,1,"Alarme Desligado"
'***************** Routine primary*******************************
loop:
if sensor_2 = 0 then goto main
goto loop


MAIN:
'*********************************************************************
' Pega numeros de agenda e grava na variavel:
'F_S sao numeros para mensagem SMS sao gravados na agenda de seguinte forma
'ex. numero cel. 555581234568 deve ser gravado na agenda de seguite forma 555518325486 o primeiro 55 = DDI e o segundo 55 = DDD
'invertendo as dezena.
'+CPBR: 1 o numero um e aposicao na agenda.
'*********************************************************************
SerOut2 TX,Baud,["AT+CNMI=1,1,0,0,1",13]
SerIn2 RX,Baud,1500,CEL_ERRO,[wait("OK")]
SerOut2 TX,Baud,["AT+CPBR=1",13]
SerIn2 RX,Baud,1500,CEL_ERRO,[wait("+CPBR: 1,",ASPAS),STR F_S\12]

CONT_S1=1
Pause 2000
sirene=1
pause 500
sirene=0
pause 500
ligado:
LCDOut $fe,1,"Alarme Ligado.",$fe,$c0,"Fone",STR F_S\12
MONITOR:
IF (Sensor_1 = 1)AND (CONT_S1=1) Then
SIRENE=1
CONT_S1=0
GoSub ENVIA_SMS
EndIF
IF (Sensor_2 = 0) Then goto inicio
GoSub AGUARDA_SMS
GoTo MONITOR

'********** mensagem de erro da inicializacao do celular *************
CEL_ERRO:
LCDOut $fe,1,"CMD sem resposta",$fe,$c0,"Verif. o Celular"
GoTo INICIO

'********** Envia mensagem SMS *************************************
'*** Envia mensagem O ALARME DISPAROU = 4F50901994368B2062720A0D4A9F55
ENVIA_SMS:
LCDOut $fe,1,"Enviando SMS...."
SerOut2 TX,Baud,["AT+CMGS=29",13]
SerIn2 RX,Baud,500,NAO_RESP,[wait(">")]
SEROUT2 TX,BAUD, ["0011000C91",STR F_S\12,"0000AA114F50901994368B2062720A0D4A9F55",26]
SerIn2 RX,Baud,5000,NAO_RESP,[wait("OK")]
LCDOut $fe,$c0,"Mensagem env. OK"
Pause 5000
GoTo ligado
Return
'******** MENSAGEM COMANDO OK = C36733E8243E41CF25
ENVIA_SMS_OK:
LCDOut $fe,1,"Enviando SMS...."
PAUSE 5000
SerOut2 TX,Baud,["AT+CMGS=23",13]
SerIn2 RX,Baud,500,DELETA,[wait(">")]
SerOut2 TX,Baud,["0011000C91",STR F_S\12,"0000AA0AC36733E8243E41CF25",26]
SerIn2 RX,Baud,5000,DELETA,[wait("OK")]
LCDOut $fe,$c0,"Mensagem env. OK"
Pause 5000
RETURN

NAO_RESP:
LCDOut $fe,$c0,"CMD sem resposta"
Pause 5000
GoTo MAIN


'***********Deletes SMS message received. ************************
DELETA:
SerOut2 TX,Baud,["AT+CMGD=",STR SMS[6],13]
SerIn2 RX,Baud,2000,NAO_RESP,[wait("OK")]
LCDOut $fe,1,"SMS ",SMS[6]," Deletada."
Pause 5000
GOTO ligado
Return


'******** Receives and treats SMS received***********************
AGUARDA_SMS:
SerIn2 RX,Baud,500,MONITOR,[wait("+CMTI:"),STR SMS\8]
pause 1000
if (sms[2]="M") then serout2 tx,baud,["AT+CPMS=",ASPAS,"ME",ASPAS,13]
PAUSE 2000
'***** lIGA O RELE 1 MENSAGEM "L1" ********************************

SerOut2 TX,Baud,["AT+CMGR=",STR SMS[6],13]
SerIn2 RX,Baud,2500,MONITOR,[wait("0791"),STR BF\54]
IF (BF[48]="0") AND (BF[49]="2") AND (BF[50]="C") AND (BF[51]="C") AND (BF[52]="1") AND (BF[53]="8") Then
SAIDA_1=1
GoSub ENVIA_SMS_OK
GoSub DELETA
EndIF
'*********** DESLIGA The RELE 1 MESSAGE "D1"**********************
IF (BF[48]="0") AND (BF[49]="2") AND (BF[50]="C") AND (BF[51]="4") AND (BF[52]="1") AND (BF[53]="8") Then
SAIDA_1=0
GoSub ENVIA_SMS_OK
GoSub DELETA
EndIF
'***** lIGA O RELE 2 MENSAGEM "L2" **********************************
IF (BF[48]="0") AND (BF[49]="2") AND (BF[50]="4") AND (BF[51]="C") AND (BF[52]="1") AND (BF[53]="9") Then
SAIDA_2=1
GoSub ENVIA_SMS_OK
GoSub DELETA
EndIF
'***********POWER OF O RELE 2 MENSAGEM "D2" *************************
IF (BF[48]="0") AND (BF[49]="2") AND (BF[50]="4") AND (BF[51]="4") AND (BF[52]="1") AND (BF[53]="9") Then
SAIDA_2=0
GoSub ENVIA_SMS_OK
GoSub DELETA
EndIF
'*********** DESLIGA The SIRENE RELE OF MESSAGE "S0" *****************
IF (BF[48]="0") AND (BF[49]="2") AND (BF[50]="5") AND (BF[51]="3") AND (BF[52]="1") AND (BF[53]="8") Then
SIRENE=0
GoSub ENVIA_SMS_OK
GoSub DELETA
EndIF
Return

End
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC