Page 1 of 1

ESP32-C3 Failing to Upload SIM800L Code

Posted: Sun Aug 09, 2026 6:16 pm
by jblake5858
Hello. I'm trying to use a SIM800L GSM module with the TinyGSM library. I've taken the following example from a site online:

Code: Select all

]#define TINY_GSM_MODEM_SIM800
#define SerialMon Serial
#define SerialAT Serial1
#define TINY_GSM_DEBUG SerialMon
#define GSM_PIN ""

#define NTP_SERVER "132.163.96.5"

#include <TinyGsmClient.h>

const char apn[] = "internet";
const char gprsUser[] = "";
const char gprsPass[] = "";

#ifdef DUMP_AT_COMMANDS
#include <StreamDebugger.h>
StreamDebugger debugger(SerialAT, SerialMon);
TinyGsm modem(debugger);
#else
TinyGsm modem(SerialAT);
#endif

TinyGsmClient client(modem);

// ESP32 and SIM800l pins
#define MODEM_TX 20     // mandatory pin
#define MODEM_RX 21     // mandatory pin
#define MODEM_RST 14    // optional 
#define MODEM_DTR 25    // optional
#define MODEM_RING 34   // optional


void setup() {
  SerialMon.begin(115200);
  delay(1000);
  pinMode(MODEM_RST, OUTPUT);
  digitalWrite(MODEM_RST, LOW);
  delay(100);                     // Keep low for 100ms
  digitalWrite(MODEM_RST, HIGH);  // Release reset pin
  delay(1000);                    // Wait for module to boot
  pinMode(MODEM_DTR, OUTPUT);
  digitalWrite(MODEM_DTR, HIGH);  // Keep modem awake
  pinMode(MODEM_RING, INPUT);     // Optional

  SerialMon.println("Wait ...");
  SerialAT.begin(115200, SERIAL_8N1, MODEM_TX, MODEM_RX);
  delay(3000);
  SerialMon.println("Initializing modem ...");
  modem.init();

  String modemInfo = modem.getModemInfo();
  SerialMon.print("Modem Info: ");
  SerialMon.println(modemInfo);

  if (GSM_PIN && modem.getSimStatus() != 3) {
    modem.simUnlock(GSM_PIN);
  }

  SerialMon.print("Waiting for network...");
  if (!modem.waitForNetwork()) {
    SerialMon.println(" fail");
    delay(10000);
    return;
  }
  SerialMon.println(" success");

  if (modem.isNetworkConnected()) {
    DBG("Network connected");
  }
  // IMEI
  String imei = modem.getIMEI();
  SerialMon.print("IMEI: ");
  SerialMon.println(imei);

  // Get operator name
  String operatorName = modem.getOperator();
  SerialMon.print("Operator: ");
  SerialMon.println(operatorName);

  // Signal quality (0–31, 99 = not known)
  int signalQuality = modem.getSignalQuality();
  SerialMon.print("Signal Quality (0-31): ");
  SerialMon.println(signalQuality);

  SerialMon.print("Connecting to APN: ");
  SerialMon.print(apn);
  if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
    SerialMon.println(" fail");
    ESP.restart();
  }
  SerialMon.println(" OK");
  if (modem.isGprsConnected()) {
    SerialMon.println("GPRS connected");
  }
  // Local IP
  IPAddress  localIP = modem.localIP();
  SerialMon.print("Local IP: ");
  SerialMon.println(localIP);
}

void loop() {
  static unsigned long lastPrint = 0;
  if (millis() - lastPrint > 5000) { // every 5 seconds
    int signal = modem.getSignalQuality();
    SerialMon.print("Signal Quality (0-31): ");
    SerialMon.println(signal);

    // Optional: Check if still connected
    if (!modem.isNetworkConnected()) {
      SerialMon.println("Network disconnected!");
    } else {
      SerialMon.println("Network OK");
    }

    lastPrint = millis();
  }

  delay(100);
}

I'm using Arduino IDE and an ESP32-C3-DevKitC-02 showing as COM10 in my device manager (which corresponds with the IDE settings). When I try to up load the above code I get the following error:

Code: Select all

A fatal error occurred: Could not open COM10, the port is busy or doesn't exist.
(could not open port 'COM10': FileNotFoundError(2, 'The system cannot find the file specified.', None, 2))

Hint: Check if the port is correct and ESP connected

Failed uploading: uploading error: exit status 2

I've done the following with no success:

1. Disconnected/reconnected the MCU.
2. Restarted the IDE.
3. Manually changed the COM port to COM 2 (Which was open and available in Windows).
4. Held the BOOT button on the MCU while trying to upload.
5. Attempted to upload the code with the GSM module completely disconnected.

I've also tried the same process with and ESP32-C6-DevKitC-1 with identical results. Other code examples upload fine, however this particular one won't. I've also tried several other examples using various SIM800L libraries to get the module working, and none want to upload, so I'm thinking it has to be something specifically to do with the code that's used for this peripheral. Can anybody help out?