SIM7600 controlling LED using ESP32

SIM7600 comes in different version. The one I am using is SIM7600G (Global) that can work with many bands. I checked here in Australia with two different providers (Telstra and Vodafone). Both sim cards worked fine.

The pin outs are quite simple. Connect four pins VCC,GND,UART(RX) and UART(TX), it will just work. This module includes proper power regulator, so we can connect 5V to the V pin. Also the TX/RX serial communication already includes necessary 3.3V level shifter. So we can connect to 3.3V ESP or STM microcontroller directly.

AT command manual, Schematic and Datasheet can be found in the following links.

Items can be purchased from I bought my items from

Wiring diagram



Arduino Fona Library

Click Sketch → Include Library → Manage Libraries...

Type Adafruit Fona in the Filter your search area

Click Install Adafruit Fona Library

Before uploading please click followings and type/select

File → Preferences → Type in Additional Boards Manager URLs

Tools → Board → Boards Manager → Type esp32 and click install button next to esp32 by Espressif Systems

Tools → Board → ESP32 Arduino → ESP32 Wrover Module

Tools → Port (Select the correct port)

Arduino code

// Arduino Code
#include "Adafruit_FONA.h"
HardwareSerial SerialAT(1);

const int RELAY_PIN = 15;
const int FONA_RST = 4;

char replybuffer[255];
uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout = 0);
String smsString = "";
char fonaNotificationBuffer[64];          //for notifications from the FONA
char smsBuffer[250];

HardwareSerial *fonaSerial = &SerialAT;

Adafruit_FONA_3G fona = Adafruit_FONA_3G(FONA_RST);

void setup() 
  digitalWrite(RELAY_PIN, LOW);
  Serial.println(F("FONA SMS caller ID test"));
  Serial.println(F("Initializing....(May take 3 seconds)"));

  fonaSerial->begin(115200,SERIAL_8N1,16,17, false);
  if (! fona.begin(*fonaSerial))
    Serial.println(F("Couldn't find FONA"));
  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() 
  char* bufPtr = fonaNotificationBuffer;    //handy buffer pointer
  if (fona.available())      //any data available from the FONA?
    int slot = 0;            //this will be the slot number of the SMS
    int charCount = 0;
    //Read the notification into fonaInBuffer
      *bufPtr =;
    } while ((*bufPtr++ != '\n') && (fona.available()) && (++charCount < (sizeof(fonaNotificationBuffer)-1)));

    //Add a terminal NULL to the notification string
    *bufPtr = 0;

    //Scan the notification string for an SMS received notification.
    //  If it's an SMS message, we'll get the slot number in 'slot'
    if (1 == sscanf(fonaNotificationBuffer, "+CMTI: " FONA_PREF_SMS_STORAGE ",%d", &slot)) 
      Serial.print("slot: "); Serial.println(slot);

      char callerIDbuffer[32];  //we'll store the SMS sender number in here

      // Retrieve SMS sender address/phone number.
      if (! fona.getSMSSender(slot, callerIDbuffer, 31)) 
        Serial.println("Didn't find SMS message in slot!");
      Serial.print(F("FROM: ")); Serial.println(callerIDbuffer);

      // Retrieve SMS value.
      uint16_t smslen;
      if (fona.readSMS(slot, smsBuffer, 250, &smslen)) // pass in buffer and max len!
        smsString = String(smsBuffer);

      if (smsString == "On")  //Change "On" to something secret like "On$@8765"
        digitalWrite(RELAY_PIN, HIGH);
        Serial.println("LED is ON.");
        fona.sendSMS(callerIDbuffer,"LED is ON." );
      else if(smsString == "Off") //Change "On" to something secret like "Off&%4235"
        digitalWrite(RELAY_PIN, LOW);
        Serial.println("LED is OFF.");
        fona.sendSMS(callerIDbuffer, "LED is OFF.");
      if (fona.deleteSMS(slot)) {
      } else {
        Serial.print(F("Couldn't delete SMS in slot ")); Serial.println(slot);
// End of Arduino Code