Build an Arduino GPS Speedometer using OLED

Sourced original idea via Circuit Digest.

Analog and digital speedometers are great tools to measure how fast a vehicle is going. However, GPS speedometers can offer much more accuracy. GPS technology is the most widely used technology for navigation and promises better access to data than any other available tools. If you are into GPS technology, you will find this tutorial both fun and useful. We will walk you through a simple process for building a DIY Arduino GPS speedometer using OLED.

Step 1: Gather the components

For this project, you’ll need:

Before we get into the process, let’s have a thorough understanding of some of these components.

NE06M GPS Module

The NEO6M GPS module is an excellent choice for this project as it comes with a ceramic antenna which is famous for its strong search capability. The module’s receiver has a strong capacity for detecting locations and it can track more than 22 satellites around the world. The module comes with additional useful features including an on-board signal indicator that will help you track the network status of the module, and a backup battery that allows the module to save backups when the power shuts out.

The NEO6M GPS chip can track various satellites on 50 channels with an impressive sensitivity level of around -161 dBm. The module’s 50-channel has a u-blox 6 positioning engine that comes with a Time-To-First-Fix of under 1 second.

Below are some of the chip’s most prominent features:

  • Operating current: 67 mA
  • Interface: UART
  • Operating Voltage: (2.7-3.6)V DC
  • Baud rate: 4800-230400 bps (9600 default)
  • Communication protocol: NEMA
  • Built-in EEPROM
  • External antenna

Pinout (GPS module)

  • VCC: Input voltage of the pin
  • RX, TX: UART communication pins (with Microcontroller)
  • GND: Ground pin

1.3 12C OLED display

The second important component in this project is the OLED (Organic Light Emitting Diode). It uses the same underlying technology as in many television sets but has fewer pixels. This project uses a Monochrome 4-pin SH1106 OLED 1.28 OLED display.

Note: This display only works with 12C mode.

The display offers the following prominent features:

  • Resolution: 128*64
  • Input Voltage: 3.3V-5V DC
  • Driver IC: SH1106
  • Interface: 12C
  • Viewing angle: greater than 160 degree
  • Current consumption: 8mA
  • Pixel color: Blue

Pin description for the device:

  • VCC: 3.3-5v dc INPUT POWER SUPPLY
  • GND: Ground pin
  • SCL: 12C interface clock pin
  • SDA: 12C serial data pin

Step 2: Install the right libraries

This project uses this library from the Arduino community.

Step 3: Connect everything according to the circuit diagram

Your complete project should look something like this:

Step 4: Program Arduino for the speedometer

  1. Get started by including all the libraries. In this tutorial, we are using the TinyGPS++.h library to fetch GPS coordinates using the receiver module and Adafruit_SH1106.h for the OLED.
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <Wire.h>
#include <Adafruit_SH1106.h>
  1. In this step, define the OLED 12C address. This can be either OX3D or OX3C. In this project, it is OX3C.
  2. Next, define the reset pin of the OLED. Here it is:
#define OLED_ADDRESS   0x3C
#define OLED_RESET -1
Adafruit_SH1106 display(OLED_RESET);
  1. Define the objects for Softwareserial and TinyGPSPlus. The serial class of the software needs the Arduino PIN for communication. These are defined as 2 and 3 in the following code:
int RX = 2, TX = 3;
TinyGPSPlus gps;
SoftwareSerial gpssoft(RX, TX);
  1. Define the baud rate as 9600 as shown in the code below. The SH1106_SWITCHCAPVCC will display 3.3V internally and use display.begin will initialize the display.
void setup()
{
Serial.begin(9600);
gpssoft.begin(9600);
display.begin(SH1106_SWITCHCAPVCC, OLED_ADDRESS);
display.clearDisplay();
}
  1. Inside the while true loop, the serial data will be validated. If the data is valid it would indicate that the GPS signals are received, Next, see the code below for displayspeed().
while (gpssoft.available() > 0)
if (gps.encode(gpssoft.read()))
displayspeed();

Next, you will check the speed data through GPS.speed.isValid(). If the result returns true, the speed value will be displayed on the OLED display. Here define the text size with the display.setTextSize function, and define cursor position with display.setCursor function. The speed data can be decoded through GPS.speed.kmph() and displayed through a display.display() function.

if (gps.speed.isValid())
{
display.setTextSize(2);
display.setCursor(40, 40);
display.print(gps.speed.kmph());
display.display();
}
  1. For the final step, upload this code in Arduino Uno and you should be able to see the speed on the display. See the image below.

Here’s the complete code for the project:

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <Wire.h>
#include <Adafruit_SH1106.h>
#define OLED_ADDRESS   0x3C
#define OLED_RESET -1
Adafruit_SH1106 display(OLED_RESET);
int RX = 2, TX = 3;
TinyGPSPlus gps;
SoftwareSerial gpssoft(RX, TX);
void setup()
{
  Serial.begin(9600);
  gpssoft.begin(9600);
  display.begin(SH1106_SWITCHCAPVCC, OLED_ADDRESS);
  display.clearDisplay();
  display.display();
}
void loop()
{
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(27, 2);
  display.print("CIRCUIT DIGEST");
  display.setTextSize(1);
  display.setCursor(35, 20);
  display.print("SPEED(KMPH)");
  display.display();
  while (gpssoft.available() > 0)
    if (gps.encode(gpssoft.read()))
      displayspeed();
  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    display.setTextSize(1);
    display.setCursor(35, 40);
    display.print("Error!!!");
    display.display();
    while (true);
  }
}
void displayspeed()
{
  if (gps.speed.isValid())
  {
    display.setTextSize(2);
    display.setCursor(40, 40);
    display.print(gps.speed.kmph());
    display.display();
  }
  else
  {
    display.setTextSize(1);
    display.setCursor(35, 40);
    display.print("No Data!!!");
    display.display();
  }
  delay(100);
}

You can start by getting your Arduino Nano from Amazon here.

We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: