I have a SIM800L which I have connected to an ESP32-C3. I'm using the following code:
#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[] = "chatrweb.apn";
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 1 // connected
#define MODEM_RX 2 // connected
#define MODEM_RST 3 // connected
#define MODEM_DTR 25 // not used
#define MODEM_RING 34 // not used
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);
}
When I connect the module to power (with an active SIM card installed) it blinks every second for a few seconds, then transitions to every 3 seconds. This is consistent with the module connecting to the network. When I run the code above, it connects and identifies all my network details etc.., but when it gets to Connecting to APN it fails and resets. Everything I've read points to a power issue, specifically that it requires up to a 2A draw when connecting.
Here's some details about the system:
-
I'm using a Dell laptop PS which is rated for 20V and 4.5A. I cut the jack off the end and soldered it to a buck converter rated at a 3A max. The buck converter is dialed down to 4V output. I've tried it with various voltages from 3.8V - 4.2V with the same results detailed above.
-
There is a 2200uF 10V electrolytic cap across the Vcc and GND pins. I've also tried 470uF and 1000uF.
-
I'm using an antenna like this one with a u.fl to SMA adapter cable:
-
Buck converter, GMS module, and ESP32 all share a common ground.
Does anybody see any issue with the power supply I'm using?
