close
KnowledgeBase

GPS (UBLOX NEO-6M) Tracking System with GSM (SIM800C) data connectivity and Google Maps Integration

Overview

Here’s an interesting scenario. You bought something across the internet. In the midst of the waiting, you ponder “How do they track the packages?”

Usually, an online shipping company has a fleet of magicians that delivers your parcel/package. Along the way, they fight different monsters across dimensions trying to steal your package. (This is the reason the package takes too long to arrive 🙁 ) At Headquarters, they have a magic crystal ball that reveals the current location of the magicians.

I’m sorry to burst your bubble, but modern technology isn’t magic. Shipping companies employ positioning systems (GLONASS or GPS) to fetch the longitude and latitude of the object being tracked.

According to Garmin, The Global Positioning System (GPS) is a satellite-based navigation system made up of at least 24 satellites. GPS works in any weather conditions, anywhere in the world, 24 hours a day, with no subscription fees or setup charges. The U.S. Department of Defense (USDOD) originally put the satellites into orbit for military use, but they were made available for civilian use in the 1980s.

Hardware Used

Software Used

  • Arduino IDE
  • Notepad/Notepad++

Libraries Used

Application Description

Ready your Notepad !We’ll save some relevant APIs, Keys, and Links in the notepad for quick reference.

First things first, we need a map to mark our locations. Luckily, Google Maps offer these services.

Google Maps API

0. If you do not have a google account, please register here.

1.Sign in and Go to https://console.developers.google.com/cloud-resource-manager, and Create a New Project.

2. Fill in your desired relevant Project Name.

3. Open your Project by Clicking the Project Name.

 

4. In the Search Bar, Type in “Google Maps Javascript API”.

5. When the redirected website has fully loaded, Click the button “Enable”

6. After Clicking “Enable” Button, it will redirect you to an overview of the project. For now, we will just need to retrieve the Google Maps Javascript API. Simply click the “Credentials” tab.

7. Click “Create Credentials”, and Select “API Key”.

8. Copy-Paste the generated API in the handy-dandy notepad. We’ll use this in our HTML code to view the location in Google Maps.

Thingspeak

ThingSpeak is an open source Internet of Things (IoT) application and API to store and retrieve data from things using the HTTP protocol over the Internet or via a Local Area Network. ThingSpeak enables the creation of sensor logging applications, location tracking applications, and a social network of things with status updates.

  1. Create an Account, if you do not have one yet.
  2. Create a new Channel.
  3. Fill-up the blank fields. Name “Field 1” and “Field 2” as “Longitude” and “Latitude”, respectively.
  4. Save the Channel.
  5. In the overview, Click the “API Keys” tab.
  6. Note/Save the Channel ID, and READ API Keys. These will be used in the Arduino Code.

GPRS

General Packet Radio Services (GPRS) is a packet-based wireless communication service that promises data rates from 56 up to 114 Kbps and continuous connection to the Internet for mobile phone and computer users. The higher data rates allow users to take part in video conferences and interact with multimedia Web sites and similar applications using mobile handheld devices as well as notebook computers. GPRS is based on Global System for Mobile (GSM) communication and complements existing services such circuit-switched cellular phone connections and the Short Message Service (SMS).

The SIM800C Module offers the ability to send messages, calls, and internet connectivity. It is a handy module to set-up IoT on the field.

GPRS setup is pretty straightforward. You just need to know what’s you Access Point Name (APN), and  a username and password, if authentication is required.

GPS

According to physics.org, If you know how far away you are from satellite A, then you know you must be located somewhere on the red circle. If you do the same for satellites B and C, you can work out your location by seeing where the three circles intersect. This is just what your GPS receiver does, although it uses overlapping spheres rather than circles.The more satellites there are above the horizon the more accurately your GPS unit can determine where you are.

Set-up the Hardware

 

Code

Arduino Code

Serial Monitor is left on the code for debugging purposes. They can be removed in the final output to save memory.

Replace the Access Point Name (APN), and READ KEY API with yours.

 

HTML Code

We will neede a bit of HTML to view the GPS location in Google Maps.

Copy to Notepad, Replace GOOGLE MAPS API, CHANNEL ID, and READ API KEYs.Afterwards, save the file as Index.html (Or anyname.html).

 

Code Breakdown

These constant variables will be used for the GSM module to connect to the internet. Replace the placeholders with the correct information.

As the name implies, these are char buffers to store float (latitude and longitude). Arduino does not support ‘%f‘ in sprintf function.

The For loop is simply a timer block. When a second passes, it checks for the latitude and longitude of the GPS.

Simply substitutes the %s in the resource variable (“https://api.thingspeak.com/update?api_key=YOUR_READ_KEYI_HERE&field1=%s&field2=%s) .

We need to convert the float (latitude and longitude) variables to char so that it can be substituted to the resource variable.The parameters for dtostrf() are :

Conclusion

Integrating different modules can be rewarding, and satisfying. It enables the creative enthusiasts to reach greater functionality, and broadens the horizon for innovation. The GPS alone is a formidable device. When integrated with internet connectivity, it can be used for numerous applications : Navigation(such as Road navigations), and Tracking (such as Wildlife).

References

https://github.com/iobridge/thingspeak/blob/master/

http://www.physics.org/article-questions.asp?id=55

http://iotmonk.com/lessons/programming-esp12e-nodemcu-module-upload-gps-data-thingspeak/

Tags : Google MapsGPRSGPSGPS TrackerGSM/GPRS

Leave a Response