Getting Started with LILYGO TTGO T-A7670G ESP32 (4G, GPRS, and GPS)

Get started with the ESP32 and the T-A7670G 4G/GPS/GPRS module. Throughout this guide, we’ll use the LILYGO TTGO T-A7670G ESP32 board that combines the ESP32 chip, the A7670G (or A7670E, A7670SA) module, SIM card slot, microSD card, GPS, battery, and charger on the same board. Besides Wi-Fi and Bluetooth, you can communicate with this ESP32 board using SMS. You can also connect it to the internet using your SIM card data plan and get GPS location.

Getting Started with LILYGO TTGO T-A7670G ESP32 4G GPRS and GPS

Compatibility

You must select the correct board version for your region.

– A7670G =Global (we recommend this version with GPS)

– A7670E = Europe / Southeast Asia / South America

– A7670SA = South America / New Zealand / Australia

You can buy your LILYGO TTGO T-A7670G board here

Introducing the LILYGO TTGO T-A7670G ESP32 (with GPS)

The LILYGO TTGO T-A7670G is an ESP32 development board with a A7670G / A7670E / A7670SA module. This adds LTE-FDD, GSM, and GPRS to your board. This means that with this board you can send SMS, and connect it to the internet using a SIM card data plan. If you buy the option with GPS, you can get location and time. You can find more information on the official LilyGO-T-A76XX GitHub repository.

ESP32 LILYGO TTGO T-A7670G Dev Board overview

Besides the A7670G module, the board also comes with some interesting features like a battery holder for an 18650 battery, a battery charging circuit where you can connect solar panels to recharge the battery, and a microSD card slot that can be useful for data logging projects or to save configuration settings.

Here’s a summary of the LILYGO TTGO T-A7670G ESP32 (with GPS) board features:

  • Supply voltage: 3.3V DC or 5V DC
  • ESP32 chip (WROVER-B Module) (240MHz dual-core processor)
  • Flash memory: 4MB
  • PSRAM: 8MB
  • Built-in Wi-Fi
  • Built-in Bluetooth
  • USB to serial converter: CP2104 or CH9102 (drivers)
  • Built-in SIMCOM A7670G module
  • Built-in nano SIM card slot
  • Built-in SIM antenna slot
  • Available with or without GPS
  • Built-in Li-ion/Li-Po battery charging circuit:
    • Solar energy charging interface for 4.4-6V solar panel
    • Built-in 1x 18650 battery holder
    • Built-in solar panel connector 2p JST-PH
  • Built-in Micro SD card slot
  • On/off battery switch
  • Reset and Boot buttons
  • Status LEDs

Here’s a quick overview of the board:

ESP32 LILYGO TTGO T A7670G Dev Board Overview highlights

To use the capabilities of this board you need to have a nano SIM card with a data plan and a USB-C cable to upload code to the board. The package comes with an external antenna for LTE connection.

ESP32 LILYGO TTGO T-A7670G Dev Board with 4G full band LTE antenna

If you buy the LILYGO TTGO T-A7670G board with GPS, it will also come with a GPS antenna that you can connect to the board as follows:

ESP32 LILYGO TTGO T-A7670G Dev Board with GPS connected antenna

You can also connect a microSD card:

ESP32 LILYGO TTGO T-A7670G Dev Board MicroSD Card Battery Holder

Where to buy LILYGO TTGO T-A7670G ESP32?

Check the following link:

You must select the correct board version for your region.

ESP32 LILYGO TTGO T A7670G A7670E A7670SA Comparison

LILYGO TTGO T-A7670G ESP32 Pinout

The following picture show the pinout of the T-A7670G ESP32 board.

The following table shows the connections between the ESP32 and the T-A7670G chip:

T-A7670GESP32
TXGPIO 26
RXGPIO 27
POWERGPIO 4

To communicate with the microSD card, you need SPI communication protocol. These are the GPIOs used:

MicroSD Card (TF card)ESP32
MOSIGPIO 15
SCLKGPIO 14
CSGPIO 13
MISOGPIO 2

AT Commands

AT commands are used to control modems, as is the case of the T-7670G. In the case of the ESP32, you send the AT commands via serial communication protocol. Then, the modem responds back also via serial communication.

There are four types of AT commands: test; read; set; execution. You can find the complete list of AT commands for the T-7670G at the following link:

Here are some AT commands:

  • Check communication with the module: AT
  • Check if SIM card is ready: AT+CPIN?
  • Check the registration status of the device: AT+CGREG?

Libraries

As we explained previously, the ESP32 communicates with the T-7670G chip by sending AT commands via serial communication. You don’t need a library, you can simply establish a serial communication with the module and start sending AT commands.

However, it might be more practical to use a library. For example, the TinyGSM library knows which commands to send, and how to handle AT responses, and wraps that into the standard Arduino Client interface.

IMPORTANT: for this tutorial we won’t use the official TinyGSM library by vshymanskyy. We’ll be using the TinyGSM-fork by lewisxhe. If you already have the TinyGSM by vshymanskyy library installed, you must remove it to use this new fork.

Installing the TinyGSM-fork Library

The TinyGSM-fork by lewisxhe library is not available to install through the Arduino Library Manager, so you need to copy the library files to the Arduino installation Libraries folder. Alternatively, in your Arduino IDE, you can go to Sketch > Include Library > Add .zip Library and select the library that can be downloaded below.

Preparing the LILYGO T-7670G ESP32 Board

This board only supports nano SIM cards. You need a SIM card for 4G and GPRS. To use 4G and GPRS you need a SIM card with some data plan. This can be expensive in some countries, so it might be cost-prohibitive depending on how much you can get a data plan for in your country.

Where we live (Portugal), we can get a SIM card with a data plan, calls, and SMS (enough for ESP32 projects) for approximately $10. We recommend using a SIM card with a prepaid or monthly plan so that you know exactly how much you’ll spend. There are also companies specializing in SIM cards for IoT projects.

Nano SIM card vodafone

Before plugging your board to the computer, you need to follow the next steps:

1) Insert a nano SIM card;

ESP32 LILYGO TTGO T-A7670G board with SIM Card inserted

2) Connect the Full Band LTE antenna to the connection;

ESP32 LILYGO TTGO T-A7670G Dev Board connected LTE band antenna

3) In order to program your board, you must power it using the USB Type-C cable;

ESP32 LILYGO TTGO T-A7670G Board connected USB Type C cable

4) Finally, if you don’t see the COM port appearing on your computer, you need to install the CH9102 USB bridge driver: Windows or Mac OS.

APN Details

To connect your SIM card to the internet, you need to have your phone plan provider’s APN details. You need the domain name, username, and password.

In my case, I’m using Vodafone Portugal. If you search for GPRS APN settings followed by your phone plan provider name, (in my case its: “GPRS APN Vodafone Portugal”), you can usually find in a forum or in their website all the information that you need.

It might be a bit tricky to find the details if you don’t use a well-known provider. So, you might need to contact them directly.

Programming the LILYGO TTGO T-A7670G ESP32

This first sketch that you’ll run on your board is good to check all the connections. It will start the modem, connect to the APN network, and make an HTTPS GET request to a website.

  1. Copy the following code to your Arduino IDE:
/*
  Rui Santos & Sara Santos - Random Nerd Tutorials
  Complete project details at https://RandomNerdTutorials.com/lilygo-ttgo-t-a7670g-a7670e-a7670sa-esp32/
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.  
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/
// set SIM card pin, if any
#define SIM_PIN ""

// It depends on the operator whether you need to set up an APN or not. 
// With some operators if you do not set up an APN, the connection will be rejected when registering for the network.
#define NETWORK_APN "REPLACE_WITH_YOUR_NETWORK_APN"

// If the status code 715 is returned, you might need to update your SIMCOM firmware please see here: https://github.com/Xinyuan-LilyGO/LilyGO-T-A76XX/issues/117
// How to update the firmware: https://github.com/Xinyuan-LilyGO/LilyGO-T-A76XX/blob/main/docs/update_fw.md
// Some websites block the ESP32 connection, so it might return an error.
// The githubusercontent.com URL defined below has been tested and it returns the proper HTTPS GET request
const char *request_url[] = {
  "https://gist.githubusercontent.com/RuiSantosdotme/7db8537cef1c84277c268c76a58d07ff/raw/d3fe4cd6eff1ed43e6dbd1883ab7eba8414e2406/gistfile1.txt"
};

#define TINY_GSM_RX_BUFFER 1024 // Set RX buffer to 1Kb

#define LILYGO_T_A7670

#if defined(LILYGO_T_A7670)
  #define MODEM_BAUDRATE                      (115200)
  #define MODEM_DTR_PIN                       (25)
  #define MODEM_TX_PIN                        (26)
  #define MODEM_RX_PIN                        (27)
  // The modem boot pin needs to follow the startup sequence.
  #define BOARD_PWRKEY_PIN                    (4)
  #define BOARD_ADC_PIN                       (35)
  // The modem power switch must be set to HIGH for the modem to supply power.
  #define BOARD_POWERON_PIN                   (12)
  #define MODEM_RING_PIN                      (33)
  #define MODEM_RESET_PIN                     (5)
  #define BOARD_MISO_PIN                      (2)
  #define BOARD_MOSI_PIN                      (15)
  #define BOARD_SCK_PIN                       (14)
  #define BOARD_SD_CS_PIN                     (13)
  #define BOARD_BAT_ADC_PIN                   (35)
  #define MODEM_RESET_LEVEL                   HIGH
  #define SerialAT                            Serial1
  #define MODEM_GPS_ENABLE_GPIO               (-1)
  #define MODEM_GPS_ENABLE_LEVEL              (-1)
  #ifndef TINY_GSM_MODEM_A7670
    #define TINY_GSM_MODEM_A7670
  #endif
#endif

// YOU MUST USE THE TinyGSM-fork LIBRARY BY lewisxhe - https://github.com/lewisxhe/TinyGSM-fork
// If you already have the vshymanskyy/TinyGSM library installed, you must remove it and use the TinyGSM-fork version by lewisxhe mentioned above
#include <TinyGsmClient.h>

// See all AT commands, if wanted
//#define DUMP_AT_COMMANDS
#ifdef DUMP_AT_COMMANDS  // if enabled it requires the streamDebugger lib
  #include <StreamDebugger.h>
  StreamDebugger debugger(SerialAT, Serial);
  TinyGsm modem(debugger);
#else
  TinyGsm modem(SerialAT);
#endif

void HTTPSGetRequest() {
  for (int i = 0; i < sizeof(request_url) / sizeof(request_url[0]); ++i) {
    int retry = 3;
    while (retry--) {
      Serial.print("Request URL : ");
      Serial.println(request_url[i]);

      // Set GET URT
      if (!modem.https_set_url(request_url[i])) {
        Serial.print("Failed to request : "); Serial.println(request_url[i]);
        // Debug
        // modem.sendAT("+CSSLCFG=\"enableSNI\",0,1");
        // modem.waitResponse();
        delay(3000);
        continue;
      }

      // Send GET request
      int httpCode = 0;
      httpCode = modem.https_get();
      if (httpCode != 200) {
        Serial.print("HTTP get failed ! error code = ");
        Serial.println(httpCode);
        delay(3000);
        continue;
      }

      // Get HTTPS header information
      String header = modem.https_header();
      Serial.print("HTTP Header : ");
      Serial.println(header);
      delay(1000);

      // Get HTTPS response
      String body = modem.https_body();
      Serial.print("HTTP body : ");
      Serial.println(body);
      delay(3000);
      break;
    }
    Serial.println("-------------------------------------");
  }
}

void setup() {
  Serial.begin(115200);
  Serial.println("Init...");
  SerialAT.begin(115200, SERIAL_8N1, MODEM_RX_PIN, MODEM_TX_PIN);

  pinMode(BOARD_POWERON_PIN, OUTPUT);
  digitalWrite(BOARD_POWERON_PIN, HIGH);

  // Set modem reset pin, reset modem
  pinMode(MODEM_RESET_PIN, OUTPUT);
  digitalWrite(MODEM_RESET_PIN, !MODEM_RESET_LEVEL); delay(100);
  digitalWrite(MODEM_RESET_PIN, MODEM_RESET_LEVEL); delay(2600);
  digitalWrite(MODEM_RESET_PIN, !MODEM_RESET_LEVEL);

  pinMode(BOARD_PWRKEY_PIN, OUTPUT);
  digitalWrite(BOARD_PWRKEY_PIN, LOW);
  delay(100);
  digitalWrite(BOARD_PWRKEY_PIN, HIGH);
  delay(100);
  digitalWrite(BOARD_PWRKEY_PIN, LOW);

  // Check if the modem is online
  Serial.println("Start modem...");

  int retry = 0;
  while (!modem.testAT(1000)) {
    Serial.print(".");
    if (retry++ > 10) {
      digitalWrite(BOARD_PWRKEY_PIN, LOW);
      delay(100);
      digitalWrite(BOARD_PWRKEY_PIN, HIGH);
      delay(1000);
      digitalWrite(BOARD_PWRKEY_PIN, LOW);
      retry = 0;
    }
  }
  Serial.println();

  // Check if SIM card is online
  SimStatus sim = SIM_ERROR;
  while (sim != SIM_READY) {
    sim = modem.getSimStatus();
    switch (sim) {
      case SIM_READY:
        Serial.println("SIM card online");
        break;
      case SIM_LOCKED:
        Serial.println("The SIM card is locked. Please unlock the SIM card first.");
        modem.simUnlock(SIM_PIN);
        break;
      default:
        break;
    }
    delay(1000);
  }

  if (!modem.setNetworkMode(MODEM_NETWORK_AUTO)) {
    Serial.println("Set network mode failed!");
  }
  String mode = modem.getNetworkModes();
  Serial.print("Current network mode : ");
  Serial.println(mode);

#ifdef NETWORK_APN
  Serial.printf("Set network apn : %s\n", NETWORK_APN);
  modem.sendAT(GF("+CGDCONT=1,\"IP\",\""), NETWORK_APN, "\"");
  if (modem.waitResponse() != 1) {
    Serial.println("Set network apn error !");
  }
#endif

  // Check network registration status and network signal status
  int16_t sq ;
  Serial.print("Wait for the modem to register with the network.");
  RegStatus status = REG_NO_RESULT;
  while (status == REG_NO_RESULT || status == REG_SEARCHING || status == REG_UNREGISTERED) {
    status = modem.getRegistrationStatus();
    switch (status) {
      case REG_UNREGISTERED:
      case REG_SEARCHING:
        sq = modem.getSignalQuality();
        Serial.printf("[%lu] Signal Quality:%d\n", millis() / 1000, sq);
        delay(1000);
        break;
      case REG_DENIED:
        Serial.println("Network registration was rejected, please check if the APN is correct");
        return ;
      case REG_OK_HOME:
        Serial.println("Online registration successful");
        break;
      case REG_OK_ROAMING:
        Serial.println("Network registration successful, currently in roaming mode");
        break;
      default:
        Serial.printf("Registration Status:%d\n", status);
        delay(1000);
        break;
    }
  }
  Serial.println();

  Serial.printf("Registration Status:%d\n", status);
  delay(1000);

  String ueInfo;
  if (modem.getSystemInformation(ueInfo)) {
    Serial.print("Inquiring UE system information:");
    Serial.println(ueInfo);
  }

  if (!modem.setNetworkActive()) {
    Serial.println("Enable network failed!");
  }
  delay(5000);

  String ipAddress = modem.getLocalIP();
  Serial.print("Network IP:"); Serial.println(ipAddress);

  // Initialize HTTPS
  modem.https_begin();

  HTTPSGetRequest();
}

void loop() {
  // Debug AT
  if (SerialAT.available()) {
    Serial.write(SerialAT.read());
  }
  if (Serial.available()) {
    SerialAT.write(Serial.read());
  }
  delay(1);
}

#ifndef TINY_GSM_FORK_LIBRARY
  #error "The correct library was NOT found. You must install TinyGSM-fork by lewisxhe - https://github.com/lewisxhe/TinyGSM-fork - No correct definition detected, Please copy all the [lib directories](https://github.com/Xinyuan-LilyGO/LilyGO-T-A76XX/tree/main/lib) to the arduino libraries directory , See README"
#endif

View raw code

  1. Insert your SIM card pin, if you have it. In my case, I disabled the pin.
#define SIM_PIN ""
  1. Insert your network APN details on the following line:
#define NETWORK_APN "t"

For example, in my case:

#define NETWORK_APN "net2.vodafone.pt"
  1. Go to Tools > Board and select ESP32 Dev Module.
  1. Finally, upload the code to your board.
Arduino 2.0 Upload Button

Open the Serial Monitor at a baud rate of 115200. Press the on-board RST button to restart the board. Wait some time until the board connects to the network (in my case, it may take 1 to 2 minutes).

You should get something similar in the Arduino IDE Serial Monitor.

ESP32 LILYGO TTGO T-A7670G A7670E A7670SA dev board HTTPS GET Request Demonstration

How the Code Works

Let’s take a quick look at the relevant parts of code.

First, insert the SIM card pin, APN details, and desired request URL (we’re just using a sample URL from GitHub that we created to test the connection):

// set SIM card pin, if any
#define SIM_PIN ""

#define NETWORK_APN ""

const char *request_url[] = {
  "https://gist.githubusercontent.com/RuiSantosdotme/7db8537cef1c84277c268c76a58d07ff/raw/d3fe4cd6eff1ed43e6dbd1883ab7eba8414e2406/gistfile1.txt"
};

Then, you need to define the module you’re using. The library is compatible with many different modules. To use the T-A7670, include the following line (pin assignment for other T-A76XX modules):

#define LILYGO_T_A7670

Include the TinyGSM-fork library by lewisxhe:

#include <TinyGsmClient.h>

A-7670G Pinout

The following lines set the module baud rate and pinout:

#define MODEM_BAUDRATE                      (115200)
#define MODEM_DTR_PIN                       (25)
#define MODEM_TX_PIN                        (26)
#define MODEM_RX_PIN                        (27)
// The modem boot pin needs to follow the startup sequence.
#define BOARD_PWRKEY_PIN                    (4)
#define BOARD_ADC_PIN                       (35)
// The modem power switch must be set to HIGH for the modem to supply power.
#define BOARD_POWERON_PIN                   (12)
#define MODEM_RING_PIN                      (33)
#define MODEM_RESET_PIN                     (5)
#define BOARD_MISO_PIN                      (2)
#define BOARD_MOSI_PIN                      (15)
#define BOARD_SCK_PIN                       (14)
#define BOARD_SD_CS_PIN                     (13)
#define BOARD_BAT_ADC_PIN                   (35)
#define MODEM_RESET_LEVEL                   HIGH
#define SerialAT                            Serial1
#define MODEM_GPS_ENABLE_GPIO               (-1)
#define MODEM_GPS_ENABLE_LEVEL              (-1)

Serial Communication

Start the serial communication with the Serial Monitor for debugging and modem to send AT commands:

Serial.begin(115200);
Serial.println("Init...");
SerialAT.begin(115200, SERIAL_8N1, MODEM_RX_PIN, MODEM_TX_PIN);

Power the Modem

In the setup(), you always need to include the following procedure to power on and start the modem:

pinMode(BOARD_POWERON_PIN, OUTPUT);
digitalWrite(BOARD_POWERON_PIN, HIGH);

// Set modem reset pin, reset modem
pinMode(MODEM_RESET_PIN, OUTPUT);
digitalWrite(MODEM_RESET_PIN, !MODEM_RESET_LEVEL); delay(100);
digitalWrite(MODEM_RESET_PIN, MODEM_RESET_LEVEL); delay(2600);
digitalWrite(MODEM_RESET_PIN, !MODEM_RESET_LEVEL);

pinMode(BOARD_PWRKEY_PIN, OUTPUT);
digitalWrite(BOARD_PWRKEY_PIN, LOW);
delay(100);
digitalWrite(BOARD_PWRKEY_PIN, HIGH);
delay(100);
digitalWrite(BOARD_PWRKEY_PIN, LOW);

// Check if the modem is online
Serial.println("Start modem...");

Wait until the T-A7670 module starts responding to AT commands, so it means it’s running properly.

int retry = 0;
while (!modem.testAT(1000)) {
  Serial.print(".");
  if (retry++ > 10) {
    digitalWrite(BOARD_PWRKEY_PIN, LOW);
    delay(100);
    digitalWrite(BOARD_PWRKEY_PIN, HIGH);
    delay(1000);
    digitalWrite(BOARD_PWRKEY_PIN, LOW);
    retry = 0;
  }
}
Serial.println();

After, check if the SIM card is properly inserted and unlock it with the SIM_PIN if necessary.

// Check if SIM card is online
SimStatus sim = SIM_ERROR;
while (sim != SIM_READY) {
  sim = modem.getSimStatus();
  switch (sim) {
    case SIM_READY:
      Serial.println("SIM card online");
      break;
    case SIM_LOCKED:
      Serial.println("The SIM card is locked. Please unlock the SIM card first.");
      modem.simUnlock(SIM_PIN);
      break;
    default:
      break;
  }
  delay(1000);
}

Set Network Mode

Set the network mode and APN to establish an internet connection:

  if (!modem.setNetworkMode(MODEM_NETWORK_AUTO)) {
    Serial.println("Set network mode failed!");
  }
  String mode = modem.getNetworkModes();
  Serial.print("Current network mode : ");
  Serial.println(mode);

#ifdef NETWORK_APN
  Serial.printf("Set network apn : %s\n", NETWORK_APN);
  modem.sendAT(GF("+CGDCONT=1,\"IP\",\""), NETWORK_APN, "\"");
  if (modem.waitResponse() != 1) {
    Serial.println("Set network apn error !");
  }
#endif

Then, run a loop that checks for the signal quality and stops when the board has established a successful internet connection.

// Check network registration status and network signal status
int16_t sq ;
Serial.print("Wait for the modem to register with the network.");
RegStatus status = REG_NO_RESULT;
while (status == REG_NO_RESULT || status == REG_SEARCHING || status == REG_UNREGISTERED) {
  status = modem.getRegistrationStatus();
  switch (status) {
    case REG_UNREGISTERED:
    case REG_SEARCHING:
      sq = modem.getSignalQuality();
      Serial.printf("[%lu] Signal Quality:%d\n", millis() / 1000, sq);
      delay(1000);
      break;
    case REG_DENIED:
      Serial.println("Network registration was rejected, please check if the APN is correct");
      return ;
    case REG_OK_HOME:
      Serial.println("Online registration successful");
      break;
    case REG_OK_ROAMING:
      Serial.println("Network registration successful, currently in roaming mode");
      break;
    default:
      Serial.printf("Registration Status:%d\n", status);
      delay(1000);
      break;
  }
}
Serial.println();

Serial.printf("Registration Status:%d\n", status);
delay(1000);

Get Modem Info

You can run these commands to print the modem information in the Serial Monitor.

String ueInfo;
if (modem.getSystemInformation(ueInfo)) {
  Serial.print("Inquiring UE system information:");
  Serial.println(ueInfo);
}

if (!modem.setNetworkActive()) {
  Serial.println("Enable network failed!");
}
delay(5000);

String ipAddress = modem.getLocalIP();
Serial.print("Network IP:"); Serial.println(ipAddress);

HTTPS GET Request

In order to make an HTTPS GET request to the request_url variable defined at the beginning of the sketch, you need to start an HTTPS client:

modem.https_begin();

Finally, call the HTTPSGetRequest() to make the HTTPS GET request. This function will print the HTTP code, HTTP header and HTTP body of the request:

HTTPSGetRequest();

HTTPSGetRequest()

This function receives one or multiple URLs, then it makes 3 attempts to GET a valid HTTPS response from a website. It prints some debugging information in the Serial Monitor such as the HTTP code, HTTP header and HTTP body from the response.

void HTTPSGetRequest() {
  for (int i = 0; i < sizeof(request_url) / sizeof(request_url[0]); ++i) {
    int retry = 3;
    while (retry--) {
      Serial.print("Request URL : ");
      Serial.println(request_url[i]);

      // Set GET URT
      if (!modem.https_set_url(request_url[i])) {
        Serial.print("Failed to request : "); Serial.println(request_url[i]);
        // Debug
        // modem.sendAT("+CSSLCFG=\"enableSNI\",0,1");
        // modem.waitResponse();
        delay(3000);
        continue;
      }

      // Send GET request
      int httpCode = 0;
      httpCode = modem.https_get();
      if (httpCode != 200) {
        Serial.print("HTTP get failed ! error code = ");
        Serial.println(httpCode);
        delay(3000);
        continue;
      }

      // Get HTTPS header information
      String header = modem.https_header();
      Serial.print("HTTP Header : ");
      Serial.println(header);
      delay(1000);

      // Get HTTPS response
      String body = modem.https_body();
      Serial.print("HTTP body : ");
      Serial.println(body);
      delay(3000);
      break;
    }
    Serial.println("-------------------------------------");
  }
}

Troubleshooting Tips

1. Code fails to compile

IMPORTANT: for this tutorial, we’re not using the official TinyGSM library by vshymanskyy. We’re using the TinyGSM-fork by lewisxhe. If you already have the TinyGSM by vshymanskyy library installed, you must remove it.

Installing the TinyGSM-fork Library

The TinyGSM-fork by lewisxhe library is not available to install through the Arduino Library Manager, so you need to copy the library files to the Arduino installation Libraries folder. Alternatively, in your Arduino IDE, you can go to Sketch > Include Library > Add .zip Library and select the library that can be downloaded below.

2. HTTPS GET Request returns status code 715

If you make an HTTPS GET request to a website and it returns the status code 715, you might need to update your SIMCOM firmware. You can learn more about this issue here.

Please note that some websites block the ESP32 connection, so it might return an HTTP error. The githubusercontent.com URL defined in this project has been tested and it returns the proper HTTPS GET request.

3. Can’t upload code, because the COM port doesn’t appear

In order to program your board, you must power it using the USB Type-C cable, if you use the other USB port it will not allow you to program the ESP32.

You also need to install in your computer the CH9102 USB bridge driver: Windows or Mac OS.

ESP32 LILYGO TTGO T-A7670G Board connected USB Type C cable

Wrapping Up

In this tutorial, you learned how to get started with the LILYGO TTGO T-A7670G ESP32 board, pinout, and it’s main features. This tutorial can also be applied if you’re using a “regular” ESP32 connected to an external SIM7670G module. This module supports 4G which can be very useful for IoT and Home Automation projects. You also learned how to connect the board to the internet and make an HTTPS GET request

The LILYGO TTGO T-A7670G ESP32 board also comes with a microSD card slot that can be useful for datalogging projects or to save configuration settings. Furthermore, it comes with a battery holder and a battery charging circuit to use with solar panels. So, it’s suitable to use in remote locations. However, I haven’t experimented with the battery circuit yet. For more examples, you can explore the the official LILYGO T-A76XX GitHub page.

Do you have one of these boards? What do you think? Let us know in the comments below.

You may also like the following guides:

Learn more about the ESP32 with our resources:

Thanks for reading.



Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »
Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »

Enjoyed this project? Stay updated by subscribing our newsletter!

10 thoughts on “Getting Started with LILYGO TTGO T-A7670G ESP32 (4G, GPRS, and GPS)”

  1. Very nice, I just completed a home alarm for my son with this board. But I programmed it in micropython since ardunio is so boring :). It is isolated from internet so commands are sent by SMS or local access to a webpage. After tweaking a lot details with timeouts and translation of the SMS format it is working. So a TinyGSM would be very nice to simplify that part. I have a problem when there is a power dropout that usually the board restarts, sometimes it survives the switching to battery. Does anybody know how fix that?

    Reply
    • Hi.
      Unfortunately, I don’t know how to fix the issue.
      We didn’t have time to test the board in “offgrid” mode.

      Did you use any library to program it in MicroPython?
      Regards.

      Reply
      • I used your instructions for the earlier SIM board to understand how the board works and the arduinocode on Github that the board makers have published and asked chatGPT to translate that to micropython, with a lot debugging and a lot fiddeling with AT commands, timeouts for calls and using the correct characterset. I believe that TinyGSM is handling that stuff. Chatgpt help me much especially to correct syntax, but it made also a lot of trouble since it dosn´t know the limits of micropython and that libraries are not identical to the latest normal python. I believe if someone more experienced in organising python it would be easy make a library. I asked chatGPT to do that but it was a quite work to change my working code, so I didn’t take that step for this project.

        Reply
  2. Hi guys. Congratulations for your explanation. I just would like to know why did you choose this lib fork instead of the original one. May be you have fond any issue with it.

    Reply
  3. seems like a good project to build, need to finish the one I am working on right now and then I might try to see what to do about it

    Reply
  4. Bonjour, j’ai pu tester le module et il fonctionne très bien.
    Excellent travail !
    La communication étant établie, le module consomme-t-il des données en continue ? Si oui, combien ?
    Merci.

    Reply

Leave a Comment

Download Our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.