Usage Example for Arduino-Auto Answering Phone Calls and Reading SMS Messages
Last revision 2026/01/15
Explore the functionality of Arduino with DFRobot_SIM808 Shield, focusing on auto answering phone calls and reading SMS messages, enhancing communication capabilities for electronics projects.
Hardware Preparation
- DFR0181 Arduino UNO x1
- TEL0097 SIM808 Expansion Shield x1
- External Power Supply x1
- SIM Card x1
Software Preparation
-
Download and install the Arduino IDE: Click to download Arduino IDE
-
Download DFRobot_SIM808 library Click to Download DFRobot_SIM808 library
Steps
-
Insert a SIM card in to the SIM slot on the SIM808 expansion shield
-
Stack the expansion shield on to an Arduino UNO
-
Connect an external power source to the Arduino
-
Set the function switch to
None -
Upload the sample code
-
Set the function switch to
Arduinoand make sure SIM808 could communicate with Arduino board -
Press the Boot power button
-
Wait for the SIM card to register the network, the Net indicator LED will slowly flash every 3 seconds
-
Open the
SIM808_LoopHandleexample or copy the code to your project -
Download and set the function switch to
Arduino -
The shield will auto-answer phone calls or send SMS Messages to the serial terminal
Sample Code
#include <DFRobot_sim808.h>
#define MESSAGE_LENGTH 20
char gprsBuffer[64];
char *s = NULL;
DFRobot_SIM808 sim808(&Serial);
void setup() {
//mySerial.begin(9600);
Serial.begin(9600);
//******** Initialize sim808 module *************
while(!sim808.init()) {
Serial.print("Sim808 init error\r\n");
delay(1000);
}
delay(3000);
Serial.println("Init Success, please call or send SMS message to me!");
}
void loop() {
//******** Wait serial data *************
if(sim808.readable()){
sim808_read_buffer(gprsBuffer,32,DEFAULT_TIMEOUT);
//Serial.print(gprsBuffer);
//************** Detect the current state of the telephone or SMS ************************
if(NULL != strstr(gprsBuffer,"RING")) {
sim808.answer();
}else if(NULL != (s = strstr(gprsBuffer,"+CMTI: \"SM\""))) { //SMS: $$+CMTI: "SM",24$$
char message[MESSAGE_LENGTH];
int messageIndex = atoi(s+12);
sim808.readSMS(messageIndex, message,MESSAGE_LENGTH);
Serial.print("Recv Message: ");
Serial.println(message);
}
sim808_clean_buffer(gprsBuffer,32);
}
}
Was this article helpful?
