FONA Acessing AT command from Arduino

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
adonise
 
Posts: 35
Joined: Fri Aug 01, 2014 1:12 am

FONA Acessing AT command from Arduino

Post by adonise »

Hi,

I am working on a project that includes FONA, Arduino Mini Pro 3.3V, 128x32 i2c Oled and custom keypad.

I was able to get all working, run the sample test and I had problems opening the tiny web page in the fona_test, so I wanted to access the AT command of the SIM800L to debug and get access to functionalists that may not be available in FONA library yet. I tried the tunnel option and sent basic AT command from arduino's serial and did not get anything back.

Can you please explain how you write AT commands and read response using the fona library?
And any feedback or confirmation of anyone able to enable gprs and retrieve content?

Thanks -- Adonis

User avatar
adonise
 
Posts: 35
Joined: Fri Aug 01, 2014 1:12 am

Re: FONA Acessing AT command from Arduino

Post by adonise »

I explored the FONA .cpp and .h files and made some changes and wanted to share them with anyone who it trying this.

First I enabled a debug option already available in FONA library.

in Adafruit_FONA.h on line 26 uncomment #define ADAFRUIT_FONA_DEBUG.
This will show you the AT commands that are being executed and their response.

Now to execute my own AT commands. I moved the following functions from private to public section (also in .h file)

Code: Select all

 boolean sendCheckReply(char *send, char *reply, uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS);
  boolean sendCheckReply(const __FlashStringHelper *send, const __FlashStringHelper *reply, uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS);
  boolean sendCheckReply(const __FlashStringHelper *prefix, char *suffix, const __FlashStringHelper *reply, uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS);
  boolean sendCheckReply(const __FlashStringHelper *prefix, int32_t suffix, const __FlashStringHelper *reply, uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS);
  boolean sendCheckReply(const __FlashStringHelper *prefix, int32_t suffix, int32_t suffix2, const __FlashStringHelper *reply, uint16_t timeout = FONA_DEFAULT_TIMEOUT_MS);
Then in your Arduino sketch you can type something like this

Code: Select all

fona.sendCheckReply(F("AT+CREG?"), F("OK"), 10000);
In serial output you will be able to see this type of output

---> AT+CREG?
.<--- +CREG: 0,1

sendCheckReply() returns true/false, so if you want to test for specific response simply use it in an if statement

Code: Select all

 if (! fona.sendCheckReply(F("ATI"), F("OK"), 10000)) {
 		Serial.println(F("ATI NOT OK"));
 }

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: FONA Acessing AT command from Arduino

Post by adafruit_support_mike »

Thanks for posting the follow-up!

User avatar
elvis
 
Posts: 25
Joined: Sat Apr 27, 2013 6:47 am

Re: FONA Acessing AT command from Arduino

Post by elvis »

This is a very useful function -- may I suggest it be included this way in future iterations of the library?

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”