I think Sim800l is one of most valuable modules in IOT because in conditions that you don't have internet or WIFI, you can use it only with a sim card. Also its so cheap and it is so easy to run and use. In my experiments i found it so easy to start working and it only needs a good power source. based on data sheet it needs between 3.4 to 4.2 volt, but i found around 4.1 volt is good and it will has a stable connection without any problems. When you power up Sim800l, if you see led on module blinks every 1 seconds it mean connection has problem and i found in most of cases its because of power supply. when it blinks every 3 seconds, its ok and connected. I use a 18650 battery which has around 4.2 volt when it is fully charged. You can also use Li-Po batteries.
One of other benefits of Sim800l is its power usage which is very low and make it a good choice for portable devices. In sleep mode it only use 1 mAh and when it is under load for receiving SMS, it uses around 50 mAh. I calculated for a normal usage with a 5000 mAh battery, it last around 2 weeks.
In this blog at first we just power up Sim800l and show received SMS in terminal, next we add a feature to send back a confirmation SMS as a SMS arrived and in last step we control a simple led with a command that we will send it through our SMS. This project is a starting point for using Sim800l and in future i am going to make other projects with it and replace this simple led with other things like GPS module to make a Tracker Device.
Project Overview
This repository contains a step-by-step implementation of SMS-based control using the SIM800L GSM module. The project is divided into three main parts:
- Basic SMS Reception - Setting up the SIM800L to receive and display SMS messages in the serial monitor
 - LED Control via SMS - Extending the basic setup to control an LED by sending "ON" or "OFF" text messages
 - SMS Reception and Confirmation - Like first part but it will sends back a confirmation SMS that your SMS delivered.
 
Perfect for IoT enthusiasts looking to add remote control capabilities to their projects without relying on WiFi or Bluetooth.
Hardware Requirements
- Arduino UNO or compatible board
 - SIM800L GSM/GPRS module
 - SIM card with SMS capability (and some credit)
 - LED
 - 220Ω resistor
 - Breadboard and jumper wires
 - Power supply (The SIM800L typically needs 3.7-4.2V)
 
SIM800l Pinout
Wiring Connections
| SIM800L Pin | Arduino Pin | 
|---|---|
| RX | D2 | 
| TX | D3 | 
| VCC | 3.7-4.2V external supply | 
| GND | GND | 
For the LED control project:
- Connect LED anode (longer leg) to Arduino pin D8
 - Connect LED cathode (shorter leg) to a 220Ω resistor
 - Connect the other end of the resistor to GND
 
Wiring Connections Diagram Without LED
Wiring Connections Diagram With LED
My Wiring Connection (Sorry if it's not so nice)
Software Setup
- Install the Arduino IDE if you haven't already
 - No additional libraries are required for this project
 - Upload the appropriate sketch to your Arduino:
- 
withoutLED.inofor basic SMS reception - 
WithLED.inofor LED control via SMS - 
WithoutLED&SendBackConfirm.inofor SMS reception and confirmation. 
 - 
 
Project Progression
Part 1: Basic SMS Reception
The first sketch demonstrates how to:
- Initialize the SIM800L module
 - Configure it to receive SMS messages
 - Display incoming messages in the serial monitor
 
This provides a foundation for understanding how to communicate with the SIM800L module.
Sketch:
#include <SoftwareSerial.h>
#define SIM800_RX_PIN 2
#define SIM800_TX_PIN 3
#define SIM800_RST_PIN 4  // Optional, can be used to reset the module
SoftwareSerial sim800(SIM800_TX_PIN, SIM800_RX_PIN); // RX, TX for Arduino
void setup() {
  Serial.begin(9600);
  sim800.begin(9600);
  delay(1000);
  Serial.println("Initializing SIM800L...");
  sim800.println("AT");
  delay(1000);
  sim800.println("AT+CMGF=1"); // Set SMS text mode
  delay(1000);
  sim800.println("AT+CNMI=1,2,0,0,0"); // Auto show SMS
  delay(1000);
}
void loop() {
  if (sim800.available()) {
    Serial.write(sim800.read());
  }
  if (Serial.available()) {
    sim800.write(Serial.read());
  }
}
Part 2: Adding SMS Confirmation
Building on the first part, this sketch adds:
- Module sends back a confirmation that our SMS has been successfully received. Sketch:
 
#include <SoftwareSerial.h>
#define SIM800_RX_PIN 2
#define SIM800_TX_PIN 3
#define SIM800_RST_PIN 4  // Optional, can be used to reset the module
SoftwareSerial sim800(SIM800_TX_PIN, SIM800_RX_PIN); // RX, TX for Arduino
String incomingData = "";
bool messageReceived = false;
String senderNumber = "";
void setup() {
  Serial.begin(9600);
  sim800.begin(9600);
  delay(1000);
  Serial.println("Initializing SIM800L...");
  // Reset module if needed
  // pinMode(SIM800_RST_PIN, OUTPUT);
  // digitalWrite(SIM800_RST_PIN, LOW);
  // delay(1000);
  // digitalWrite(SIM800_RST_PIN, HIGH);
  // delay(3000);
  // Initialize module
  sendATCommand("AT", 1000);
  sendATCommand("AT+CMGF=1", 1000); // Set SMS text mode
  sendATCommand("AT+CNMI=1,2,0,0,0", 1000); // Configure SMS notification
  Serial.println("SIM800L Ready");
}
void loop() {
  // Check for incoming data from SIM800L
  while (sim800.available()) {
    char c = sim800.read();
    incomingData += c;
    Serial.write(c); // Echo to serial monitor
    delay(10);
  }
  // Process complete messages
  if (incomingData.length() > 0) {
    // Check if it's an SMS message notification
    if (incomingData.indexOf("+CMT:") != -1) {
      // Extract sender phone number
      int phoneStartIndex = incomingData.indexOf("+CMT: \"") + 7;
      int phoneEndIndex = incomingData.indexOf("\"", phoneStartIndex);
      if (phoneStartIndex > 7 && phoneEndIndex != -1) {
        senderNumber = incomingData.substring(phoneStartIndex, phoneEndIndex);
        Serial.print("Sender number: ");
        Serial.println(senderNumber);
        // Send reply SMS
        sendSMS(senderNumber, "Your SMS has been received. Thank you!");
      }
    }
    // Clear the buffer after processing
    incomingData = "";
  }
  // Handle commands from Serial monitor
  if (Serial.available()) {
    sim800.write(Serial.read());
  }
}
// Function to send AT commands
void sendATCommand(String command, int timeout) {
  sim800.println(command);
  delay(timeout);
  while (sim800.available()) {
    Serial.write(sim800.read());
  }
}
// Function to send SMS
void sendSMS(String number, String message) {
  Serial.println("Sending SMS reply...");
  sim800.println("AT+CMGF=1"); // Set SMS text mode
  delay(500);
  sim800.print("AT+CMGS=\"");
  sim800.print(number);
  sim800.println("\"");
  delay(500);
  sim800.print(message);
  delay(500);
  sim800.write(26); // ASCII code for CTRL+Z to send message
  delay(3000); // Wait for message to be sent
  Serial.println("SMS sent!");
}
Part 3: LED Control via SMS
Building on the first part, this sketch adds:
- LED control functionality
 - SMS command parsing
 - Feedback through the serial monitor
 
Send "ON" or "OFF" in an SMS to the SIM card number to control the LED remotely.
Sketch:
#include <SoftwareSerial.h>
#define SIM800_RX_PIN 2
#define SIM800_TX_PIN 3
#define SIM800_RST_PIN 4  // Optional, not used here
#define LED_PIN 8        // Connect an LED to this pin
SoftwareSerial sim800(SIM800_TX_PIN, SIM800_RX_PIN); // RX, TX for Arduino
String incomingData = ""; // To hold incoming data from SIM800
void setup() {
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, LOW); // Turn off LED initially
  Serial.begin(9600);
  sim800.begin(9600);
  delay(1000);
  Serial.println("Initializing SIM800L...");
  sim800.println("AT");
  delay(1000);
  sim800.println("AT+CMGF=1"); // Set SMS text mode
  delay(1000);
  sim800.println("AT+CNMI=1,2,0,0,0"); // Show SMS directly
  delay(1000);
}
void loop() {
  while (sim800.available()) {
    char c = sim800.read();
    Serial.write(c);
    incomingData += c;
    // Check for end of SMS
    if (c == '\n') {
      incomingData.trim(); // Remove extra spaces/newlines
      if (incomingData.indexOf("ON") != -1) {
        digitalWrite(LED_PIN, HIGH);
        Serial.println("LED turned ON");
      }
      else if (incomingData.indexOf("OFF") != -1) {
        digitalWrite(LED_PIN, LOW);
        Serial.println("LED turned OFF");
      }
      incomingData = ""; // Clear buffer for next message
    }
  }
  // Optional: forward Serial input to SIM800 for debugging
  while (Serial.available()) {
    sim800.write(Serial.read());
  }
}
Troubleshooting Tips
- Power Issues: The SIM800L is sensitive to power fluctuations. Use a dedicated power supply capable of handling current spikes.
 - Network Registration: Make sure the SIM card is activated and has good signal strength.
 - AT Commands: If you're having trouble, try sending basic AT commands through the serial monitor to test communication.
 - Baud Rate: Ensure both the Arduino and SIM800L are communicating at the same baud rate (9600 in this project).
 
👉 You can find the full source code here:
GitHub Repo: payamhsn/Iot-Sim800l-Starter
At the end, i think this module is so valuable, because with this module and a relay which is a low cost setup, you can connect to any device with any voltage, from a Lamp to an Air condition systems and control them from anywhere that you are.
Thanks a lot for reading my blog. I wrote everything by myself and a little help of AI in making tables and some content. Love & Respect
              



    
Top comments (0)