Seeli Powlin
Newbie level 6
Hi ,
Can any one show me a small example regarding how to use AT commands inside the main() ?
Can any one show me a small example regarding how to use AT commands inside the main() ?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
void main(){
char command1[]="\r\nAT+CMGF=1\r\n";
char command2[]="AT+CMGS=\"phonenumber\"\r";
char command3[]="https://maps.google.com/maps?q=";
Delay10KTCYx(200);
puts1USART(command1);
Delay10KTCYx(200);
puts1USART(command2);
Delay10KTCYx(200);
puts1USART(command3);
}
This is my code in MPLABX C18 Compiler.
The command1 has the function to put the GSM module in mode to send SMS, after that just send another command along with the number you want to send the message then just write your message
hope this helps.:wink:
Code:void main(){ char command1[]="\r\nAT+CMGF=1\r\n"; char command2[]="AT+CMGS=\"phonenumber\"\r"; char command3[]="https://maps.google.com/maps?q="; Delay10KTCYx(200); puts1USART(command1); Delay10KTCYx(200); puts1USART(command2); Delay10KTCYx(200); puts1USART(command3); }
If you want to make a confirmation of OK, you need a UART for receiving char and store in a variable. After that u compare with another variable that has the expected data.
Or you can search for characters to receive, eg 'O' or 'K', or 'O' and 'K', so you do not need to use the memory space to store variables to compare.
This code I showed you, simply sends the command and waits a delay time to send the next. It worked for my tests. But do it the way u think this is safer for a stand-alone application.