Example Code for Arduino-Integrated Application-V1.0
Last revision 2026/01/24
This article guides users through the process of integrating the SIM800H GPRS shield with an Arduino UNO board. It provides step-by-step instructions for hardware and software preparation, library modifications, and includes example code to enable SMS notifications and DTMF features in embedded applications.
Hardware Preparation
Software Preparation
- Download and install the driver: Click to download driver
- Download and install the SIM800H Arduino Library: SIM800H Arduino Library
- Download and install the SIM800H Hardware Library: SIM800H Hardware Library
NOTE: SIM800H Hardware Library Due to the incoming serial data is too large, the original Arduino serial cache buffer needs to be changed to be larger, there are two ways:
- If your Arduino IDE is below 1.5.5 version, cut HardwareSerial.cpp to Arduino\hardware\arduino\cores\arduino and cover the original file.
- If it is version 1.5.5 or later, then cut the HardwareSerial.h to Arduino\hardware\arduino\cores\arduino and cover the original file.
Modify the library:
If your Arduino IDE is below 1.5.5 version, open the HardwareSerial.cpp file in the Arduino\hardware\arduino\cores\arduino, change # define SERIAL_BUFFER_SIZE 64 to # define SERIAL_BUFFER_SIZE 140;
If the version is 1.5.5 or later, open HardwareSerial.h file and do the same modifications.
NOTE: Not compatible with Arduino IDE1.6.*, Recommand Arduino IDE 1.0.6.
Steps
- Insert the SIM800H GPRS Shield onto UNO board;
- connect UNO to PC with USB cable;
- Use external power supply;
- Turn the switch to the "NONE";
- Open different sketch, select the right board "UNO" and "Srial port", upload sketch to the UNO;
- Don't forget to turn the switch to "Arduino".
- Open the sketch "Examples\sim800program\sim800test " in Arduino IDE.
//libraries
#include <sim800cmd.h>
//initialize the library instance
//fundebug is an application callback function,when someon is calling.
Sim800Cmd sim800demo(fundebug);
//return DTMF value
char rqt = 0;
//the setup routine runs once when you press reset:
void setup()
{
pinMode(13,OUTPUT);
//turn the LED off by making the voltage LOW
digitalWrite(13,LOW);
while((sim800demo.sim800init()) == 0);
delay(1000);
sim800demo.setSMSEnablePrompt(OPEN);
//enable DTMF
sim800demo.setDTMFenable(OPEN);
//registration fundebug2 function
sim800demo.setDTMFHandlefunction(fundebug2);
}
//the loop routine runs over and over again forever:
void loop()
{
//calling
if(rqt == 1)
{
rqt = 0;
sim800demo.sendTTSUCS2Compulsory("003253D1900177ED4FE1FF0C00315F00706FFF0C00305173706F",UCS2);
}
else if(rqt == '3')
{
rqt = 0;
sim800demo.sendTTSUCS2Compulsory("6B63572853D1900177ED4FE1",UCS2);
delay(2000);
sim800demo.cancelCall();
delay(2000);
sim800demo.sendSMS("00310035003900380032003300370033003100380031","4F60597DFF0C6B228FCE4F7F752800530049004D0038003000300048");
}
else if(rqt == '1')
{
rqt = 0;
digitalWrite(13,HIGH);//turn the LED off by making the voltage LOW
sim800demo.sendTTSUCS2Compulsory("706F5DF25F00",UCS2);
}
else if(rqt == '0')
{
rqt = 0;
digitalWrite(13,LOW);//turn the LED off by making the voltage LOW
sim800demo.sendTTSUCS2Compulsory("706F5DF25173",UCS2);
}
}
//application callback function
void fundebug(void)
{
rqt = 1;
sim800demo.answerTelephone();
}
//application callback function
void fundebug2(void)
{
//get DTMF data
sim800demo.getDTMFresult(&rqt);
}
Result
Initialize the SIM800H module, enable SMS notification, enable DTMF feature. If there is an incoming call, answer it and reset rqt to 1, voice broadcast, if there is any DTMF input, then assign it to rqt and then judge rqt for appropriate action.
AT command:
AT+CMGS="00310038003600310036003300360036003500340037"\r\n'
Was this article helpful?
