Hi All,
I am trying to implement a project with ESP32 and SIM800L. I can make calls and messages but when I try connecting to GPRS, NET LED blinks every 500mSec. I am giving proper power as required. I have used an Airtel 5G sim and am trying to connect 2g network.
I am using tiny GSM libraries. I have used the below code and serial monitor is showing GPRS connected but NET LED on SIM800L blinks continuously at every 500mSec.
Can anyone suggest my next steps related this issue?
Here is my code
"Code Begins"
#define TINY_GSM_MODEM_SIM800 // Uncomment for SIM800L modem
#include <TinyGsmClient.h>
#include <SoftwareSerial.h>
// Define your modem's serial port
#define SerialMon Serial // Serial monitor
#define SerialAT Serial2 // Serial communication with SIM800L (ESP32 has multiple UARTs)
// Your SIM800L PIN and APN settings
#define SerialMonBaud 115200
#define SerialATBaud 9600
#define MODEM_TX 17 // TX pin (from ESP32 to SIM800L)
#define MODEM_RX 16 // RX pin (from SIM800L to ESP32)
// Initialize the modem
TinyGsm modem(SerialAT);
void setup() {
// Start the serial monitor
SerialMon.begin(SerialMonBaud);
delay(10);
// Start communication with the modem
//SerialAT.begin(SerialATBaud, );
SerialAT.begin(115200, SERIAL_8N1, MODEM_RX, MODEM_TX);
delay(3000);
// Restart the modem
modem.restart();
SerialMon.println("SIM800L is ready!");
// Check network registration
checkNetwork();
}
void loop() {
// Run periodic check
delay(10000);
checkNetwork();
}
// Function to check if the SIM800L is connected to the network
void checkNetwork() {
String status;
// Check if GPRS is attached to the network
modem.sendAT("+CGATT?"); // Check GPRS attachment status
status = modem.stream.readString();
modem.sendAT("+SAPBR=3,1,\"CONTYPE\",\"GPRS\""); // Set GPRS connection type
modem.sendAT("+SAPBR=3,1,\"APN\",\"airtelgprs.com\""); // Replace 'your_apn' with your carrier's APN
modem.sendAT("+SAPBR=1,1"); // Activate the bearer profile
// Display the network status
if (status.indexOf("1") != -1) {
SerialMon.println("GPRS is connected!");
} else {
SerialMon.println("GPRS is not connected.");
}
// Check if the SIM800L is registered on the network
modem.sendAT("+CREG?"); // Check network registration status
status = modem.stream.readString();
if (status.indexOf("+CREG: 0,1") != -1) {
SerialMon.println("SIM800L is registered to the network (Home Network).");
} else if (status.indexOf("+CREG: 0,5") != -1) {
SerialMon.println("SIM800L is registered to the network (Roaming).");
} else {
SerialMon.println("SIM800L is not registered to the network.");
}
}
COde Ends"