Those who worked with Arduino and built any GPRS or IoT project, are familiar with Adafruit_FONA Library. This library is handy for the Arduino platform to build any GSM, GPRS, or related project. But unfortunately, this library doesn’t work with ESP32 directly. And I had awful experiences with this issue. Here is my solution, which you can follow.

Disclaimer: Electricity is always dangerous. Proper skill is required to work with electricity. Do work at your own risk. The author will not be responsible for any misuse or harmful act or any mistake you make. The contents of this website are unique and copyright-protected. Kindly don’t do any nonsensical act of copying and claiming it as yours. Most of the articles published here are kept open-source to help you. Take the knowledge for free and use it, but if you are interested you can buy the ready resources offered here. If you need any help or guidance feel free to comment below, the author will try to help you. Also, there can be affiliation links in the article. Which will not affect you anyway, but allows the author with some commission. So please don’t take it otherwise. Thanks.

Table of Contents


Configure your IDE for ESP32:

Adafruit_FONA library is very useful and there are many features included in it. But this works fine with Arduino UNO, Mega, etc., not with ESP32 ICs. So, if you really want to use this library, then you must configure your ESP in the right way.

First, select the right ESP board. And if you do not have the board installed, then copy this link “” into preference and search for the ESP32 board and install the ESP board.

After installation, select the right board. In my case, it was the ESP32 wrover module.

Adafruit_FONA Library with ESP32

Start code:

Now, use the following code:

//Easy wash data logging part with the board named 'ESP32 wrover module'

#include"Arduino.h" // as you are using arduino libraries, so its important to include
#include "Adafruit_FONA.h"

//if you use Software Serial
#include <SoftwareSerial.h>
SoftwareSerial fonaSS;
SoftwareSerial *fonaSerial = &fonaSS;

//if you want to use hardware serial
//HardwareSerial fonaSS(1);
//HardwareSerial *fonaSerial = &fonaSS;

#define FONA_RST 32

char replybuffer[255];
Adafruit_FONA fona = Adafruit_FONA(~FONA_RST);

//for 3G
//Adafruit_FONA_3G fona = Adafruit_FONA_3G(FONA_RST);

void setup()
  Serial.println("Hano?");//as my kid called hello...
  Serial.println(F("Initializing GSM"));
  fonaSerial->begin(4800, SWSERIAL_8N1, 33, 25, false);//for hardware serial use: fonaSerial->begin(115200,SERIAL_8N1,16,17, false);
  if (! fona.begin(*fonaSerial))
    Serial.println(F("Couldn't find FONA"));
    while (1);
  Serial.println(F("FONA is OK"));
  fonaSerial->print("AT+CNMI=2,1\r\n");  //set up the FONA to send a +CMTI notification when an SMS is received
  Serial.println("FONA Ready");


void loop()


int net_status;
uint16_t statuscode;

void GSM_ON()
  // make it slow so its easy to read!
  fonaSerial->begin(4800, SWSERIAL_8N1, 33, 25, false);
  if (! fona.begin(*fonaSerial))
    Serial.println(F("Couldn't find FONA"));
    digitalWrite(FONA_RST, LOW); delay(100);
    digitalWrite(FONA_RST, HIGH); delay(300);
    goto again;
    while (1);
  Serial.println(F("FONA is OK"));
  net_status = fona.getNetworkStatus();
  while (net_status != 1)
    net_status = fona.getNetworkStatus();
  Serial.println(F("Registered ok"));


Here, the only important and different thing is the

“fonaSerial->begin(4800, SWSERIAL_8N1, 33, 25, false);” line. Unlike Arduino UNO or mega, we need to configure the serial port in detail like this for ESP32.

Now, you can use your fona library as you need. If anywhere, there is any initialization, you need to replace it with the detail one. That’s it.

My result:

My result was satisfactory and worked immediately.

Adafruit_FONA Library with ESP32

Adafruit_FONA Library with ESP32

After this, I used the code for GPRS data posting which worked fine. Just like Arduino. No restarting or failure. I think you can use it now for your project.


I had been having trouble configuring the ESP32 for fona library and ESP was restarting. Now it’s all solved and works smoothly. I Hope, your’s one will also work fine. See you in the next article, thanks!

You can read my other articles here:

For Professional Designs or Help:



Mithun K. Das; B. Sc. in EEE from KUET; Head of R&D @ M's Lab Engineering Solution. "This is my personal blog. I post articles on different subjects related to electronics in the easiest way so that everything becomes easy for all, especially for beginners. If you have any questions, feel free to ask through the contact us page." Thanks.


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

%d bloggers like this: