SIM808_with_Leonardo_mainboard_SKU_DFR0355-DFRobot

Introduction

SIM808 with Leonardo mainboard is the latest Arduino card developed for multi-purpose by DFRobot. The SIM808 module onboard is an integrated quad-band GSM/GPRS and GPS satellite navigation technology module. 4-layer PCB design makes the powerful card into an UNO size, this can saves time and cost for you.

This SIM808 we chosen is the latest version, compared with the existing SIM808 module on the market, the new module has a better stability. However, you may have to pay attention that the AT command of the GPS is not compatible with the old version of the SIM808 module.

Applications: GPRS network nodes, remote communications, GPS positioning and monitoring in real time, the Internet of things(IoT).

Specification

Board Overview

- DFR0355PinOutOverall.png

Num Label Description
1 RESET Reset Leonardo MCU
2 USB Connect with PC via Arduino USB port
3 Net SIM808 network indicator
Quick flashing: Finding Network
Slow flashing(every 3 seconds): Registered to the network
OFF: SIM808 chip is not powered on(Button: BOOT)
4 GSM GSM/GPRS Antenna Connector
5 GPS GPS Antenna Connector
6 RX/TX Serial Port indicator: Rx: Will flash if data received Tx: Will flash if data sent
7 7-23V External power supply jack, 7-23V DC
8 BAT 3.7V li-battery power supply connector Available here
*9 BOOT SIM808 Switch: Turn SIM808 module ON/OFF
10 Red jack Arduino standard power pins
11 Blue jack Arduino standard analog pins
*12 NO BAT? Switch for Li-battery power supply
13 Headphone jack Suggested Shopping
14 JP2 RI/DTR control pin of SIM808 module, see below for more info
15 ICSP Arduino ICSP interface
16 MIC Onboard Microphone
*17 MIC jack External microphone jack
18 green jack Arduino standard digital pins

warning_yellow.png *12 Battery Usage:

About JP2


Description on back view

Connect RI with D8 with a Jumper

This port gets the working state of the board in code. By connecting the Arduino digital pins to DTR or RI, you can read the text info on the board's back. e.g. If I connect D8 to RI, then I could know RI pin state by writing this line in code:

   RI_state = digitalRead(8);
// remember the setup(): pinMode(8, INPUT);

1. DTR Description


DTR - Data terminal ready. The user can control the SIM808 module to enter or exit sleep mode(AT+CSCLK=1) by DTR signal or by pulling down the DTR pin. The serial port will become active after the DTR pin is pulled to LOW for 50ms.

2. RI Description


RI - Ring Indicator. The behavior of the RI pin is shown in the following table when the module is used as a receiver:

The behaviors of the RI

** Table: RI Description**

State RI response
Standby HIGH
Voice Call The pin is changed to LOW. When any of the following events occur, the pin will be changed to HIGH:
-Establish the call
- Hang up the call
Data Call The pin is changed to LOW. When any of the following events occur, the pin will be HIGH:
- Call established
- Call hang up
SMS The pin is changed to LOW, and kept low for 120ms when a SMS is received. Then it is changed to HIGH.
URC The pin is changed to LOW, and kept low for 120ms when some URCs are reported. Then it is changed to HIGH. For more details, please refer to SIM808_Hardware Design_V1.00.

Power Saving Mode

The user can control the SIM808 module to enter or exit sleep mode (AT+CSCLK=1) by DTR signal. When DTR is high level and without interrupt (on air and hardware such as GPIO interrupt or data in serial port), SIM808 will enter sleep mode automatically. In this mode, SIM808 can still receive paging or SMS messages from the network but the serial port is not accessible.

NOTE: The user must shut off the power supply of GPS, and then the AT commands about the power saving mode can be executed correctly, and current consumption will be lower.

Function Mode

There are three functionality modes, which are set by the AT command AT+CFUN=\. The command provides the choice of the functionality levels \=0, 1, 4.

level Description Current consumption(uA)
AT+CFUN=0 minimum functionality. 869.5
AT+CFUN=1 full functionality (default). 1400
AT+CFUN=4 flight mode (disable RF function). 922.5

Current consumption of function modes

Minimum functionality mode minimizes the current consumption to the lowest level. If SIM808 is set to minimum functionality by AT+CFUN=0, the RF function and SIM card function will be disabled. In this case, the serial port is still accessible, but all AT commands correlated with RF function and SIM card function will not be accessible.

Sleep Mode (AT+CSCLK=1)

When the GPS function is shut off, the user can control SIM808 module to enter or exit the sleep mode (AT+CSCLK=1) by DTR signal. When DTR is in high level and without interrupt (on air and hardware such as GPIO interrupt or data in serial port), SIM808 will enter sleep mode automatically. In this mode, SIM808 can still receive paging or SMS messages from the network, but the serial port is not accessible.

NOTE: For SIM808, it requests to set AT command: AT+CSCLK=1 and ensure DTR at high level to enable the sleep mode; the default value is 0, which can not make the module to enter sleep mode.

Wake SIM808 from Sleep Mode

When SIM808 is in sleep mode (AT+CSCLK=1), the following methods can wake it:

Charge Li-Battery with the Board

SIM808 includes an integrated charging circuit for Li-Ion batteries which makes it very convenient for any user applications that support battery charging. The maximum charge current is 1A. The following steps walk you through how to use this feature:

  1. Remove the jumper Cap from "NO BAT?"
  2. Connect a 3.7V lithium battery to the BAT interface
  3. Connect the mainboard to your computer via a USB cable and download the debugging code
  4. Short press button BOOT to boot the module
  5. Send command AT+ECHARGE=1 through serial Assistant/Arduino Serial Monitor to set the module into charging mode. (Port setting: Carriage return, Baud Rate: 115200)
  6. Connect an external DC power supply 7-23V to VIN power interface. If it fails to register, disconnect and reinsert it.

After the five steps above, you can query the battery and charging status by sending AT+CBC.

For more details please refer to the AT instruction manual (Bottom of this page > "More").

Interfacing with SIM808 via USB port/AT Commands

In this section we will do some basic tasks on the board via AT commands. More AT command can be found at the end of the page @ More> Document> AT commands.

Note: SIM808 mainboard is using Arduino Leonardo. This microcontroller has two serial ports. Serial0 (Serial) is used to communicated with USB port; Serial1 is used to communicated with SIM808 GSM module.

Since USB port does not directly connect to the SIM808 port. We need upload a debug code to setup the communication

DFR0355 communication mechanism

/*
 * The sketch here will make Leonardo exchange
 * data between the USB serial port and SIM808 module.
*/

void setup() {
  Serial.begin(115200); //initialize Serial(i.e. USB port)
  Serial1.begin(115200); //initialize Serial1
}

void loop() {
  //If Serial1 receive data, print out to Serial
  while (Serial1.available()) {
    Serial.write(Serial1.read());
  }
  //If Serial receive data, print out to Serial1
  while (Serial.available()) {
    Serial1.write(Serial.read());
  }
  delay(1);  //delay for a short time to
  // avoid unstable USB communication
}

Requirements

Hardware Software Optional:
SIM808 with Leonardo mainboard x1
GSM & GPS Antennas (Included) x1
External power supply (7-23V, DC) x1
SIM card (GSM/GPRS) x1
Micro USB Cablex1
Coolterm or DF Serial Debugger by Lisper, we use the second one in the wiki.
Arduino IDE V1.5.* Click to Download Arduino IDE
3.7V Lithium Battery x1
Smartphone Headset to PC Adapter x1
Earphone x1

Commissioning

Shown as Leonardo in Device manager

  1. Install the SIM card in the sim slot on the back of the board
    • Make sure your SIM card is available, and you can put the SIM card into the socket or get it out by sliding the metal lock.
  2. Install the GPS & GSM antennas on the board
  3. Connect with PC and power supply
    • There are three ways to supply the power:
      1. Through 7~23V power supply jack
      2. Through VIN pin on board
      3. Remove the jumper on NO BAT?, and connect a 3.7V Lithium Battery to BAT jack
    • After connecting the board to PC by an USB cable, the board shows up as Leonardo automatically if you have installed the Arduino by .exe file, or you will need to install the driver manually
  4. BOOT SIM808 by pressing the BOOT white button for 2 seconds if the NET indicator LED is OFF.
  5. Upload the Debugging Code above to Leonardo.

Make a Call

Please choose the board and serial port for the main board, then open your Arduino Serial Monitor, and choose Baud Rate@ 115200, Format@ Carriage Return, you can also use other software or even wireless module.

- <File:DFR0355> serial monitor in Arduino IDE.png

  1. Send AT to enter AT mode, you will get OK, or please check the serial monitor setting or if the NET led is flashing every 3 seconds.
  2. Send ATD170****9217; to make a call, do not forget the ";" in the end;
  3. If accepted, you will see OK.
  4. If rejected, you will see NO CARRIER.

- <File:DFR0355> make a call.png

Answer/Reject an Incoming Call

  1. If there is an incoming call, serial port 1 will receive the message
  2. The number can be displayed if your SIM card has this function
  3. Send ATA to answer the call
  4. Send ATH to reject the call

- <File:DFR0355> answer call.png

Send a Message

We recommend using DF Serial Debugger because when you are going to send the message, you have to send 0x1A in HEX. The DF Serial Debugger can send data in HEX while the Arduino IDE can't.

NOTE: Do NOT tick the checkbox hex until Step 4 which is to send 0x1A in HEX.

Received the message

- Open DF Serial Debugger and copy the settings according to the image below. If you cannot open the port, please check if the port is occupied by the Arduino IDE serial monitor.

  1. Send AT+CMGF=1 to set the SMS in text format. You will get OK
  2. Send AT+CMGS="170****9217" to set the receiver number. You will see a notation >
  3. Write the content of the message
  4. Send 1A(HEX) as an end to send the message
  5. You will get OK, and the message will be sent

:AT command, SMS

Read a Message

  1. Send a message to the SIM card on the module, I sent test! here
  2. The serial monitor will print a message +SMTI: "SM",1, and 1 shows the number of the message
  3. Send AT+CMGR=1 to read the message of 1. The message "Test!" should display

- DFR0355_read_sms.png

NOTE: If the text is unreadable, please set the message in TEXT by AT+CMGF=1.

TCP Communication

In order to do this you may first need to know how to get an available site's IP address. Follow these steps to do so:

  1. Press Windows+r, type cmd, click OK.
  2. Type a site and press Enter. e.g.www.baidu.com
  3. You will get some info including the IP address. e.g. 115.239.211.112

- <File:get> ip address by ping in windows.png

Once you are able to do this you can continue:

NOTE: Do NOT tick the checkbox hex until Step 4 which is to send 0x1A in HEX.

  1. Send AT+CIPSTART="TCP","115.239.211.112","80", and you receive OK. After a while, you should see CONNECT OK. If it failed to connect, try a more common website, or powercycle the SIM808 module to reboot
  2. Send AT+CIPSEND to get the permission to send data to the site
  3. After you get a notation >, you can send your message
  4. Send 0x1A in HEX as an end, after a while, if the site received your data, you will see SEND OK
  5. After a while, the connection with the site will break off automatically if no more data is transmitted. You can also send AT+CIPCLOSE to break the connection.

- <File:DFR0355> TCP Communication.png

GPS Feature

We recommend using this feature outside for best perfomance.

  1. Send AT+CGNSPWR=1, the serial monitor will confirm with OK immediately
  2. Send AT+CGNSTST=1, the serial monitor will confirm with OK

The module should then start displaying GPS location data.

- File: DFR0355 gps at command.png

NOTE: To get GPS position data, the module should be placed outside. Here, we did the it inside in order to demonstrate the AT commands.

Read: The raw GPS data from the serial is in the form: DDmm.mmmmm. e.g. If the raw information is: 5320.12345, then it is: 53 degress and 20.12345 minutes. In order to convert to decimal coordinates you need to divide the minutes by 60. i.e. 20.12345/60 = 0.33539. So the decimal result is 53.33539.

Drive SIM808 via Library

Download the SIM808 library and install it to Arduino-1.5.*\libraries instead of Documents\Arduino\Library!

Library should be in the Arduino **installation folder**

NOTE: You have to use Arduino V1.5.*;
The library should be placed at Arduino1.5.*\libraries, the Arduino Installation directory.
The SIM808 module initialization part has been completed in the library, it doesn't require the user to initialize the module
In the debugDF.h file under the \SIM808\src folder, modifing the relevant macro definitions can print a debugging message via USB port

-

Open Arduino V1.5.*, and you will find the sample sketch in the examples menu, upload it according to your needs, and please note that we will use Newline and a baudrate of 9600 in this section .

- settings_Arduino_newline_9600.png

Make Voice Call

Steps:

  1. Open the serial monitor, you will get a ready notice
  2. Send the number. e.g. 1709***9217. If the number is incorrect, you will receive a warning
  3. If the call is answered, the monitor will print text like lable 3
  4. If the call is rejected, the monitor will print text like lable 4
    • You can send a Newline character to hang up, i.e.
      1. \n in code
      2. Do NOT type anything and click Send/ press Enter on your keyboard in serial monitor
    • If you close the serial monitor and open it again, you will not see any information in the window but it will still be waiting for you to input a number to call. This is because the code runs the setup() only once.

- DFR0355_notice_call_failed.png

NOTE:
Make sure you have prepared everything ready to go, i.e. the NET led is flashing properly, please check the chapter above.
The first time you open the serial monitor after uploading the sketch, the SIM808 module would reboot automatically whether the previous NET state is ON or OFF, and after about 1 minute, the Not connected message will disappear. If not, you can press BOOT button on board to BOOT it manually.

Function Explanation:

Receive a Voice Call

Steps:

  1. Make a call to the SIM card on the module after you got the message Waiting for a call
  2. The module would answer the coming call automatically, and you will get the message
  3. You can send a Newline to hang up

- File: DFR0355 answer a call.png

Function Explanation:

Send SMS

Received the test message\!

Steps:

  1. Send the receiver number after you see the message GSM initialized
  2. Send a message after you see the message Now, enter SMS...
  3. After a while the receiver will receive the message

- <File:DFR0355> send sms serial sender.png

Function Explanation:

GPS TCP

The GPS feature should be used outside, here we used it just for an explanation of the library.

Steps:

  1. Find an available server and get the following settings information: (Here, we just show it as an example which doesn't work)
    • char tcpip[]="\"TCP\",\"183.230.40.39\",\"876\"";
    • char datastreams_id[]="GPS Data";
    • char device_id[]="135506";
    • char api_key[] ="Qjvc7i1UwteNzL1jOGZ8VsVJ04gA";
  2. Upload the sketch and open the serial monitor, wait until the module initialization finished
  3. Then it will get the state if there is any available GPS data. If it is avaible, then the data will be sent to the server

- <File:DFR0355> GPS TCP serial.png

Function Explanation:

FAQ

For Q1
Q1 I noticed that on the mainboard, you designed the antenna for the bluetooth2.0. But I didn't find any description about it, is it available, if so how to use it? It is very useful to me!
A Welcome! It is designed for BT feature of SIM800 module as you said. However, the newest chip SIM800 is not stable when using BT, the firmware would become defective or even lost. So it is not available on this module so far. If you need use bluetooth, we suggest to buy BT module or better BLE module, Bluno is one of the popular BLE cards, you can have a look.
Any question and more cool ideas to share, please visit DFRobot Forum

More Documentation