Esp32 gnss: Difference between revisions
From wikiluntti
(→Specs) |
(→ESP32) |
||
Line 78: | Line 78: | ||
# PPS LED: red. PPS LED not bright when GPS not fixed, flashing when fixed. | # PPS LED: red. PPS LED not bright when GPS not fixed, flashing when fixed. | ||
=== ESP32 === | === ESP32 Code === | ||
<syntaxhighlight lang="C"> | |||
#include <TinyGPS++.h> | |||
#define GPS_BAUDRATE 9600 // The default baudrate of NEO-6M is 9600 | |||
TinyGPSPlus gps; // the TinyGPS++ object | |||
void setup() { | |||
Serial.begin(9600); | |||
Serial2.begin(GPS_BAUDRATE, SERIAL_8N1, 16, 17); | |||
Serial.println(F("ESP32 - GPS module")); | |||
Serial.println(F("Lat, Lon, Alt, speed [m/s], Datetime")); | |||
} | |||
void loop() { | |||
if (Serial2.available() > 0) { | |||
if (gps.encode(Serial2.read())) { | |||
if (gps.location.isValid()) { | |||
Serial.print(gps.location.lat(), 8); | |||
Serial.print(F(", ")); | |||
Serial.print(gps.location.lng(), 8); | |||
Serial.print(F(", ")); | |||
if (gps.altitude.isValid()) | |||
Serial.print(gps.altitude.meters()); | |||
else | |||
Serial.print(F("INVALID")); | |||
} else { | |||
Serial.print(F("Nan, Nan")); | |||
} | |||
Serial.print(F(", ")); | |||
if (gps.speed.isValid()) { | |||
Serial.print(gps.speed.mps()); | |||
} else { | |||
Serial.print(F("NaN")); | |||
} | |||
Serial.print(F(", ")); | |||
if (gps.date.isValid() && gps.time.isValid()) { | |||
Serial.print(gps.date.year()); | |||
Serial.print(F("-")); | |||
Serial.print(gps.date.month()); | |||
Serial.print(F("-")); | |||
Serial.print(gps.date.day()); | |||
Serial.print(F(" ")); | |||
Serial.print(gps.time.hour()); | |||
Serial.print(F(":")); | |||
Serial.print(gps.time.minute()); | |||
Serial.print(F(":")); | |||
Serial.print(gps.time.second()); | |||
} else { | |||
Serial.print(F("Nan")); | |||
} | |||
Serial.println(); | |||
} | |||
} | |||
if (millis() > 5000 && gps.charsProcessed() < 10) | |||
Serial.println(F("No GPS data received: check wiring")); | |||
} | |||
</syntaxhighlight> |
Revision as of 17:39, 11 March 2025
Introduction
Global Navinagation Network Systems
- GPS (USA),
- GLONASS (Russia)
- BDS (Beidou) (China)
- Galileo (Europe)
GPS based:
- Japan's Quasi-Zenith Satellite System (QZSS)
- India's GAGAN
- European EGNOS
NMEA 0183 standard
See https://aprs.gids.nl/nmea/
Comma-delimited text format consists of rows of data.
Examples
- $GPBOD – Bearing, origin to destination
- $GPBWC – Bearing and distance to waypoint, great circle
- $GPGGA – Global Positioning System Fix Data
- $GPGLL – Geographic position, latitude / longitude
- $GPGSA – GPS DOP and active satellites
- $GPGSV – GPS Satellites in view
- $GPHDT – Heading, True
- $GPR00 – List of waypoints in currently active route
- $GPRMA – Recommended minimum specific Loran-C data
- $GPRMB – Recommended minimum navigation info
- $GPRMC – Recommended minimum specific GPS/Transit data
- $GPRTE – Routes
- $GPTRF – Transit Fix Data
- $GPSTN – Multiple Data ID
- $GPVBW – Dual Ground / Water Speed
- $GPVTG – Track made good and ground speed
- $GPWPL – Waypoint location
- $GPXTE – Cross-track error, Measured
- $GPZDA – Date & Time
GPS Libraries
SoftwareSerial because the Serial port is used by USB.
TinyGPS
TinyGPS++
Basic GPS Module Operation – Beitian 180 & 220 with Arduino
Beitian 180 & 220
Beitian
Specs
Beitian BN-180 GPS includes
- GPS antenna,
- GNSS antenna,
- RTK antenna,
- Beisan RDSS antenna,
- GPS module,
- GNSS module, board,
- GNSS receiver,
- Beidou module.
Size 18*18*6.2mm
Pins (from left to right)
- GND (black)
- TX output (white) -> Connect to Serial RX pin ESP32 (eg GPIO 16: UART2 RX)
- RX input (yellow) -> Connect to Serial TX pin ESP32 (eg GPIO 17: UART2 TX)
- VCC 3.6 V - 5.5 V (red)
LEDs
- TX LED: blue. The data output, TX LED flashing
- PPS LED: red. PPS LED not bright when GPS not fixed, flashing when fixed.
ESP32 Code
#include <TinyGPS++.h>
#define GPS_BAUDRATE 9600 // The default baudrate of NEO-6M is 9600
TinyGPSPlus gps; // the TinyGPS++ object
void setup() {
Serial.begin(9600);
Serial2.begin(GPS_BAUDRATE, SERIAL_8N1, 16, 17);
Serial.println(F("ESP32 - GPS module"));
Serial.println(F("Lat, Lon, Alt, speed [m/s], Datetime"));
}
void loop() {
if (Serial2.available() > 0) {
if (gps.encode(Serial2.read())) {
if (gps.location.isValid()) {
Serial.print(gps.location.lat(), 8);
Serial.print(F(", "));
Serial.print(gps.location.lng(), 8);
Serial.print(F(", "));
if (gps.altitude.isValid())
Serial.print(gps.altitude.meters());
else
Serial.print(F("INVALID"));
} else {
Serial.print(F("Nan, Nan"));
}
Serial.print(F(", "));
if (gps.speed.isValid()) {
Serial.print(gps.speed.mps());
} else {
Serial.print(F("NaN"));
}
Serial.print(F(", "));
if (gps.date.isValid() && gps.time.isValid()) {
Serial.print(gps.date.year());
Serial.print(F("-"));
Serial.print(gps.date.month());
Serial.print(F("-"));
Serial.print(gps.date.day());
Serial.print(F(" "));
Serial.print(gps.time.hour());
Serial.print(F(":"));
Serial.print(gps.time.minute());
Serial.print(F(":"));
Serial.print(gps.time.second());
} else {
Serial.print(F("Nan"));
}
Serial.println();
}
}
if (millis() > 5000 && gps.charsProcessed() < 10)
Serial.println(F("No GPS data received: check wiring"));
}