Implementation of Cellular Communication on Arduino using GSM Module (SIM800L)

Objective

To implement cellular communication using an Arduino and a SIM800L GSM module for IoT applications. This setup allows the Arduino to send sensor data via SMS or HTTP requests to cloud platforms.

Methodology

  • Connect the SIM800L GSM module to Arduino.
  • Use AT commands to send data via SMS or HTTP.
  • Implement communication with cloud platforms like ThingsBoard or ThingSpeak.

Implementation Steps

Hardware Requirements

1Arduino Uno/Nano
2SIM800L GSM module
3SIM card (2G/3G/4G) with an active data plan
4Li-ion battery or 5V 2A power supply
5Jumper wires

Connections

1SIM800L VCC → External 5V supply (4.1V–4.4V preferred)
2SIM800L GND → Arduino GND
3SIM800L TX → Arduino RX (Pin 2)
4SIM800L RX → Arduino TX (Pin 3)
5SIM800L RST → Not connected
6Note: Use a voltage divider or logic level shifter between Arduino TX and SIM800L RX to prevent damage.

Step 1: Send SMS Using SIM800L

Code for sending SMS via SIM800L using AT commands.

1#include <SoftwareSerial.h>
2  
3  SoftwareSerial sim800(2, 3);  // RX, TX
4  
5  void setup() {
6      Serial.begin(115200);
7      sim800.begin(9600);
8      
9      delay(1000);
10      Serial.println("Initializing SIM800L...");
11      
12      sim800.println("AT");
13      delay(1000);
14      
15      sim800.println("AT+CMGF=1");  // Set SMS mode
16      delay(1000);
17      
18      sim800.println("AT+CMGS=\"+91XXXXXXXXXX\"");  // Replace with recipient number
19      delay(1000);
20      
21      sim800.print("Temperature Alert! Sensor value: 30°C");
22      delay(1000);
23      
24      sim800.write(26);  // End SMS
25      Serial.println("Message Sent!");
26  }
27  
28  void loop() {
29  }

Step 2: Send Data to a Cloud Platform via HTTP

Code for sending temperature data to ThingsBoard cloud platform via HTTP.

1#include <SoftwareSerial.h>
2  
3  SoftwareSerial sim800(2, 3);  // RX, TX
4  
5  void setup() {
6      Serial.begin(115200);
7      sim800.begin(9600);
8      
9      Serial.println("Initializing SIM800L...");
10      sendCommand("AT", 1000);
11      
12      sendCommand("AT+SAPBR=3,1,\"Contype\",\"GPRS\"", 1000);
13      sendCommand("AT+SAPBR=3,1,\"APN\",\"your_apn\"", 1000);  // Replace with your APN
14      sendCommand("AT+SAPBR=1,1", 2000);
15      
16      sendCommand("AT+HTTPINIT", 1000);
17      sendCommand("AT+HTTPPARA=\"CID\",1", 1000);
18      sendCommand("AT+HTTPPARA=\"URL\",\"http://demo.thingsboard.io/api/v1/YOUR_ACCESS_TOKEN/telemetry\"", 1000);
19      sendCommand("AT+HTTPDATA=25,10000", 1000);
20      
21      sim800.println("{\"temperature\":30}");
22      delay(1000);
23      
24      sendCommand("AT+HTTPACTION=1", 10000);
25      sendCommand("AT+HTTPTERM", 1000);
26  }
27  
28  void loop() {}
29  
30  void sendCommand(String command, int timeout) {
31      sim800.println(command);
32      delay(timeout);
33  }

Applications

  • Remote Monitoring: Use SMS to alert users in areas without Wi-Fi.
  • IoT with Cellular: Send telemetry to cloud via GSM where internet is not available.
  • Agricultural Sensors: Use GSM to send field data like temperature and moisture.

Future Research Concepts

  • Switch to NB-IoT or LTE-M for low-power wide-area cellular IoT.
  • Enable MQTT over GSM for real-time lightweight communication.
  • Integrate GPS with SIM800L to track and report device location.