How to Display GPS Data on the Mini-OLED
In this guide I will show you how to display the data returned from the GPS module to the mini-OLED display. This will help assist you to make this a truly portable project, without the need to be tethered to a computer to read the serial monitor in the Arduinos IDE.
Let's Build!
Components:
- Arduino
- GPS Neo 6M
- Mini-OLED
- Jumpers
The Code:
The code is very similar to our last guide: Programming Arduino with GPS except this time we send the returned data to the mini-OLED display instead.
You may need to install any missing libraries, to learn how to do this you can follow our guide here: How to Install Arduino Libraries
#include "TinyGPS++.h" #include "SoftwareSerial.h" #include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels Adafruit_SSD1306 display(128, 64, &Wire); int RXpin=3; int TXpin=4; SoftwareSerial gpsConnection(RXpin,TXpin); TinyGPSPlus gps; int tm=2000; void setup() { gpsConnection.begin(9600); display.begin(SSD1306_SWITCHCAPVCC, 0x3C); display.setTextSize(2); display.setTextColor(WHITE); display.display(); //Display logo delay(500); display.clearDisplay(); display.setTextSize(3); display.setCursor(35,10); display.print("GPS"); display.setTextSize(2); display.setCursor(1,40); display.print("Connecting"); display.display(); delay(500); } void loop() { while(gpsConnection.available()){ gps.encode(gpsConnection.read()); } if(gps.location.isUpdated()){ display.setTextSize(2); display.clearDisplay(); display.setCursor(7,10); display.print(gps.date.day()); display.print("/"); display.print(gps.date.month()); display.print("/"); display.println(gps.date.year()); display.setCursor(14,45); display.print(gps.time.hour()); display.print(":"); display.print(gps.time.minute()); display.print("."); display.print(gps.time.second()); display.display(); delay(tm); display.clearDisplay(); display.setCursor(1,10); display.print("Satellites"); display.setCursor(55,40); display.println(gps.satellites.value()); display.display(); delay(tm); display.clearDisplay(); display.setCursor(10,1); display.println("Lat/Long"); display.setCursor(10,25); display.println(gps.location.lat(),6); display.setCursor(10,50); display.println(gps.location.lng(),6); display.display(); delay(tm); display.clearDisplay(); display.setCursor(8,10); display.println("Direction"); display.setCursor(8,40); display.print(gps.course.deg()); display.println(" deg"); display.display(); delay(tm); display.clearDisplay(); display.setCursor(10,1); display.println("Speed"); display.setCursor(10,25); display.print(gps.speed.kmph()); display.println(" km"); display.setCursor(10,50); display.print(gps.speed.mph()); display.println(" mph"); display.display(); delay(tm); display.clearDisplay(); display.setCursor(10,1); display.println("Altitude"); display.setCursor(10,25); display.print(gps.altitude.feet()); display.println(" Ft"); display.setCursor(10,50); display.print(gps.altitude.meters()); display.println(" Mtr"); display.display(); delay(tm); } }
The Circuit:
For GPS:
- VCC on the GPS module to 5v on Arduino.
- GND on the GPS module to GND on Arduino.
- RX on the GPS module to pin 4 on Arduino.
- TX on the GPS module to pin 3 on Arduino.
For mini-OLED:
- VCC on mini-OLED to 5V on Arduino.
- GND on mini-OLED to GND on Arduino.
- SCL on mini-OLED to A5 on Arduino.
- SDA on mini-OLED to A4 on Arduino.
Just like in the image below:
Upload the Code:
Once you have the circuit built and the code uploaded to the Arduino, you will begin to see the data displayed on the mini-OLED display.
Conclusion
As we wrap up this journey of Arduino, GPS technology, and mini-OLED integration, we’ve unlocked a world of possibilities and embarked on a path of creative innovation. Throughout this project, we’ve witnessed the synergy of hardware and software, transforming raw GPS data into a dynamic visual display.
But this is just the beginning. Next, we will begin recording the data returned from the GPS module to an SD Card.
So, stay tuned, we are about to become unleashed!
Happy Tinkering!