GPS-Daten & ESP8266

Schaltplan

Quellcode

BETA-VERSION – Arduino/ESP8266 – Code
/*

https://forum.arduino.cc/t/gps-esp8266-oled/1178602/12
https://github.com/ahmadlogs/arduino-ide-examples/blob/main/esp32-gps-tracker/esp32-gps-tracker.ino
https://randomnerdtutorials.com/guide-to-neo-6m-gps-module-with-arduino
https://arduiniana.org/libraries/tinygpsplus

µC:         ESP2866 Wemos D1 Mini (Clone)
Display:    0.96inch OLED Module SSD1306 (SKU: MC096GW/white) 
GPS-Module: GY-NEO6MV2

*/


#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <TinyGPS++.h>
#include <SoftwareSerial.h>

// Define your OLED display settings
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET    -1
#define SCREEN_ADDRESS 0x3C //See datasheet for Address
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);



// Define the GPS module
SoftwareSerial gpsSerial(13, 15); // RX-Pin = D7 (GPIO13), TX-Pin=D8 (GPIO15)
TinyGPSPlus gps;

void setup() {
  // Initialize the display
  if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  
  // Set up the GPS module
  gpsSerial.begin(9600);
  
  display.display(); // Display startup message
  delay(2000);
  display.clearDisplay();
}

void loop() {
  while (gpsSerial.available() > 0) {
    if (gps.encode(gpsSerial.read())) {
      display.clearDisplay();
      
      // Display the number of locked satellites
      display.setTextSize(2);
      display.setTextColor(SSD1306_WHITE);
      display.setCursor(0, 0);
      display.print("H:");
      display.print(gps.altitude.meters(),1);
      
      // Display GPS speed in the middle
      display.setTextSize(2);
      display.setCursor(0, SCREEN_HEIGHT / 2 - 8);
      //display.print(gps.speed.kmph());
      //display.print(gps.altitude.meters(), 0);
      //display.print(gps.time.hour());
      //display.print(":");
      display.print(gps.time.minute());
      display.print(":");
      display.print(gps.time.second());
      display.print("_");
      display.print(gps.satellites.value());      

      // Meine Testreihe
      display.setTextSize(2);
      display.setCursor(0, 48);
      display.print(gps.location.lat(), 8);

      
      display.display();
    }
  }
}
Download

Parameter

Die hier gelisteten Parameter können im Quellcode z.B. mit display.print(gps.date.year()); ergänzt/geändert werden, um die entsprechenden Werte dann auf dem Display ausgeben zu lassen.

gps.location.lat(), 6 // Latitude in degrees (double)
gps.location.lng(), 6 // Longitude in degrees (double)

gps.location.rawLat().negative ? "-" : "+"
gps.location.rawLat().deg // Raw latitude in whole degrees
gps.location.rawLat().billionths // ... and billionths (u16/u32)

gps.location.rawLng().negative ? "-" : "+"
gps.location.rawLng().deg // Raw longitude in whole degrees
gps.location.rawLng().billionths // ... and billionths (u16/u32)

gps.date.value() // Raw date in DDMMYY format (u32)
gps.date.year() // Year (2000+) (u16)
gps.date.month() // Month (1-12) (u8)
gps.date.day(); // Day (1-31) (u8)

gps.time.value() // Raw time in HHMMSSCC format (u32)
gps.time.hour() // Hour (0-23) (u8)
gps.time.minute() // Minute (0-59) (u8)
gps.time.second() // Second (0-59) (u8)
gps.time.centisecond() // 100ths of a second (0-99) (u8)

gps.speed.value() // Raw speed in 100ths of a knot (i32)
gps.speed.knots() // Speed in knots (double)
gps.speed.mph() // Speed in miles per hour (double)
gps.speed.mps() // Speed in meters per second (double)
gps.speed.kmph() // Speed in kilometers per hour (double)

gps.course.value() // Raw course in 100ths of a degree (i32)
gps.course.deg() // Course in degrees (double)

gps.altitude.value() // Raw altitude in centimeters (i32)
gps.altitude.meters() // Altitude in meters (double)
gps.altitude.miles() // Altitude in miles (double)
gps.altitude.kilometers() // Altitude in kilometers (double)
gps.altitude.feet(); // Altitude in feet (double)

gps.satellites.value() // Number of satellites in use (u32)

gps.hdop.value() // Horizontal Dim. of Precision (100ths-i32)
TinyGPS++ by Mikal Hart

Download

gps
gps

Funktionsfähige aber noch frühe Codeversion

Größe: 2,2 KiB (2.249 Bytes)
Version: 0.1
Published: 28. September 2024

Quellen und weiterführende Informationen