Arduino Projects

Arduino Sim800L GSM GPRS Module Tutorial

Arduino SIM800L:

Arduino Sim800L GSM GPRS Module, Send SMS, Receive SMS, Request SMS, and Alert Message- Now, you can control your electrical loads and monitor sensors by sending a message from any cell phone using the Arduino and GSM Sim800L module.

You might be wondering if anyone can control loads or monitor sensors by sending a message from any cell phone, then anyone could misuse it.

Well, that’s not the case. I have designed this system with careful consideration. To control any load or request the value of a sensor, you need to enter a password. And you know, without a password, nobody would be able to control anything or request the sensor value.

And the most amazing thing about this project is that you can send control and request commands from any cell phone. And my designed system will reply back to you on that same number. When Arduino receives a message, it extracts the sender’s cell number and replies back to that number. Isn’t it amazing? Of course, it is.




Now, if your SMS package runs out, or your cell phone is turned off, or if it gets lost, there’s no need to worry. You can use anyone’s cell phone to control your loads and monitor sensors. Let me practically demonstrate it for you.

Arduino SIM800L

Since this is just a prototype model and a beginners level project so I have tried my level best to make it as simple as possible. So, that’s why, for the demonstration purposes I am using a potentiometer as a sensor and 110/220Vac Bulb as the load. But if you want you can use any other analog or digital sensor and the same thing applies to the Bulb.

Arduino SIM800L

Anyway, I have powered up the Arduino board, and I have also connected the 220Vac supply. When the 110/220Vac supply is connected, never touch the relay contacts.



It is important to note that when working with mains voltage, proper safety precautions should always be taken, and it is advisable to consult relevant electrical codes and standards.

I am sure you might have noticed that I am using a single 12V power supply and this is because my designed Arduino Nano development board has a 5V and 3A power supply. Which is more then enough to power up the Arduino, GSM Sim800L module, and all the other electronics.

Arduino SIM800L

I have seen many people complaining about the GSM Sim800L module, stating that it doesn’t connect to the network or keeps restarting. Such issues are often related to the power supply. So, if you use the same 5V and 3A power supply, you shouldn’t face any problems.

If you don’t want to make such a development board, you can also make this 5V and 3A power supply.



As you can see, the Sim800L module is connected to the GSM network. Now, let’s try turning this bulb on and off.

Arduino SIM800L

The message simply consists of the password.

Arduino SIM800L

This password can consist of letters, numbers, and special characters; then the word relay, and finally the command on or off.

You might have noticed I used percentage sign; I am doing this because when the Arduino receives this message. Then the Arduino can easily split this message using % sign as the delimiter. Anyway, the message is ready, and I am going to send it to the Arduino.

Arduino SIM800L

As you can see, the bulb has turned ON, and it also sent me a feedback message that the “relay is turned on”. No matter which number you use to send the message, you will receive the feedback on that same number. This feature is incredibly amazing, and I’m sure you will like it too.



Let’s turn off the Blub. This time, in the message I have written “off.”

Arduino SIM800L

As you can see, the bulb has turned OFF, and the Arduino also sent me a feedback message “relay is turned off”.

Now, let’s check the value of the sensor.

Arduino SIM800L

This time, I have only written the password, and the command “req” the message format remains exactly the same. Let’s send this message.

Arduino SIM800L

As you can see, I have received the sensor value 221. Now, I’ll rotate the knob of the potentiometer slightly to change the value. Let’s request the sensor value again.




Arduino SIM800L

This time, you can see I have received a different value. In this way, you can monitor the sensor at any time and from any cell number, provided you remember the password and message format.

And not just that. In this project, I have also added an automatic feature. Whenever the sensor value crosses the threshold value, I receive a message saying “value exceeded.” So, let’s increase the value and see if we receive the message.

Arduino SIM800L

This is amazing. In one article, you will learn all these things. So, without any further delay, let’s get started!



Amazon Links:

Arduino Nano USB-C Type (Recommended)

GSM Sim800L Module

*Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.

Sim800L GSM module:

Arduino SIM800L

The SIM800L is a GSM/GPRS module that enables communication over the GSM (Global System for Mobile Communications) network. It is commonly used in embedded systems and IoT (Internet of Things) projects for applications such as sending SMS messages, making phone calls, and connecting to the internet over GPRS. Sim800L module supports quad-band GSM/GPRS networks, which means it will work almost anywhere in the world.



The SIM card holder or slot is on the bottom side. Direction for inserting the SIM card is engraved.

Arduino SIM800L

Just make sure the Notch is pointing upwards when inserting the SIM. On my side, I have successfully tested it using Ufone and Zong sim cards, and I am sure its also going to work with Jazz and Telenor.

Arduino SIM800L

This is the u.fl connector for connecting other antennas other than the Helical Antenna connected to the pin number 1. In my case, I have connected both the Antenna’s.

This is the Network Status indicator Led. So when you power up the Sim800L module, initially, it blinks faster, so, you will need to wait for a few seconds. When it’s connected to the network then it starts to blink at a slower rate. But, if for any reason it blinks at a faster rate then remove the SIM card and insert it again and also check your power supply, I already explained it during the practical demonstration.



Here are some key features and technical specifications of the SIM800L module:

Network Compatibility:

Supports GSM/GPRS 850/900/1800/1900MHz bands.

Can be used globally, as it covers the widely used GSM frequency bands.

Communication Interfaces:

UART (Universal Asynchronous Receiver/Transmitter) interface for communication with microcontrollers or other devices.

AT command set for controlling and configuring the module.

Data Transfer:

GPRS multi-slot class 12/10.

GPRS mobile station class B.

SMS (Short Message Service):

Supports sending and receiving SMS messages.

AT commands are used to manage SMS functionality.

Voice Functionality:

Allows for making and receiving phone calls.

Supports audio codecs like HR, FR, EFR, and AMR.

Internet Connectivity:

GPRS connectivity for internet access.

TCP/IP stack for data transfer over the internet.

SIM Card Interface:

Standard SIM card slot for GSM network authentication.

Supports SIM card hot-plugging.

Power Supply:

Typically operates on 3.4V to 4.4V DC.

Low power consumption.

Dimensions:

Compact size, suitable for integration into small devices.

Operating Temperature:

Generally, it can operate in a temperature range from -40°C to +85°C.

Control and Configuration:

Controlled through AT commands, which are ASCII commands sent via the UART interface.

Can be configured for various modes and functionalities using these commands.




Sim800L Pinout:

Arduino SIM800L

It has a total of 12 pins and the bad thing is there is no labeling. So, you will have to remember all these pins.

Net Pin: Net pin is where you can solder the Helical Antenna that comes with the module.

VCC Pin: VCC Pin is the power supply pin. Connect it to a stable power source within the specified voltage range (typically 3.4V to 4.4V). This provides the necessary operating power for the module.

RST Pin: The RST pin is used to reset the SIM800L module. When this pin is pulled low or connected to a logic low signal for atleast 100ms, it triggers a hard reset, restarting the module.

RXD Pin: RXD is the pin used for receiving data by the SIM800L module. Connect it to the TX pin of your microcontroller or other communication device.

TXD Pin: TXD is the pin used for transmitting data from the SIM800L module. Connect it to the RX pin of your microcontroller or other communication device.

GND Pin: GND is the ground reference pin. Connect this pin to the ground of your system to establish a common ground reference.

The SPK- and SKP+ pins are part of the audio interface and are used for connecting the negative and positive terminals of an external 8-ohm speaker.

The MIC- and MIC+ pins are used to connect the negative and positive terminals of an external microphone.

DTR (Data Terminal Ready) Pin: DTR Pin controls the sleep mode. Pulling it HIGH causes the module to enter sleep mode, disabling serial communication. Pulling it LOW for approximately 50ms will wake up the module.

Ring Pin: Ring Pin is the Ring Indicator. This is basically the ‘interrupt-out’ pin from the module. It is by default HIGH and can be configured to go LOW when a call or SMS is received.

If you want to know more about its technical specifications and other features then ready my article. I have added a link in the description. Now, let’s go ahead and take a look at the wiring.



SIM800L interfacing with Arduino:

Arduino SIM800L

Connect the VCC and GND pins to the 5V and 3A power supply. Connect the TXD pin to the Arduino D9 and connect the RXD pin to the Arduino D10.

Out of these 4 relays I am using only 1 relay. It’s a 5V SPDT type relay and its connected to the Arduino digital pin D4. Make sure you connect the Relay module VCC and GND pins to the 5V power supply, if incase you are using an external 1 channel or multiple channels relay module.

Connect the Leftmost and rightmost legs of the Potentiometer to the 5V and GND. Connect the middle leg of the potentiometer to the Arduino analog pin A0.

You can see the Vin and GND wires in the circuit diagram. Simply, connect these wires to a 5V and 3A power supply.

Arduino SIM800L

You can follow this circuit diagram; if you want to make your own 5V and 3A power supply.



SIM800L Arduino Programming:



Code Explanation:

This line includes the SoftwareSerial library, which is used for software-based serial communication.

This line defines a SoftwareSerial object named sim800 and specifies that the transmit (TX) pin is 9 and the receive (RX) pin is 10.

These lines define integer variables relay and pot and assign them the pin numbers 4 and A0, respectively.

These lines declare several String variables (text, callerID, caller_id, passcode, and incoming) to store information, and a boolean variable (isReply) to track whether a reply is needed.

This line defines a function named getResponse, which is used to obtain a response from the SIM800L module.

The setup() function initializes the serial communication, sets the relay pin as an output, and configures the SIM800L module. It sends AT commands to the module to set up SMS functionality.




The loop() function is the main execution loop. It reads incoming SMS messages, processes commands, and sends replies. It also monitors the potentiometer value and sends a warning message if it exceeds a certain threshold.

The getValue function extracts a specified value from a string based on a separator and index.

The getCallerID and getMsgContent functions extract the caller ID and message content from an SMS message.

The Reply function sends a reply SMS to the specified caller ID using the SIM800L module.



Watch Video Tutorial:

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button