Introduction: Arduino OBD2


It's a project to find out the road speed with the Arduino with the help of OBDII and GPS. And that your speed does not exceed the speed of the road and warns when driving. Jeddah coordinates are recorded, to know the speed of the road and display it on the screen while driving.


  • Arduino
  • HC05 Bluetooth Module
  • GPS
  • SD Card Module
  • Nextion


What is Arduino?

The Arduino Uno is an open-source microcontroller board based on the Microchip ATmega328P microcontroller and developed by Arduino. The board is equipped with sets of digital and analog input/output (I/O) pins that may be interfaced to various expansion boards (shields) and other circuits. The board has 14 digital I/O pins (six capable of PWM output), 6 analog I/O pins, and is programmable with the Arduino IDE (Integrated Development Environment), via a type B USB cable. It can be powered by the USB cable or by an external 9-volt battery, though it accepts voltages between 7 and 20 volts. It is similar to the Arduino Nano and Leonardo. The hardware reference design is distributed under a Creative Commons Attribution-Share-Alike 2.5 license and is available on the Arduino website. Layout and production files for some versions of the hardware are also available.

What is OBD?

OBD Communication protocols used in modern vehicles are incompatible with standard computer protocols. An OBD adapter (sometimes referred to as “vehicle interface adapter”) is an electronic device that allows a computer to access the vehicle network. It is similar in operation to a computer modem or a gateway, in that it translates messages from one protocol to another.

What is Bluetooth?
HC-05 Bluetooth Module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed for transparent wireless serial connection setup. HC-05 Bluetooth module provides switching mode between master and slave mode which means it able to use neither receiving nor transmitting data.

What is SD Card Module?
The SD Card Module is a simple solution for transferring data to and from a standard SD card. The pinout is directly compatible with Arduino, but can also be used with other microcontrollers. This module has SPI interface which is compatible with any sd card and it use 5V or 3.3V power supply which is compatible with Arduino UNO/Mega.SD module has various applications such as data logger, audio, video, graphics.

What is GPS?
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.

What is Nextion?

Nextion is a seamless Human Machine Interface (HMI) solution that provides a control and visualisation interface between a human and a process, machine, application or appliance.

Step 1: Coordinates and Excel Sheet

Record coordinates with Maps by taking longitude and latitude. And then record the speed of the path through the site (Maxspeed). And to ensure the speed of the road to be accurate. And then record the points of longitude and latitude with the speed of the road in Excel Sheet.

Step 2: How to Install an OBD2 Device

This picture will help you easily find the OBD2 device port for your vehicle. All 1996 and newer passenger vehicles have the port you are looking for.

Step 3: HC05 Bluetooth Module

HC05 Bluetooth Setup

  • HC05 will be the Master, ELM327 will be the Slave.
  • Hold Button before power up to force HC05 into AT command mode.
  • Open Serial Monitor or Hyper terminal to COM Port.
  • AT Commands to set up HC05 to connect permanently to ELM327:
  2. AT+ORGL (Set to original)
  3. AT+ROLE=1 (Set to Master)
  4. AT+CMODE=0 (Set connect to a specific address)
  5. AT+BIND=1234,56,789c72
  6. AT+INIT (Need to connect)
  7. AT+PAIR=1234,56,789c72,20 (20 means 20 second timeout)
  8. AT+LINK=1234,56,789c72

Step 4: SD Card Module

SD Card Module setup

The first step when using the SD card module with Arduino is formatting the SD card as FAT16 or FAT32. Follow the instructions below.

  • To format the SD card, insert it in your computer. Go to My Computer and right click on the SD card. Select Format.
  • A new window pops up. Select FAT32, press Start to initialize the formatting process.

Read and write to the SD card

The SD library provides useful functions for easily write in and read from the SD card. To write and read from the SD card, first you need to include the SPI and SD libraries.


 #include <SD.h>
 #include <SPI.h>
 File myfile;
 void setup () {
 Serial.begin (115200);
 while (!Serial) {
 Serial.print ("Initializing SD Card...");
 if(! SD.begin (4) ){
 Serial.println (" Initialization failed!");
 Serial.println (" Initialization done"); ("file.csv");
 if (myfile) {
 Serial.println ("arduino. txt:");
 while (myfile. available ()){
   Serial.write (myfile. read ());
 myfile.close ();
           Serial.println("error opening arduino.txt");

 void loop () {

Step 5: GPS Module

How GPS works

GPS satellites circle the Earth twice a day in a precise orbit. Each satellite transmits a unique signal and orbital parameters that allow GPS devices to decode and compute the precise location of the satellite. GPS receivers use this information and trilateration to calculate a user's exact location. Essentially, the GPS receiver measures the distance to each satellite by the amount of time it takes to receive a transmitted signal. With distance measurements from a few more satellites, the receiver can determine a user's position and display it.

To calculate your 2-D position (latitude and longitude) and track movement, a GPS receiver must be locked on to the signal of at least 3 satellites. With 4 or more satellites in view, the receiver can determine your 3-D position (latitude, longitude and altitude). Generally, a GPS receiver will track 8 or more satellites, but that depends on the time of day and where you are on the earth.

Once your position has been determined, the GPS unit can calculate other information, such as:

  • Speed
  • Bearing
  • Track
  • Trip dist
  • Distance to destination

Step 6: Connections

Step 7: Working

When driving the car, the Arduino takes the car's speed from OBDII, takes the coordinates from the GPS, reads the Excel sheet from the SD card module, And compares the car's speed, the coordinates, and the road speed recorded in the excel sheet, And it displays it on the screen.

Step 8: Design

Step 9: Thank You Dr. Jaber

Dr. Jaber Al Yamany, Thank you for the project idea, support, follow-up, Thank you for everything.