Home / Tutorials / Arduino Tutorial / 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 with using this nifty device. Sending and receiving texts with your Arduino have never been easier!

Arduino sim800L breakout board

SIM800L Introduction

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

Go to SIM900 Tutorial if you have that module instead

This SIM800L breakout board is ideal for projects that needs to save space. In fact, I created my own cellphone using this module. 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.

SIM800L Pinout

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!

If the power to the SIM800L is enough, the on-board LED starts blinking. The frequency of the blinking means something:

  • Every second:  searching for a network.
  • Every three seconds: connected to a network.
  • Twice per second: connected through GPRS.

Antennas are essential for this kind of module especially if your project is indoors. Without an antenna, there would not be enough transmitting power for the SIM800L to perform GSM services such as calls and SMS. I decided to purchase this one:

SIM800L Antenna

I found this antenna to be more effective than the one that comes with the SIM800L module by default:

If you are still having trouble with the SIM800L, I suggest you try out my network test project. This helps you test out if the module is really connecting to a network or is getting enough power.

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

With the library now accessible, you can explore the features of the SIM800L. Let's start with sending SMS using this wiring diagram:

Arduino SIM800L Connection

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:

Upload this sketch to your Arduino and open serial monitor to send SMS.

Let me explain the sketch above. 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.

Check out my GPRS tutorial to learn how to use the SIM800 module to connect to the Internet

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.

You can automate the sending of SMS instead of using the serial monitor by using the sketch below:

In the sketch above, the message "Hello World" will be sent to the number  "+639567110674" when the Arduino starts.

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.

You also need to add the following functions for reading sms:

The readnumber() function returns the number of the sender of the SMS you are reading. The readBlocking() function is necessary to avoid reading the serial port when nothing arrives.

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 possible through the callPhone() function. Moreover, this function returns true if the call is successfull. The number to be called is the parameter for this function.

Receiving a Call

Receiving a call is a bit more complicated because there must be an interrupt trigger 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. The SIM800L uses this pin to interrupt the Arduino whenever there is an incoming call. Thus, connecting the D2 pin to the SIM800L's RING pin (above the DTR pin, if its not visible in yours) is a must.

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!

Buy Chip SIM800L Modules at AliExpress

Check Also

Arduino 16-bit PWM

Generating an Arduino 16-bit PWM

Ever since I wrote about timer interrupts, a number of readers have asked me on …


  1. Hello,thanks for your tutorial.
    I have a problem whit my madule, when I upload this code(for sending sms) in serial monitor appear "couldnt find fona"what is the problem?

  2. When I change the portion of the code to receive SMS I get this error "readnumber" was not declared in this scope, that's from uint8_t smsn = readnumber();

  3. hi sir. I am new in this sim800l module.. Can I use this module in Philippines?

    • Hello Gino,

      Yes it is usable in the Philippines. In fact, I am a Filipino using this device in the Philippines 🙂

      • char sendto[21], message[141];
        Serial.print(F("Send to #"));
        readline(sendto, 20);

        sir in this part, 11 numbers lang po yung dapat na iinput.
        tama po ba to ?

        char sendto[12], message[141];
        Serial.print(F("Send to #"));
        readline(sendto, 11);

  4. Hello dear,
    I am Reshad, from Bangladesh. I baught a SIM 800L and Arduino UNO R3. But I can not run SIM 800L. Would you please help me?

    Actually I want to make a little project. Like on/off a relay by sending SMS or DTMF system. Please help me. Thanks.

    • Hello Reshad,

      By "I can not run SIM 800L", do you mean you aren't getting any response from the module? Have you tried using the library I suggested in this post?

      • Thanks a lot for your kind reply dear. My SIM 800L run now. But serial monitor doesn't response. How can I do?? :-/

        • I am using this code as it is and wire connect SIM800L TXD, RXD, RST to UNO 3,2,4 pin. But serial monitor no response. Would you help me plz.

          #include "Adafruit_FONA.h"

          #define FONA_RX 2
          #define FONA_TX 3
          #define FONA_RST 4

          char replybuffer[255];

          SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);

          Adafruit_FONA fona = Adafruit_FONA(FONA_RST);

          uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout = 0);

          void setup() {
          while (!Serial);
          Serial.println(F("FONA basic test"));
          Serial.println(F("Initializing....(May take 3 seconds)"));
          if (! fona.begin(fonaSS)) {
          Serial.println(F("Couldn't find FONA"));
          while (1);
          Serial.println(F("FONA is OK"));

          char sendto[21], message[141];
          Serial.print(F("Send to #"));
          readline(sendto, 20);
          Serial.print(F("Type out one-line message (140 char): "));
          readline(message, 140);
          if (!fona.sendSMS(sendto, message)) {
          } else {

          void loop() {}

          void flushSerial() {
          while (Serial.available())

          uint8_t readline(char *buff, uint8_t maxbuff, uint16_t timeout) {
          uint16_t buffidx = 0;
          boolean timeoutvalid = true;
          if (timeout == 0) timeoutvalid = false;

          while (true) {
          if (buffidx > maxbuff) {

          while(Serial.available()) {
          char c = Serial.read();

          if (c == '\r') continue;
          if (c == 0xA) {
          if (buffidx == 0) // the first 0x0A is ignored

          timeout = 0; // the second 0x0A is the end of the line
          timeoutvalid = true;
          buff[buffidx] = c;

          if (timeoutvalid && timeout == 0) {
          buff[buffidx] = 0; // null term
          return buffidx;

      • Yes I got SIM800L response. Now I need code to operate a relay by SMS and DTMF.

      • which libraries please tell

  5. I have the GSM800L you described above. What did you use for an antenna? I got a sim not registered error when i run get network status of ADAFRUIT FONA library. Can you help? I assumed it was an antenna error but i cant seem to fix it.

  6. whether the part

    Serial.print(F("Send to #"));
    readline(sendto, 20);
    Serial.print(F("Type out one-line message (140 char): "));

    should i change with the destination phone number and the message?

    • Hi Danny,

      No, you can't insert a number there unless other modifications are made. That code is for sending messages via the IDE's serial monitor. Thus, the number should be printed on the monitor rather than in-code.

  7. Hi Roland, pls i've been working on a sim800 project and been having some issues, would be glad if you could help out. The sim module sends sms normally using the example code, but for my project, it is meant to send a message to a number when the heart rate sensor detects an abnormality in the heart beat. the serial monitor shows the reading but when it is meant to send the message, it shows error CMGF. Pls i need help urgently.

  8. Hi, I really enjoyed your tutorial - thanks !
    I've purchased a SIM800L with the intention of repeating your project with my Arduino. I have two questions, please.
    What regulator would you choose for use with a 'normal' 5V power supply ?
    My package came with two antenna ( I think ) - the wound bronze wire type as seen in years ur picture, plus the plug in type with the small connector. Am I right that they are alternate antennae and that the curled wire type is not as useful ?

    Many thanks,


  9. Hi sir I got a sim not registered error when i run get network status of ADAFRUIT FONA library. Can you help?

    • Hi Theresa,

      I can think of a couple of reasons for that error:

      1. The SIM might have PIN enabled. Try running AT+CPIN? If it responds with +CPIN:SIM PIN or +CPIN: SIM PUK then you might need to unlock it with the PIN or PUK.
      2. There is no 2G coverage in your area. GSM (2G) technology is currently being wiped out on some countries in favor of newer technologies. Or, the cell signal can't reach your area.

  10. Hi Roland,

    I am new to Arduino and setup the following: 2 off Ultra-sonic sensor with a DHT22. The data is uploaded to Thingspeak using ESP8266. It took me a while, but eventually got it work and have uploaded more than 15k data points. I would like to use the SIM800L module to upload the data, but have been struggling for >2 weeks just to get AT commands run successfully via the serial monitor. I read that the power supply is critical, thus I am using a "LM2596S Voltage Regulator Adj [email protected]" with 12V input and feeding the SIM800L with 4V. GND is also bridged to the Arduino board. Could you please send me a basic sketch which I can use just to check my SIM800L and SIM card. I have bought 4 off modules thus far and are really lost!!

    • Hi Kobus,

      You can try the "Sending SMS" example sketch I gave above to test your module. I also had some trouble with giving the right power to the SIM800L module. After a couple or more tries, I was finally able to run it by using a 3.7V LiPo battery. I am currently working on a project that is very similar to yours. I'll update you once it's done via email.

      • Hi Roland,

        Although I thought I was OK using the Voltage Regulator, it was only when I changed to a 3.7V Lipo battery that I managed to get it working. I ran your sketch and also a different one to use AT commands. Everything seems to be OK connecting to the internet. I managed to use manual input to update Thingspeak successfully. The challenge is to write the code to upload the sensor values automatically. Would you be prepared to assist me with the coding please?

        Best regards,

  11. Should i connect rx tx and rest of sim800l directly with arduino without divide the 5v to 3.3v ??

  12. sir im from the philippines
    i have encountered error it say in the serial monitor +CPIN: NOT INSERTED
    what could be the problem in this situation

  13. +CPIN: READY

    ---> AT+CPMS="SM","SM","SM"
    <--- ERROR
    FONA is OK
    Send to
    ganito nalabas sir

  14. Hi Roland,

    I just want to use the GSM for sending SMS. No calls or getting SMS back. Do I have to switch off these functions (with code or hardware) or can I use the GSM normally without any changings?

    I am worried about illogical conditions due to these functions which are never used. Like somebody calls this GSM and the whole system crashes because i havent catched these conditions.

    Maybe u can help me 🙂

    Many Thanks!

  15. hi sir, i am working on uno r3 with gsm sim800l i tried the code which is given above but sir i got this error

    Send to #+923483138265
    Type out one-line message (140 char): hi this is my msg
    ---> AT+CMGF=1

    > hi this is my msg

    , i dont know how to solve it so kindly guide me.

  16. Hi Roland,

    Thanks very much for your excellent tutorial!
    I am struggeling with the incoming call example as I am not able to get a response from the SIM module.
    I am using a Nano with RX-4 TX-5 RST-3 and RING connected to pin 2. The sim module gets network connectivity as it flashes every 3 seconds.

    My code looks exactly like yours, only the pins are changed:

    #include "Adafruit_FONA.h"

    #define FONA_RX 4
    #define FONA_TX 5
    #define FONA_RST 3

    #define FONA_RI_INTERRUPT 0

    SoftwareSerial fonaSS = SoftwareSerial(FONA_TX, FONA_RX);

    Adafruit_FONA fona = Adafruit_FONA(FONA_RST);

    void setup() {
    Serial.println(F("FONA incoming call example"));
    Serial.println(F("Initializing....(May take 3 seconds)"));
    fonaSS.begin(4800); // if you're using software serial
    if (! fona.begin(fonaSS)) { // can also try fona.begin(Serial1)
    Serial.println(F("Couldn't find FONA"));
    while (1);
    Serial.println(F("FONA is OK"));

    if(fona.callerIdNotification(true, FONA_RI_INTERRUPT)) {
    Serial.println(F("Caller id notification enabled."));
    else {
    Serial.println(F("Caller id notification disabled"));

    void loop(){
    char phone[32] = {0};
    Serial.print(F("Phone Number: "));

    Could you give me a hint what I did wrong?

    Kind regards,


  17. Hello there.

    I have a question. I've used the adafruit fona library and sim800l. In the code I wrote, I used incomingcallnumber, sms write, sms read codes.

    No nagging program. However when it comes to sms serial port> incoming call .. and code if (fona.incomingCallNumber (phone)) {

    It stopped at this point.

    How can I solve the problem?

  18. I am having issues with the code above. Whenever I try to send a message, it says Failed. I connected SIM800L TX to Arduino pin 3, RX to pin 2, and RST to 4. Is there something wrong with my setup? I just copied and pasted your code directly to Arduino IDE. I also have the required libraries for this setup.

  19. Hello.
    This cod:
    "Receive call" can't not run!
    Because the program stops while the program is running. So the code is breaking. How can we fix this?
    Please help.....

  20. Hi,
    My Names Supri, from Indonesia, I have jobs to make SMS Gateway with SIM800L V1.0 Module and Arduino Uno R3, but I can't understand in your sketch, how to write SMS sender address/ phone number in your sketch?

  21. Hi. I have a problem propably with serial. It shows random symbols in seral monitor. I tryed to change baudrates but it doesn't help. Do You know what can be the cause of this problem?

  22. Hello Sir, I have a problem powring my moduler i used a phone charger which output 3.7 v /355mA/1.3VA. after wiring my moduler blink every second without stopping after few minute while coding its stopped blink and get hot. whats happened did i burn it?

    • are you using 355 mA source? If you are, it's not enough to make the module operate continuously especially if it's looking for cellular signals.

  23. Hi Roland,
    First off,,Great job!
    2 questions if you wouldn't mind:
    1) when i compile your code, its uses a lot of memory ( I am using a Nano, so it used 54% of the available 2K dynamic). Is there a way to use less,, or an alternative to using the library ( or a smaller one)?
    2) I am trying to add to the code so that it will respond(turn off/on a relay; check/send status; send when status changes) to commands received from SMS messages. Any ideas on the best and easiest way to add those capabilities?

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.