Display Lat Long on T-Beam

Updated on 12 April 2022
dev board LilyGO T-Beam
chip ESP32-DOWDQ6
chip SSD1306
chip NEO-6M
features display oled gps parsed

Before starting

Dependancies

Ensure the following dependancies are downloaded and available:

Pre-requisites

Try these simpler or similar examples:

Buy the components

Code

Download code display-parsed-gps-esp32-t-beam.ino
#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();
  }
}

Makefile

BOARD?=esp32:esp32:t-beam
PORT?=/dev/cu.SLAB_USBtoUART

.PHONY: default lint all flash clean

default: all flash clean

lint:
	cpplint --extensions=ino --filter=-legal/copyright *.ino

all:
	arduino-cli compile --fqbn $(BOARD) ./

flash:
	arduino-cli upload -p $(PORT) --fqbn $(BOARD)

clean:
	rm -r build

Prototype

A photo of the actual setup.

Display Lat Long on T-Beam prototype

Serial console

Serial output from the firmware.

Display Lat Long on T-Beam serial console

Description

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.

References

Watch