How to use SIM800L GSM Module | Arduino | Send and Receive SMS
Introduction
There are actually a lot of GSM module available in the market but I personally recommend and prefer SIM800L due to its size and simplicity. It has a small footprint so it occupies a very small space. This is because SIM800L only provides the basic core of GSM. Meaning to say, you need to provide additional circuitry to use it but don’t worry I will show you the simplest way to use it.
To send SMS:
- Send AT+CMGF=1 <CR><LF>
– this is to configure the GSM module to text mode
CR – Cariage Return, ASCII character 13 or r
LF – Line Feed, ASCII character 10 or n - Sent AT+CMGS=”+ZZxxxxxxxxxx”<CR><LF>
– this is for entering the sim number
ZZ – is the country code
xx – is the 10-digit mobile number
CR – Cariage Return, ASCII character 13 or r
LF – Line Feed, ASCII character 10 or n - Wait for the ‘>’ reply from SIM800L before sending the next
- When the GSM replied with ‘>’, this is the time to send your message such as:
“Hello from SIM800L”<CR><LF>
Hello from SIM800L – is the SMS you want to send.
CR – Cariage Return, ASCII character 13 or r
LF – Line Feed, ASCII character 10 or n - Send a CTRL+Z character or ASCII character 26.
To receive SMS:
- Send AT+CMGF=1 <CR><LF>
– this is to configure the GSM module to text mode
CR – Cariage Return, ASCII character 13 or r
LF – Line Feed, ASCII character 10 or n - Send AT+CNMI=1,2,0,0,0<CR><LF>
– this is to configure the GSM module to forward via serial when SMS is receive.
CR – Cariage Return, ASCII character 13 or r
LF – Line Feed, ASCII character 10 or n
Video Demonstration
Source Code
1
2#include "SoftwareSerial.h"
3SoftwareSerial mySerial(2, 3);
4String cmd = "";
5
6void setup()
7{
8 mySerial.begin(9600);
9 Serial.begin(9600);
10 Serial.println("Initializing...");
11 delay(1000);
12 mySerial.println("AT"); // Sends an ATTENTION command, reply should be OK
13 updateSerial();
14 mySerial.println("AT+CMGF=1"); // Configuration for sending SMS
15 updateSerial();
16 mySerial.println("AT+CNMI=1,2,0,0,0"); // Configuration for receiving SMS
17 updateSerial();
18}
19
20void loop()
21{
22 updateSerial();
23}
24
25void updateSerial()
26{
27 delay(500);
28 while (Serial.available())
29 {
30 cmd+=(char)Serial.read();
31 if(cmd!=""){
32 cmd.trim(); // Remove added LF in transmit
33 if (cmd.equals("S")) {
34 sendSMS();
35 } else {
36 mySerial.print(cmd);
37 mySerial.println("");
38 }
39 }
40 }
41
42 while(mySerial.available())
43 {
44 Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
45 }
46}
47
48void sendSMS(){
49 mySerial.println("AT+CMGF=1");
50 delay(500);
51 mySerial.println("AT+CMGS="+639175291539"r");
52 delay(500);
53 mySerial.print("Hi! TechToTinker!");
54 delay(500);
55 mySerial.write(26);
56}
Call To Action
If you find article helpful, please kindly Subscribe to my channel. Thank you and have a good day.
Posts in this series
- How to Get Started with ATTiny85 in Arduino IDE
- Tutorial: How to use MFRC522 RFID module using Arduino
- SOS Flasher Using Millis Function with Enable Switch
- Tutorial: How to use DS3231 RTC in Arduino
- Tutorial: How to use 0.96 OLED - a small and cute display
- Tutorial: Getting Started with the NRF24L01 | How to use | Arduino
- Tutorial: How to use SIM800L GSM Module for Controlling Anything | Arduino
- Tutorial: How to use Keypad | Text Entry Mode | Arduino
- Tutorial: How to use 4x4 Keypad | Arduino
- Project Idea: Arduino Voltmeter
- Project Idea: Door Lock Security | Arduino
- Multitasking with Arduino | Relay Timer Controller | using millis
- Tutorial Understanding Blink Without Delay | How to millis
- Arduino Simple LCD Menu
- How to use SIM800L GSM Module using Arduino | Make or Answer Voice Calls
- Tutorial: How to Use Arduino Uno as HID | Part 2: Arduino Mouse Emulation
- Tutorial: How to Use Arduino Uno as HID | Part 1: Arduino Keyboard Emulation
- Tutorial: How to use SIM800L DTMF to Control Anything | Arduino
- Tutorial: Arduino EEPROM
- 16x2 LCD Menu for Arduino
- Tutorial: Arduino GPIO | How to use Arduino Pins
- MIT App Inventor for Arduino
- RC Car using L298N, HC-06, and Arduino Uno
- How to Use LCD Keypad Shield for Arduino
- How to Use Arduino Interrupts
- Project: Automatic Alcohol Dispenser
- TUTORIAL: How to use HC-SR04 Ultrasonic Sensor with Arduino
- Source Code: Astronomia Meme and Funeral Dance | melodies the Arduino way
- How to Get Started with L293D Motor Driver Shield with Arduino
- How to Get Started with L298N Motor Driver module using Arduino
- Part 2: Wav Music Player with Lyrics Using Arduino and SD Card
- Interfacing Infrared to Arduino Uno
- Part 1: Wav Music Player Using Arduino Uno and SD Card
- How to Interface Stepper Motor to Arduino Uno
- How To Play MP3 Files on Arduino from SD Card
- What is Arduino Software Serial
- How to Interface SD card to Arduino (without SD card shield)?
- Playing Melodies Using Arduino
- 8 Degrees Of Freedom (DOF) Robot Using Arduino Uno
- How to Interface PS2 Controller to Arduino Uno
- Part 3: DF Player Mini Tinkering with Arduino Nano and LCD
- How to Interface HC-06 to Arduino
- How to make a Remote Control RC car using Arduino and HC-06 bluetooth module
- Part 2: DF Player Mini Tinkering with Arduino Nano
- Part 1: DF Player Mini - a mini cheap mp3 player
No comments yet!