Arduino SIM800L GSM Module for Beginners: Detailed Guide to Send SMS & Make Calls
Objective: Use SIM800L GSM Module with Arduino
This comprehensive guide explains how to use the SIM800L GSM module with Arduino for sending SMS messages and making phone calls. It is designed for beginners, providing step-by-step instructions, code examples, and troubleshooting tips to ensure successful implementation.
Project Goals for Arduino SIM800L GSM Module
- Understand how to interface the SIM800L GSM module with Arduino.
- Learn to send SMS messages with the SIM800L using AT commands.
- Make phone calls using Arduino and the SIM800L module.
- Develop a strong foundation in GSM communication with Arduino.
Required Components for Arduino SIM800L GSM Module
The following components are required for this project:
Component | Description | Link |
---|---|---|
Arduino Uno | Main microcontroller for GSM control | Amazon Link |
SIM800L GSM Module | Handles SMS and call functionality | Check Availability |
SoftwareSerial Library | Enables communication with the SIM800L | Built-in Arduino IDE |
SIM Card (Activated) | Provides GSM network access | Purchase from local carrier |
3.7V Li-ion Battery or 4V Power Supply | Power source for SIM800L | Check Availability |
Jumper Wires | Connects components to Arduino | Amazon Link |
Breadboard | For prototyping connections | Amazon Link |
What is the SIM800L GSM Module?
The SIM800L GSM module is a versatile GSM/GPRS module used for mobile communication. It can send SMS, make calls, and connect to the internet over a 2G network. It supports standard AT commands to communicate with microcontrollers like Arduino.
SIM800L Pinout Overview
Pin | Description |
---|---|
VCC | Power input, requires 3.7V to 4.2V |
GND | Ground connection |
TX | Transmit data, connects to Arduino RX |
RX | Receive data, connects to Arduino TX |
RST | Resets the module, connects to Arduino reset pin (optional) |
NET | External antenna pin for better GSM reception |
Circuit Connection for SIM800L GSM Module
Ensure the following connections for the SIM800L module with Arduino:
Component | Arduino Pin | Details |
---|---|---|
SIM800L VCC | External 3.7V - 4.2V | Power the SIM800L module |
SIM800L GND | GND | Ground the module |
SIM800L TX | Pin 2 | Connects to Arduino RX (SoftwareSerial) |
SIM800L RX | Pin 3 | Connects to Arduino TX (SoftwareSerial) |
SIM800L NET | External antenna | Improves GSM signal reception |
How the Circuit Works
The SIM800L GSM module communicates with the Arduino using the SoftwareSerial library, allowing you to use pins 2 and 3 for RX and TX communication. The SIM800L module handles GSM functions like sending SMS and making calls through AT commands sent from the Arduino.
Arduino Code for Sending SMS using SIM800L
This code sends an SMS message using the SIM800L module. Make sure to change the phone number to your desired recipient before uploading the code to the Arduino.
#include
// Create a SoftwareSerial object for SIM800L
SoftwareSerial mySerial(3, 2); // SIM800L Tx & Rx connected to Arduino pins #3 & #2
void setup() {
Serial.begin(9600); // Begin Serial communication
mySerial.begin(9600); // Begin communication with SIM800L
Serial.println("Initializing SIM800L...");
delay(1000);
mySerial.println("AT"); // Handshake command
updateSerial();
mySerial.println("AT+CMGF=1"); // Set SMS mode to TEXT
updateSerial();
mySerial.println("AT+CMGS=\"+ZZxxxxxxxxxx\""); // Replace ZZxxxxxxxxxx with the recipient number
updateSerial();
mySerial.print("Hello from Arduino!"); // SMS content
updateSerial();
mySerial.write(26); // Send Ctrl+Z to send SMS
}
void loop() {}
void updateSerial() {
delay(500);
while (Serial.available()) {
mySerial.write(Serial.read());
}
while (mySerial.available()) {
Serial.write(mySerial.read());
}
}
Arduino Code for Making Calls using SIM800L
This code initiates a phone call using the SIM800L module. Make sure to change the phone number to the desired recipient before uploading the code.
#include
// Create a SoftwareSerial object for SIM800L
SoftwareSerial mySerial(3, 2); // SIM800L Tx & Rx connected to Arduino pins #3 & #2
void setup() {
Serial.begin(9600); // Begin Serial communication
mySerial.begin(9600); // Begin communication with SIM800L
Serial.println("Initializing SIM800L...");
delay(1000);
mySerial.println("AT"); // Handshake command
updateSerial();
mySerial.println("ATD+ZZxxxxxxxxxx;"); // Replace ZZxxxxxxxxxx with the recipient number
updateSerial();
delay(20000); // Call duration (20 seconds)
mySerial.println("ATH"); // Hang up the call
updateSerial();
}
void loop() {}
void updateSerial() {
delay(500);
while (Serial.available()) {
mySerial.write(Serial.read());
}
while (mySerial.available()) {
Serial.write(mySerial.read());
}
}
Steps to Upload Arduino Code
- Connect your Arduino to the computer using a USB cable.
- Open the Arduino IDE, paste the code into a new sketch.
- Select the correct board (e.g., Arduino Uno) and port from the "Tools" menu.
- Click the "Upload" button to transfer the code to the Arduino.
Check Output for SIM800L GSM Module
- After uploading the SMS code, you should receive an SMS on the specified phone number.
- After uploading the call code, the specified number should receive a call that lasts for 20 seconds before hanging up.
Troubleshooting Tips for SIM800L GSM Module
- No Response from SIM800L: Check the power supply. It should be between 3.7V and 4.2V.
- No SMS Sent: Ensure that the SIM card is active, has sufficient balance, and supports SMS services.
- Network Issues: Attach an external antenna to the NET pin for better signal reception.
- Serial Communication Issues: Ensure the baud rate in the code matches the baud rate of the module (9600).
Suggestions for Beginners
Start by sending basic AT commands to the SIM800L module via the Serial Monitor to understand how it responds. Once comfortable, move on to sending SMS and making calls using the Arduino code provided.
Recommended Book for Learning Arduino
Arduino Programming for Absolute Beginners - This book provides step-by-step instructions for building various projects with Arduino, making it perfect for beginners.
Explore more tutorials and projects at MechatronicsLab.net, where you’ll find resources on Arduino, ESP8266, ESP32, and Raspberry Pi.
No comments