Get familiar with the SIM808 module by creating a car tracking system with an Arduino and GPS antenna!

In this tutorial, I will explain the SIM808 hardware interface in depth. You may have a SIM808 module that was shipped from China only to find they don’t come with any documentation or test code. This tutorial can help beginners to quickly understand SIM808 interface specifications and mechanical and electrical details. Also, I am going to add the documentation and libraries on GitHub so you will be to able design various applications quickly.

This project is a simple tracking system that uses the same GSM and GPS module that is built into the SIM808 module. At the end of this tutorial, when you text the GSM module from any phone, you will be able to get a response with the GPS location of the module depending on where it is.

What is the SIM808 Module?

Basically, the SIM808 module is designed for the global market. It is integrated with a high-performance GSM/GPRS chip, and as a bonus, it also has a GPS engine and a BT engine.

SIM808 is a quad-band GSM/GPRS module that works on frequencies GSM 850MHz, EGSM 900MHz, DCS 1800MHz, and PCS 1900MHz. It features GPRS multi-slot class 12/class 10 and supports the GPRS coding schemes CS-1, CS-2, CS-3, and CS-4. The GPS solution offers best-in-class acquisition and tracking sensitivity, time-to-first-fix (TTFF), and accuracy.

Read more about the SIM808 module here.

Benefits of the SIM808 Module

The SIM808 has 68 pins SMT pads (a single chip module which comes without soldering), which provides all hardware interfaces between the module and the user’s boards. It also has the following features:

  • One full modem serial port (UART interface)
  • Audio channels, which include a microphone input and a receiver output
  • One SIM card interface
  • Ability to support 4*4keypads by default
  • A charging interface
  • One USB, which supports debug and firmware upgrading
  • Ability to support Bluetooth function
  • Programmable general purpose input and output (GPIO)
  • Ability to support two PWMs and two ADCs
  • Integrated TCP/IP protocol and extended TCP/IP AT commands, which are very useful for data transfer applications
  • Ability to support GPS function
  • A power-saving technique the keeps the current consumption is as low as 1.2mA in sleep mode (with GPS engine powered down)
  • PCM/SPI interface

Hardware and Software Requirements

Hardware

  • SIM 808 Module 
  • Arduino UNO OR Arduino MEGA 
  • Arduino cable
  • 9V supply
  • GPS antenna and GSM antenna 


Necessary hardware

Software

Make Your Connections

Wire up everything as shown in the figures below.

  • Rx to pin 10
  • Tx to pin 11
  • Connect SIM808 with 9V adapter
  • Give the power to Arduino via USB cable or 9V charger

Connections for the Arduino UNO

Connections for the Arduino Mega

The following images show how the connections will look when wired correctly:

Upload the Source Code

Upload the following code. If you are new to Arduino, make sure to check out Maker Pro’s Arduino education page for more tutorials.

        #include <DFRobot_sim808.h>
#include <SoftwareSerial.h>
#define MESSAGE_LENGTH 160
char message[MESSAGE_LENGTH];
int messageIndex = 0;
char MESSAGE[300];
char lat[12];
char lon[12];
char wspeed[12];

char phone[16];
char datetime[24];

#define PIN_TX    10
#define PIN_RX    11
SoftwareSerial mySerial(PIN_TX,PIN_RX);
DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,

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);

  if( sim808.attachGPS())
      Serial.println("Open the GPS power success");
  else 
      Serial.println("Open the GPS power failure");
      
  Serial.println("Init Success, please send SMS message to me!");
}

void loop()
{
  //*********** Detecting unread SMS ************************
   messageIndex = sim808.isSMSunread();

   //*********** At least, there is one UNREAD SMS ***********
   if (messageIndex > 0)
   { 
      Serial.print("messageIndex: ");
      Serial.println(messageIndex);
      
      sim808.readSMS(messageIndex, message, MESSAGE_LENGTH, phone, datetime);
                 
      //***********In order not to full SIM Memory, is better to delete it**********
      sim808.deleteSMS(messageIndex);
      Serial.print("From number: ");
      Serial.println(phone);  
      Serial.print("Datetime: ");
      Serial.println(datetime);        
      Serial.print("Recieved Message: ");
      Serial.println(message); 

    while(!sim808.getGPS())
    {
      
    }

   
      Serial.print(sim808.GPSdata.year);
      Serial.print("/");
      Serial.print(sim808.GPSdata.month);
      Serial.print("/");
      Serial.print(sim808.GPSdata.day);
      Serial.print(" ");
      Serial.print(sim808.GPSdata.hour);
      Serial.print(":");
      Serial.print(sim808.GPSdata.minute);
      Serial.print(":");
      Serial.print(sim808.GPSdata.second);
      Serial.print(":");
      Serial.println(sim808.GPSdata.centisecond);
      Serial.print("latitude :");
      Serial.println(sim808.GPSdata.lat);
      Serial.print("longitude :");
      Serial.println(sim808.GPSdata.lon);
      Serial.print("speed_kph :");
      Serial.println(sim808.GPSdata.speed_kph);
      Serial.print("heading :");
      Serial.println(sim808.GPSdata.heading);
      Serial.println();
  
      float la = sim808.GPSdata.lat;
      float lo = sim808.GPSdata.lon;
      float ws = sim808.GPSdata.speed_kph;
  
      dtostrf(la, 6, 2, lat); //put float value of la into char array of lat. 6 = number of digits before decimal sign. 2 = number of digits after the decimal sign.
      dtostrf(lo, 6, 2, lon); //put float value of lo into char array of lon
      dtostrf(ws, 6, 2, wspeed);  //put float value of ws into char array of wspeed
    
      sprintf(MESSAGE, "Latitude : %s\nLongitude : %s\nWind Speed : %s kph\nMy Module Is Working. Mewan Indula Pathirage. Try With This Link.\nhttp://www.latlong.net/Show-Latitude-Longitude.html\nhttp://maps.google.com/maps?q=%s,%s\n", lat, lon, wspeed, lat, lon);
      
       Serial.println("Sim808 init success");
       Serial.println("Start to send message ...");
       Serial.println(MESSAGE);
       Serial.println(phone);
       sim808.sendSMS(phone,MESSAGE);
      //************* Turn off the GPS power ************
      sim808.detachGPS();
      
   }
}
    

Putting it all Together

After uploading the code via Arduino IDE, just open the serial monitor at 9600 baud rate. Here you will see the following:

So, whenever you send the “Hi” or “Hello” string to the number of that SIM that is already inserted in the GSM Module, Arduino will text you back with the longitude and latitude information of your module location. 

Moreover, I have already added a link to Google maps, so when it texts you back, it also comes with the Google map location as shown in the figure below:

If you need any help, please leave a comment!

Jonathan Miller
I love to explore and make things that incorporate new modules and familiar dev boards. Learning as much as I can to create things I can use!

Maker Pro Logo
Continue to site
Quote of the day

-