Hi everyone, I need help about my project on the interfacing part of the GSM to the microcontroller(pic16f877), I need to control some switching devices(outlets using relays) to turn them on and off using text message(sms) via GSM. I am using mikrobasic as my programming language, and as a temporary replacement for the GSM I am using the mikrobasic usart terminal for testing some codes. Currently I am trying to figure out how to use the usart_data_ready command and I tried the code below. Can anyone kindly share with me some codes regarding this project and any advice or clarifications with the code below. Thanks in advance for the help
program readstring
dim txt, delim as char[20]
trisA= %000000
main:
porta = %000000
USART_init(9600)
delim = "ON"
while true
if Usart_Data_Ready = 1 then
Usart_Read_Text(txt, delim) ' read text until "OK" is received
Usart_Write_Text(txt) ' write back what has been read
delay_ms(400)
porta = %011011
else
'if not equal to ON then reply "invalidkeyword" the GSM will send a 'message invalid
end if
wend
end.
first make some key words (for toggle on / off particular pins)
then make ur hex do that exactly ____when u got that from your code input
___first delay some time ___ then do switch ur relay___then again start loop____
this is same for every module ;;gsm,rxtx,i2c;ir;bluetooth etc
in any lang. like c c++ basic whatever,,who cares
practice this with ur pc serial cable rx tx rs232 first
go further step by step,,then u get what u deserve by ur effort
peace
Hi thanks for the reply, but still I dont know how to write the codes that would exactly do as you have said. I have some ideas but im still working on it. I really need it to figure it out asap so if you or anyone have any sample codes for it or any related to it can you please share it to me. thanks
Hi
Firstly u should skip u controller and use hyperterminal to figureout how to
send sms via gsm modem , u should be familiar with AT commands
u can start with simple AT commands
during this debugging you can use Hextool6 program to monitor the transactions between PC and gsm modem
Once u able to send SMS just program the ucontroller to act like Hyperterminal
I am already doing what you have said khabbash, I managed to test the GSM sending process using the hyperterminal properly and I do have a reference already for the AT commands. Now my problem is how will the microcontroller understand if the sent SMS is correct. I prefer to use proton or mikrobasic for the codes.
Ex.
I sent an sms "ON"
then the microcontroller will check the sms if it is correct and trigger some ports to be turned ON or else if the message was wrong the GSM will send back an SMS that it is "Invalid".