Skip to content

Instantly share code, notes, and snippets.

@KornWtp
Last active April 28, 2024 06:54
Show Gist options
  • Save KornWtp/d238863000637eb1834ab4d58d2812d5 to your computer and use it in GitHub Desktop.
Save KornWtp/d238863000637eb1834ab4d58d2812d5 to your computer and use it in GitHub Desktop.
ESP32+GPS ATGM336H GPS Module .ino
#include <TinyGPS++.h>
#include <HardwareSerial.h>
#define RXPin (16)
#define TXPin (17)
static const uint32_t GPSBaud = 9600;
// The TinyGPS++ object
TinyGPSPlus gps;
// The serial connection to the GPS device
HardwareSerial ss(2);
void setup()
{
Serial.begin(115200);
ss.begin(GPSBaud, SERIAL_8N1, RXPin, TXPin, false);
Serial.println(TinyGPSPlus::libraryVersion());
}
void loop()
{
// This sketch displays information every time a new sentence is correctly encoded.
while (ss.available() > 0)
if (gps.encode(ss.read()))
displayInfo();
if (millis() > 5000 && gps.charsProcessed() < 10)
{
Serial.println(F("No GPS detected: check wiring."));
while(true);
}
}
void displayInfo()
{
Serial.print(F("Location: "));
if (gps.location.isValid())
{
Serial.print(gps.location.lat(), 6);
Serial.print(F(","));
Serial.print(gps.location.lng(), 6);
}
else
{
Serial.print(F("INVALID"));
}
Serial.println();
}
@Gixs
Copy link

Gixs commented Jun 1, 2020

Missing "}" in line 20

@KornWtp
Copy link
Author

KornWtp commented Jun 11, 2020

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment