Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

How to build a real-time vehicle tracking system

By Nikhil Agnihotri March 31, 2024

A vehicle tracking system is a technology that tracks and monitors a vehicle’s location in real time. It uses the Global Navigation Satellite System (GNSS) — typically, the Global Positioning System (GPS) — to accurately determine a vehicle’s location. The GPS monitors and relays data to a server through a cellular or satellite network. 

In this project, we’ll design a vehicle tracking system using Arduino, SIM900A GSM/GPRS modem, and the Neo 6M GPS module. The device will transmit a vehicle’s real-time location using the ThingSpeak server. ThingSpeak is a popular Internet-of-Things (IoT) development platform. 

The Neo-6M GPS module tracks the vehicle’s location and transmits it to the ThingSpeak server via an HTTP post using GPRS communication over the SIM900A modem. 

Components 

  1. Arduino Mega x1
  2. SIM900A GSM/GPRS Modem x1
  3. Neo-6M GPS module
  4. SIM card
  5. Connecting wires or Jumper wires 

Circuit connections
To build this vehicle tracking device, we must interface the SIM900A GSM/GPRS modem and Neo-6M GPS module with Arduino. We use Arduino Mega because it has multiple hardware UART (universal asynchronous receiver/transmitter) ports, but any Arduino board will work. Depending on the board, you might have to use the software serial. 

To interface the GPS module with Arduino Mega:

  • Connect the GPS’s VCC and ground pins with Arduino’s 5V out and ground pins. 
  • Connect the GPS’s TX and RX with Arduino’s RX1 and TX1, respectively. 

To interface the GSM/GPRS modem with Arduino:

  • Connect the GSM/GPRS’s GND, TX, and RX pins with Arduino’s GND, RX2, and Tx2 pins, respectively. 

Then, power the GSM-GPRS modem through an adaptor. Note: a regulated battery supply can power the complete circuit. 

Create a ThingSpeak account
We’ll use the ThingSpeak server to communicate data with Arduino. ThingSpeak is an open-source IoT analytics platform service. First, you must create an account on the platform by going to ThingSpeak.com. Click on the user icon at the top right corner and then click on the ‘Create One’ link. Fill out the form and verify your email ID to complete the account.

Create a ThingSpeak channel
Now, we must create a channel to communicate with the ThingSpeak server. Channels are where applications store and retrieve data on the ThingSpeak server. 

To create a channel, click the ‘New Channel’ button and fill in the form. Enter a name for your channel, such as ‘GSM-GPS-Vehicle-Tracking.’ Next, create two fields: 

1. ‘Latitude’ to store the latitude of the vehicle’s location.
2. ‘Longitude’ to store the longitude of the vehicle’s location. 

Click on the ‘Save Channel’ button to create the channel.

After creating the channel, navigate to ‘Channel Settings’ and write down the channel ID. Also, click on the ‘API Keys’ tab and note down the ‘Write API Key.’ We’ll be using them in the Arduino sketch.

Arduino sketch
Upload the following sketch to Arduino. Remember to replace your write API key in the sketch.

<ADD CODE HERE>

How it works
Arduino retrieves a vehicle’s current location using the GPS module. The board stores the latitude and longitude of the current location and transmits them to the ThingSpeak server using the GSM network via the SIM900A modem. The modem generates an HTTP post for the address of the ThingSpeak server to transmit the vehicle’s location data. It’s uniquely identified by the write API key.  

The code
The sketch begins by importing the TinyGPSPlus library, which works with the GPS module. An object of the TinyGPSPlus class is instantiated. Variables are declared to store the latitude and longitude of the vehicle’s location, to transmit a message to the ThingSpeak server, and to format the vehicle’s latitude and longitude values.

The setup() function sets the baud rate for Serial, Serial1, and Serial2 UART channels to 9600 bps. The Serial port is used to debug the console. Serial1 communicates with the GPS module, and Serial2 communicates with the GSM-GPRS modem. 

The user-defined function SendATCommand() transmits the AT commands to the SIM900A GSM modem. The user-defined function UpdateLocation() sends the vehicle’s location data to the ThingSpeak server through GPRS technology. 

Note that the APN used in this function is airtelgprs.com as we’re using an Airtel SIM. If you use a different network provider, its APN will be different. Also, remember to replace the API key in the code for your ThingSpeak channel. 

In the loop() function, Arduino retrieves the latitude and longitude of vehicle’s current location by calling the gps.location.lat() and gps.location.lng() methods. The latitude and longitude values are formatted using the dtostrf() function. The values are updated into the global variables, ‘lat’ and ‘lng’, which are transmitted to the ThingSpeak server using the UpdateLocation() function.

Results
Here’s a screenshot of the console messages of Arduino’s Serial Monitor retrieving the location data and transmitting it to the ThingSpeak server.

The following screenshot is of live vehicle location data on the ThingSpeak server.

 

 

You may also like:


  • What are Global Navigation Satellite Systems (GNSS) and how are…

  • What role do automotive sensors play in modern vehicles?

  • What are the communication protocols in electric vehicles?

  • What are the top GPS tracker chips of 2023?

  • What is a Global Positioning System (GPS)?
  • ESP32 voice-operated home automation
    ESP32 voice-operated home automation with ThingSpeak MQTT, IFTTT and Google…

Filed Under: Electronic Projects
Tagged With: Arduino, electronicproject, gprs, gps, gsm, modem, monitoring, tracking, vehicletracking
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: 5G Technology
This Tech Toolbox covers the basics of 5G technology plus a story about how engineers designed and built a prototype DSL router mostly from old cellphone parts. Download this first 5G/wired/wireless communications Tech Toolbox to learn more!

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Right Half Plane Zero
  • dc-dc converter in series
  • Single ended measuring ports and balanced antenna
  • Thermal modelling of repetitive power pulse
  • Permittivity and Permealibility in CST

RSS Electro-Tech-Online.com Discussions

  • Fun with AI and swordfish basic
  • Microinverters and storeage batteries?
  • FFC connector white
  • Is AI making embedded software developers more productive?
  • Can I make two inputs from one??

Featured – LoRa/LoRaWan Series

  • What is the LoRaWAN network and how does it work?
  • Understanding LoRa architecture: nodes, gateways, and servers
  • Revolutionizing RF: LoRa applications and advantages
  • How to build a LoRa gateway using Raspberry Pi
  • How LoRa enables long-range communication
  • How communication works between two LoRa end-node devices

Recent Articles

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe