Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Regarding how to use AT command

Status
Not open for further replies.

Seeli Powlin

Newbie level 6
Joined
May 7, 2014
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
94
Hi ,
Can any one show me a small example regarding how to use AT commands inside the main() ?
 

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);
}
 
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);
}



Hi,
Thank you for your reply.

For suppose, If i use some AT command, it should respond like OK.
For example:
1. Send command AT+GMR<cr>
2. Wait for response OK


Where this OK gets stored?
How i can check this?
Do i need to code for that OK response?
Guide me.
 

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.
 

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.

Hi,
Thank you.
 

Hi,
Thank you.
I got your points and wrote codes.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top