Just in case the linked document disappears, here's the gist:
Be sure the TinyGPS++ library is installed in
Arduino\libraries
TinyGPS++ here:
https://github.com/mikalhart/TinyGPSPlus/releases
// If your M5Stick is the original, use:
#include <M5StickC.h>
// If its M5 Stick Plus 2 use:
#include "M5StickCPlus2.h"
//The rest should be default:
#include "TinyGPS++.h"
TinyGPSPlus gps;
HardwareSerial GPSRaw(2);
void setup() {
M5.begin();
M5.Lcd.setRotation(3);
M5.Lcd.fillScreen(BLACK);
M5.Lcd.setTextSize(2); // Size 1 or 2 as needed
M5.Lcd.setCursor(20, 15);
M5.Lcd.println("GPS UNIT TEST");
GPSRaw.begin(9600, SERIAL_8N1, 33, 32); // M5StickC?GROVE???
while (!GPSRaw) {
; // ???????????????
}
}
void loop() {
while(GPSRaw.available()) {
gps.encode(GPSRaw.read());
if (gps.location.isUpdated()) {
M5.Lcd.setCursor(20, 30);
M5.Lcd.print("LAT="); M5.Lcd.print(gps.location.lat(),6);
M5.Lcd.setCursor(20, 45);
M5.Lcd.print("LNG="); M5.Lcd.print(gps.location.lng(),6);
M5.Lcd.setCursor(20, 60);
M5.Lcd.print("ALT="); M5.Lcd.print(gps.altitude.meters());
}
}
}