Usage Example for Arduino-Send SMS Messages

Last revision 2026/01/15

This article presents a detailed usage example for sending SMS messages with Arduino, guiding readers through the hardware and software setup, step-by-step procedures, and providing sample code for implementation using the SIM808 Expansion Shield.

Hardware Preparation

Software Preparation

Steps

  1. Insert a SIM card in to the SIM slot on the SIM808 expansion shield

  2. Stack the expansion shield on to an Arduino UNO

  3. Connect an external power source to the Arduino

  4. Set the function switch to None

  5. Upload the sample code

  6. Set the function switch to Arduino and make sure SIM808 could communicate with Arduino board

  7. Press the Boot power button

  8. Wait for the SIM card to register the network, the Net indicator LED will slowly flash every 3 seconds

  9. Open the SIM808_SendSMS example or copy the code to your project

  10. Input your SIM's phone number in the line:#define PHONE_NUMBER "187*******39"

  11. Set the function switch to Arduino

Sample Code


  #include <DFRobot_sim808.h>

 //Mobile phone number, need to change
  #define PHONE_NUMBER "187*******39"

  //The content of messages sent
  #define MESSAGE  "hello,world"

  DFRobot_SIM808 sim808(&Serial);

  void setup() {
    //mySerial.begin(9600);
    Serial.begin(9600);

   //******** Initialize sim808 module *************
    while(!sim808.init()) {
        delay(1000);
        Serial.print("Sim808 init error\r\n");
    }
    Serial.println("Sim808 init success");
    Serial.println("Start to send message ...");

    //******** define phone number and text **********
    sim808.sendSMS(PHONE_NUMBER,MESSAGE);
  }

  void loop() {
    //nothing to do
  }

Was this article helpful?

TOP