Quantcast
Viewing all articles
Browse latest Browse all 20608

BASCOM-AVR : SIM800L GPRS GSM Module : REPLY

Hello everyone! Where's wrong with this program, I tried more than once, but does not work [code:1:b19498dc7f] $regfile = "m8def.dat" $crystal = 3686400 $baud = 9600 $hwstack = 64 $swstack = 64 $framesize = 64 Config Portb.0 = Output Config Portb.1 = Output Config Portb.2 = Output Config Portb.3 = Output Config Portb.4 = Output Config Portb.5 = Output Declare Sub Getline Declare Sub Send_sms Declare Sub Sms_check Relay1 Alias Portb.5 Relay2 Alias Portb.4 Relay3 Alias Portb.3 Relay4 Alias Portb.2 Rled Alias Portb.0 Gled Alias Portb.1 ’#################################### Dim Status1 As Eram Byte At 5 Dim Status2 As Eram Byte At 6 Dim Status3 As Eram Byte At 7 Dim Status4 As Eram Byte At 8 Dim Number As Eram String * 13 At 10 '------------ Variables and constants for GSM --------------------------------- ------ Dim Num As String * 80 Dim Msg As String * 160 Dim Inmsg As String * 160 Dim Gstmp As Byte Dim Ar(10) As String * 20 Dim Sender As String * 25 Dim Engine As Byte Dim Alarms As Byte Dim Icnt As Byte Dim A_armed As Byte Dim Gps As Byte Dim Stmp As Byte Dim Pass_stored As String * 13 'Print Pass_stored Relay1 = 0 Relay2 = 0 Relay3 = 0 Relay4 = 0 Pass_stored = Number Gps = Status1 If Gps = 0 Then Relay1 = 0 Else Relay1 = 1 End If Gps = Status2 If Gps = 0 Then Relay2 = 0 Else Relay2 = 1 End If Gps = Status3 If Gps = 0 Then Relay3 = 0 Else Relay3 = 1 End If Gps = Status4 If Gps = 0 Then Relay4 = 0 Else Relay4 = 1 End If Wait 1 Rled = 1 Gled = 0 Wait 20 ' give some time for gsm modem ' give some time for gsm modem Print "AT" Wait 2 Print "AT+CMGD=1" Wait 2 Print "AT+CREG?" Wait 2 Print "ATE0" Wait 2 Print "AT+CNMI=1,1,0,0,0" 'new message indication off Wait 2 'Third command TEXT MODE Print "AT+CMGF=1" Wait 2 'Print #2 , "AT+CSQ" 'signal strength 'Wait 2 Rled = 0 Gled = 1 Do Print "AT" Wait 2 Print "AT+CMGF=1" ' Change to text mode Wait 2 Print "AT+CMGR=1" ' get the message Getline If Inmsg <> "OK" Then Rled = 1 Gled = 1 Num = Inmsg Getline Gps = Split(num , Ar(1) , ",") Num = Ar(2) Gps = Len(num) Gps = Gps - 2 Num = Mid(num , 2 , Gps) Inmsg = Lcase(inmsg) ' Print Num ; "Msg:" ; Inmsg If Inmsg = "microcontroller" Then 'other numbers Pass_stored = Num Number = Pass_stored Msg = "Password Accepted" Send_sms Elseif Num = Pass_stored Then If Inmsg = "light on" Then Relay1 = 1 Status1 = 1 Num = Pass_stored Msg = "Light Switched ON" Send_sms Elseif Inmsg = "light off" Then Relay1 = 0 Status1 = 0 Num = Pass_stored Msg = "Light Switched OFF" Send_sms Elseif Inmsg = "fan on" Then Relay2 = 1 Status2 = 1 Num = Pass_stored Msg = "Fan Switched ON" Send_sms Elseif Inmsg = "fan off" Then Relay2 = 0 Status2 = 0 Num = Pass_stored Msg = "Fan Switched OFF" Send_sms Elseif Inmsg = "ac on" Then Relay3 = 1 Status3 = 1 Num = Pass_stored Msg = "AC Switched ON" Send_sms Elseif Inmsg = "ac off" Then Relay3 = 0 Status3 = 0 Num = Pass_stored Msg = "AC Switched OFF" Send_sms Elseif Inmsg = "tv on" Then Relay4 = 1 Status4 = 1 Num = Pass_stored Msg = "AC Switched ON" Send_sms Elseif Inmsg = "tv off" Then Relay4 = 0 Status4 = 0 Num = Pass_stored Msg = "AC Switched OFF" Send_sms Else Num = Pass_stored Msg = "Invalid Command.." Send_sms End If End If Wait 2 Print "AT+CMGD=1" Wait 3 Rled = 0 Gled = 1 End If Gled = 0 Waitms 1 Gled = 1 Wait 8 Gled = 0 Waitms 1 Gled = 1 Loop '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ' SEND SMS '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Sub Send_sms Rled = 1 Wait 3 Print "AT+CMGS=" ; Chr(34) ; Num ; Chr(34) 'send sms Waitms 200 Print Msg ; Chr(26) Wait 5 Print "AT" Wait 2 Rled = 0 End Sub '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ' Read gsm modem '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Sub Getline Inmsg = "" Do Gps = Inkey() If Gps > 0 Then Select Case Gps Case 13 : If Inmsg <> "" Then Exit Do ' if we have received something Case 10 : If Inmsg <> "" Then Exit Do ' if we have received something Case Else Inmsg = Inmsg + Chr(gps) ' build string End Select End If Loop End Sub End [/code:1:b19498dc7f]

Viewing all articles
Browse latest Browse all 20608

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>