esp32_neo-m6-gps-module_lilygo-t-display-s3 | Last modified: 1744968742 | Edit | Home

GPS

ESP32 + NEO-M6 GPS Module

Tout est là: https://randomnerdtutorials.com/esp32-neo-6m-gps-module-arduino/

LilyGO T-Display-S3 + NEO-M6 GPS Module

NEO-M6 T-Display-S3
VCC 5V
Rx GPIO 16
Tx GPIO 21
GND GND

Schémas GPIO du T-Display-S3

#include <TinyGPS++.h>
#include <TFT_eSPI.h>

 // Define the RX and TX pins for Serial 2
#define RXD2 21
#define TXD2 16

#define GPS_BAUD 9600

// The TinyGPS++ object
TinyGPSPlus gps;

// Create an instance of the HardwareSerial class for Serial 2
HardwareSerial gpsSerial(2);

TFT_eSPI tft = TFT_eSPI();


void setup(){
  // Serial Monitor
  Serial.begin(115200);
  Serial.println("Serial 1 started at 115200 baud rate");

  // Start Serial 2 with the defined RX and TX pins and a baud rate of 9600
  gpsSerial.begin(GPS_BAUD, SERIAL_8N1, RXD2, TXD2);
  Serial.println("Serial 2 started at 9600 baud rate");

  tft.begin();
  tft.setRotation(1);
  tft.setTextColor(TFT_WHITE, TFT_BLACK);
}

void loop(){
  while (gpsSerial.available() > 0){
    // get the byte data from the GPS
    char gpsData = gpsSerial.read();
    Serial.print(gpsData);
    gps.encode(gpsData);
  }
    if (gps.location.isUpdated()) {
      tft.fillScreen(TFT_BLACK);
      tft.drawString("LAT: " + String(gps.location.lat(), 6), 0, 0, 4);
      tft.drawString("LONG: " + String(gps.location.lng(), 6), 0, 20, 4);
      tft.drawString("SPEED (km/h) = " + String(gps.speed.kmph()), 0, 40, 4); 
      tft.drawString("ALT (min)= " + String(gps.altitude.meters()), 0, 60, 4);
      tft.drawString("HDOP = " + String(gps.hdop.value() / 100.0), 0, 80, 2); 
      tft.drawString("Satellites = " + String(gps.satellites.value()), 0, 94, 2); 
      tft.drawString("Time in UTC: " + 
            String(gps.date.year()) + "/" + String(gps.date.month()) + "/" + 
            String(gps.date.day()) + "," + String(gps.time.hour()) + ":" + 
            String(gps.time.minute()) + ":" + String(gps.time.second()),
            0, 108, 2);
      Serial.println("");
    }

  delay(1000);
  Serial.println("-------------------------------");
}