Internet of Things,  Tutorials

Read and Send SMS using SIM800L GSM Module and Arduino

Today we will learn how to send and receive SMS with SIM800L GSM Module and Arduino. This is a great project that you can integrate with your home automation or send sensor readings to your phone using SMS.

Requirements

Arduino

Sim 800L GSM Module

Simcard with Load for Texting

 

Connections

Connect VCC pin to 5V. Sim 800L recommended voltage is 3.4V to 4.4V but it can handle up to 5V of Arduino. You can use a linear Voltage regulator like LM317 or LM388 or just use a Buck Converter to step down the voltage. In this tutorial, we won’t be using those and will directly connect our module to 5V.

Connect the RX to Digital Pin 2 and TX to Digital Pin 3. Lastly, connect the GND to GND of Arduino.

After connecting the SMS module, plug your Arduino to your PC.

You will notice that the SMS module is Blinking. If it is blinking every 1 second, it means that the module is running but hasn’t made a connection to the cellular network yet. If it blinks every 3 seconds, the module has made contact with the cellular network & can send/receive voice and SMS.

Source Code

Sending SMS

Change the YY with your country code, and continue with your number. For example, in the Philippines, YY would be 63 and X’s would be the next 10 digits.

For the complete country codes, visit this website. http://www.ipipi.com/help/telephone-country-codes.htm

AT is the abbreviation of “Attention“.

AT Perform handshake. Replies OK if succeeded.
AT+CMGF=1 Set the operating mode to SMS text mode
AT+CMGS=”+YYxxxxxxxxxx” Send the Message

You will notice that we added mySerial.write(26); (number 26 (1A hex) This is to print Ctrl+Z, by convention often described as ^to send the message.



Reading Message

Upload the following code to your Arduino

After uploading the code, open up your Serial Monitor by clicking “Tools -> Serial Monitor” or simply “CTRL + SHIFT + M”. Send a message to your GSM module and you will see the ff. in your Serial Monitor.

 

The AT+CNMI=1,2,0,0,0 sets how the modem will response when an SMS is received. We will need to continuously poll the serial to monitor the message.

 

Testing your GSM Module

If you want to test your GSM module connected to your Arduino, there is a handy tool called AT Command Tester.

Download AT Command Tester

Simply choose the COM Port of your Arduino and set the Baud Rate to 9600 then connect. You can test the GPRS connection, sending/receiving of message, calls, get information about your module and many more 🙂

If you have further concerns or would like to integrate the GSM module with your sensors, just comment down below and I will promptly reply to your comment.

Please like and share if you enjoy this tutorial 🙂

 

 

Spread the love

Leave a Reply

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