Home » Arduino » Arduino SIM800L Tutorial

Arduino SIM800L Tutorial

The SIM800L is a cheap and portable GSM breakout board with all the capabilities of the larger SIM900 shields. In this Arduino SIM800L tutorial, I will help you get started with this nifty device. Sending and receiving texts with your Arduino have never been easier!

Arduino sim800L breakout board

Here are the features of the SIM800L breakout board:

  • 2G quad-band @ 850/900/1800/1900 MHz
  • Receive and make calls using the speaker and microphone outputs
  • Receive and send SMS
  • Connect to the Internet via GPRS
  • Listen to FM radio broadcasts
  • Accepts AT Commands

This SIM800L breakout board is ideal for projects that needs to save space. In fact, this is the one I used when I created my own cellphone. This board draws a maximum of 2 A with an input voltage of 3.7 V to 4.2 V. This means you must not connect its pins directly to a 5 V Arduino! It doesn't even run on 3.3 V.

The solution is either to use a regulator or just have the SIM800L draw from a Li-Po (cellphone) battery. That's what I did and it works!

As for the code, we can use Adafruit's FONA library. Download it here and install it on the Arduino IDE.

Once the library is installed, you can now explore the features of the SIM800L. Let's start with sending SMS.

SMS Sending

The FONA library has a simple sendSMS() function that accepts the number and message as parameters and returns true if the message was sent through the network successfully. Here's an example code:

Let's start with this:

This part declares that the RX, TX and RST pins of the SIM800L must be connected to pin 2, 3 and 4 of the Arduino.

The lines above assigns the RX and TX pins as software serial pins. This is done so that the Arduino's hardware serial port remains to be used with the serial monitor. The FONA object is then initialized with the RST pin as parameter. The readline() declaration is needed for that last function you see on the full sketch. This function is a nifty way to read inputs from the user via the serial monitor.

The SIM800L is checked using the following sequence:

If "FONA is OK" appears in your serial monitor screen then the SIM800L is now ready to accept commands!

This part is the SMS sending part. The code asks for the recipient's number first then asks for the message. If the message is successfully sent, a "Sent!" appears on the serial monitor. Otherwise, a "Failed" appears.

Reading SMS

To read SMS stored in the SIM card, we just change the portion of the code above with this:

The function getSMSSender() returns true and places the SMS sender number to the replybuffer, while the readSMS() function returns true and places the SMS to that same buffer.

Making a Call

To make a call, we must attached a speaker to the SPKRP and SPRKRN terminals of the SIM800L and an electret microphone to the MICP and MICN terminals. Then we can replace the portion of the code above with this:

Calling a number is done using the callPhone() function which returns true if the call is successfully made and accepts the number to be called as parameter.

Receiving a Call

Receiving a call is a bit more complicated because whatever the Arduino is doing must be interrupted to acknowledge the call. This is what the example IncomingCall sketch does:

The first thing that is noticeable is the change in the pin assignments for RX, TX and RST. This is because the D2 pin of the Arduino is the default interrupt pin which will be used by the SIM800L to interrupt the Arduino whenever there is an incoming call. The D2 pin must be connected to the SIM800L's RING pin (above the DTR pin, if its not visible in yours).

There's also an option to enable or disable Caller ID notification. Cool.

There are other options in the FONA library including reading the signal level of the GSM network, scanning FM networks, and enabling GPRS to connect to the Internet! I'll explore these features on my next post so stay tuned!

Leave a Reply

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