Display Lat Long on ESP32 LilyGO T-Beam

esp32 t-beam lilygo display oled ssd1306 gps ublox neo-6m parsed

Pre-requisites

This example contains the code to display latitude/longitude information on OLED display SSD1306 with ESP32-based LilyGO T-Beam.

  1. Install Arduino library dependancy for the OLED display SSD1306

     arduino-cli lib install "ESP8266 and ESP32 OLED driver for SSD1306 displays"
     arduino-cli lib install "TinyGPSPlus"
    
  2. Run make to compile and flash the code
  3. Ensure, after a while, when there is a GPS fix, the latitude-longitude information is displayed on the OLED.

Code

Download code
#include "src/gps/gps.h"
#include "src/oled/oled.h"

int interval = 2000;
long lastSendTime = 0;
LatLong latlong = {0.0, 0.0};

void setup() {
  Serial.begin(9600);
  initGPS();
  initOLED();
}

void loop() {
  // Get the GPS information as soon as it is available,
  // but display the lat-long in serial monitor and OLED only every interval
  while (isGPSAvailable()) {
    getLatLong(&latlong);
  }

  if (millis() - lastSendTime > interval) {
    Serial.print(millis());
    Serial.print(" Lat-Long: ");
    Serial.print(latlong.latitude, 7);
    Serial.print(", ");
    Serial.println(latlong.longitude, 7);

    displayOLED(latlong.latitude, latlong.longitude);

    lastSendTime = millis();
  }
}

Serial console

Serial output from the firmware.

Display Lat Long on ESP32 LilyGO T-Beam serial console

Prototype

A photo of the actual setup.

Display Lat Long on ESP32 LilyGO T-Beam prototype

References