Skip to main content
ESPBoards

ESP32 SIM800L GSM/GPRS Module

The SIM800L is a GSM/GPRS communication module that supports voice, SMS, and data transmission. It is ideal for IoT applications requiring wireless connectivity over quad-band GSM networks.

Jump to Code Examples

Arduino Core Image
ESP-IDF Image
ESPHome Image
PlatformIO Image
MicroPython Image

Quick Links

SIM800L GSM/GPRS Module Datasheet ButtonSIM800L GSM/GPRS Module Specs ButtonSIM800L GSM/GPRS Module Specs ButtonSIM800L GSM/GPRS Module Specs Button

SIM800L Price

SIM800L GSM/GPRS Module
Normally, the SIM800L GSM/GPRS Module costs around 6.00$ per Psc.
The prices are subject to change. Check current price:

Amazon com

Amazon de logo

Aliexpress logo

About SIM800L GSM/GPRS Module

The SIM800L is a GSM/GPRS module offering quad-band connectivity (850/900/1800/1900MHz), making it ideal for applications like SMS, voice, and data communication. Its compact size, low power consumption, and versatile interface options make it suitable for IoT projects and embedded systems. The module supports TCP/IP protocol, HTTP, FTP, and MMS functionalities, enhancing its usability in various network-dependent applications.

If you are still choosing the SIM Module and would like to know more about different available LTE, 3G, GPRS Modules, check the ESP32 SIM Modules Comparison Table.

SIM800L Sensor Technical Specifications

Below you can see the SIM800L GSM/GPRS Module Technical Specifications. The sensor is compatible with the ESP32, operating within a voltage range suitable for microcontrollers. For precise details about its features, specifications, and usage, refer to the sensor’s datasheet.

  • Protocol: UART
  • Frequency Bands: Quad-band 850/900/1800/1900MHz
  • Voltage Range: 3.4V to 4.4V
  • Current Consumption (Sleep Mode): 0.7mA
  • Dimensions: 15.8mm x 17.8mm x 2.4mm
  • Temperature Range: -40°C to +85°C
  • Protocol Support: TCP/IP, HTTP, FTP, MMS
  • SIM Card: Supports 1.8V and 3V SIM cards
  • Interface: UART (AT Command)

SIM800L Sensor Pinout

Below you can see the pinout for the SIM800L GSM/GPRS Module. The VCC pin is used to supply power to the sensor, and it typically requires 3.3V or 5V (refer to the datasheet for specific voltage requirements). The GND pin is the ground connection and must be connected to the ground of your ESP32!

The SIM800L pinout includes:

  • VCC: Power input (3.4V to 4.4V).
  • GND: Ground connection.
  • RXD: UART Receive pin (connects to microcontroller TX).
  • TXD: UART Transmit pin (connects to microcontroller RX).
  • RST: Reset pin (active low).
  • NET: External antenna pad for better signal reception.

SIM800L Wiring with ESP32

Below you can see the wiring for the SIM800L GSM/GPRS Module with the ESP32. Connect the VCC pin of the sensor to the 3.3V pin on the ESP32 or external power supply for power and the GND pin of the sensor to the GND pin of the ESP32. Depending on the communication protocol of the sensor (e.g., I2C, SPI, UART, or analog), connect the appropriate data and clock or signal pins to compatible GPIO pins on the ESP32, as shown below in the wiring diagram.

To connect the SIM800L to a microcontroller, follow these steps:
  • Connect VCC to a stable 4V power source.
  • Connect GND to the ground of the microcontroller.
  • Attach TXD to the RX pin of the microcontroller and RXD to the TX pin.
  • Optionally, connect RST to a GPIO pin for resetting the module.
  • Ensure a proper external antenna is connected to the NET pin for better signal reception.

Code Examples

Below you can find code examples of SIM800L GSM/GPRS Module with ESP32 in several frameworks:

If you encounter issues while using the SIM800L GSM/GPRS Module, check the Common Issues Troubleshooting Guide.

Arduino Core Image

ESP32 SIM800L Arduino IDE Code Example

Example in Arduino IDE

Fill in your main Arduino IDE sketch file with the following code to use the SIM800L GSM/GPRS Module:

#include <SoftwareSerial.h>

SoftwareSerial sim800l(10, 11); // RX, TX

void setup() {
Serial.begin(9600);
sim800l.begin(9600);

// Send AT command to test communication
Serial.println("Sending: AT");
sim800l.println("AT");
delay(1000);
while (sim800l.available()) {
Serial.write(sim800l.read());
}
}

void loop() {
// Send an SMS
sim800l.println("AT+CMGF=1"); // Set SMS to text mode
delay(1000);
sim800l.println("AT+CMGS=\"+1234567890\""); // Replace with recipient's number
delay(1000);
sim800l.print("Hello from SIM800L");
delay(1000);
sim800l.write(26); // CTRL+Z to send SMS
delay(5000);
}

This Arduino sketch interfaces with the SIM800L module using the SoftwareSerial library. The module is initialized, and a basic AT command is sent to verify communication. In the loop, the sketch sends an SMS to a specified number by setting the module to SMS text mode, providing the recipient's number, and sending the message. The message is finalized with CTRL+Z (ASCII 26) to trigger the transmission.

Connect your ESP32 to your computer via a USB cable, Ensure the correct Board and Port are selected under Tools, Click the "Upload" button in the Arduino IDE to compile and upload the code to your ESP32.

ESP-IDF Image

ESP32 SIM800L ESP-IDF Code Example
Example in Espressif IoT Framework (ESP-IDF)

If you're using ESP-IDF to work with the SIM800L GSM/GPRS Module, here's how you can set it up and read data from the sensor. Fill in this code in the main ESP-IDF file:

#include <stdio.h>
#include "driver/uart.h"
#include "freertos/task.h"

#define TX_PIN 17
#define RX_PIN 16
#define UART_PORT UART_NUM_1

void app_main(void) {
uart_config_t uart_config = {
.baud_rate = 9600,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE
};

uart_param_config(UART_PORT, &uart_config);
uart_set_pin(UART_PORT, TX_PIN, RX_PIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
uart_driver_install(UART_PORT, 1024, 0, 0, NULL, 0);

char *test_cmd = "AT\r\n";
uart_write_bytes(UART_PORT, test_cmd, strlen(test_cmd));

while (true) {
char data[128];
int len = uart_read_bytes(UART_PORT, data, sizeof(data), 100 / portTICK_PERIOD_MS);
if (len > 0) {
data[len] = '\0';
printf("Response: %s\n", data);
}
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}

This ESP-IDF example demonstrates UART communication with the SIM800L module. The UART interface is configured with GPIO17 as TX and GPIO16 as RX. An AT command is sent to test communication, and responses from the module are printed to the console. The module’s replies are read using the uart_read_bytes function in a loop.

Update the I2C pins (I2C_MASTER_SDA_IO and I2C_MASTER_SCL_IO) to match your ESP32 hardware setup, Use idf.py build to compile the project, Use idf.py flash to upload the code to your ESP32.

ESPHome Image

ESP32 SIM800L ESPHome Code Example

Example in ESPHome (Home Assistant)

Fill in this configuration in your ESPHome YAML configuration file (example.yml) to integrate the SIM800L GSM/GPRS Module

uart:
tx_pin: GPIO17
rx_pin: GPIO16
baud_rate: 9600

switch:
- platform: template
name: "Send AT Command"
turn_on_action:
- uart.write: "AT\r\n"

sensor:
- platform: custom
lambda: |-
return {nullptr};
sensors:
- name: "SIM800L Response"

The ESPHome configuration sets up UART communication with the SIM800L using GPIO17 (TX) and GPIO16 (RX) at 9600 baud. A template switch is used to send the AT command, and a custom sensor can be implemented to process responses from the module.

Upload this code to your ESP32 using the ESPHome dashboard or the esphome run command.

PlatformIO Image

ESP32 SIM800L PlatformIO Code Example

Example in PlatformIO Framework

For PlatformIO, make sure to configure the platformio.ini file with the appropriate environment and libraries, and then proceed with the code.

Configure platformio.ini

First, your platformio.ini should look like below. You might need to include some libraries as shown. Make sure to change the board to your ESP32:

[env:sim800l]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200

ESP32 SIM800L PlatformIO Example Code

Write this code in your PlatformIO project under the src/main.cpp file to use the SIM800L GSM/GPRS Module:

#include <HardwareSerial.h>

HardwareSerial sim800l(1);

void setup() {
Serial.begin(115200);
sim800l.begin(9600, SERIAL_8N1, 16, 17); // RX, TX

sim800l.println("AT"); // Test AT command
delay(1000);
while (sim800l.available()) {
Serial.write(sim800l.read());
}
}

void loop() {
sim800l.println("AT+CMGF=1"); // Set SMS to text mode
delay(1000);
sim800l.println("AT+CMGS=\"+1234567890\""); // Replace with recipient's number
delay(1000);
sim800l.print("Hello from PlatformIO");
delay(1000);
sim800l.write(26); // CTRL+Z to send SMS
delay(5000);
}

This PlatformIO code interfaces with the SIM800L module using HardwareSerial on an ESP32. The AT command is sent to test communication, and SMS functionality is implemented in the loop. GPIO16 (RX) and GPIO17 (TX) are configured as serial pins.

Upload the code to your ESP32 using the PlatformIO "Upload" button in your IDE or the pio run --target upload command.

MicroPython Image

ESP32 SIM800L MicroPython Code Example

Example in Micro Python Framework

Fill in this script in your MicroPython main.py file (main.py) to integrate the SIM800L GSM/GPRS Module with your ESP32.

from machine import UART
import time

# Initialize UART
uart = UART(2, baudrate=9600, tx=17, rx=16)

def send_at(command):
uart.write(command + '\r\n')
time.sleep(1)
while uart.any():
print(uart.read().decode('utf-8'), end='')

# Test communication
send_at('AT')

# Send SMS
send_at('AT+CMGF=1') # Set SMS to text mode
send_at('AT+CMGS="+1234567890"') # Replace with recipient's number
uart.write("Hello from MicroPython" + chr(26))

This MicroPython code communicates with the SIM800L module over UART. It defines a function to send AT commands and display the response. The script tests communication with an AT command and sends an SMS by setting the module to SMS text mode, specifying the recipient, and finalizing the message with CTRL+Z (ASCII 26).

Upload this code to your ESP32 using a MicroPython-compatible IDE, such as Thonny, uPyCraft, or tools like ampy.

SIM800L GSM/GPRS Module Troubleshooting

This guide outlines a systematic approach to troubleshoot and resolve common problems with the . Start by confirming that the hardware connections are correct, as wiring mistakes are the most frequent cause of issues. If you are sure the connections are correct, follow the below steps to debug common issues.

Module Continuously Resets or Reboots

Issue: The SIM800L module restarts frequently, indicated by the status LED turning off and on repeatedly.

Possible causes include insufficient power supply or voltage drops due to wiring.

Solution: Use a dedicated power supply capable of providing 4V and at least 2A. Incorporate low ESR capacitors (e.g., 100µF tantalum and 470µF electrolytic) close to the module's power pins to handle current spikes. Additionally, use short, thick wires (e.g., 22AWG) to minimize resistance and ensure consistent voltage levels.

Failure to Connect to the Cellular Network

Issue: The module's network LED blinks rapidly, indicating it is not registered on the network.

Possible causes include incorrect SIM card configuration, poor signal strength, or frequency mismatch.

Solution: Ensure the SIM card is active, has sufficient balance, and the PIN lock is disabled. Check the external antenna connection and position it in a location with better network coverage. Verify that the module supports the cellular network's frequency bands in your region.

UART Communication Issues

Issue: No response from the module when sending AT commands.

Possible causes include incorrect baud rate, wiring errors, or power instability.

Solution: Ensure that the module and the microcontroller are set to the same baud rate (default is 9600). Confirm the RX and TX pins are connected correctly (RX to TX and TX to RX). Use a stable power source and add decoupling capacitors to avoid power fluctuations.

Unstable GSM Signal

Issue: The SIM800L fails to maintain a stable connection, resulting in dropped calls or intermittent data transmission.

Possible causes include poor antenna placement or interference from nearby electronics.

Solution: Use a proper external antenna and position it away from other electronic components that may cause interference. Ensure that the antenna connection to the NET pin is secure.

Conclusion

We went through technical specifications of SIM800L GSM/GPRS Module, its pinout, connection with ESP32 and SIM800L GSM/GPRS Module code examples with Arduino IDE, ESP-IDF, ESPHome and PlatformIO.