Created
September 9, 2020 21:33
-
-
Save dwblair/6caf0e087b4b360f4c2a08febdf535c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <TinyGPS++.h> | |
//#include <SoftwareSerial.h> | |
/* | |
This sample code demonstrates how to use an array of TinyGPSCustom objects | |
to monitor all the visible satellites. | |
Satellite numbers, elevation, azimuth, and signal-to-noise ratio are not | |
normally tracked by TinyGPS++, but by using TinyGPSCustom we get around this. | |
The simple code also demonstrates how to use arrays of TinyGPSCustom objects, | |
each monitoring a different field of the $GPGSV sentence. | |
It requires the use of SoftwareSerial, and assumes that you have a | |
4800-baud serial GPS device hooked up on pins 4(RX) and 3(TX). | |
*/ | |
//static const int RXPin = 4, TXPin = 3; | |
static const uint32_t GPSBaud = 9600; | |
// The TinyGPS++ object | |
TinyGPSPlus gps; | |
// The serial connection to the GPS device | |
//SoftwareSerial ss(RXPin, TXPin); | |
void setup() | |
{ | |
Serial.begin(115200); | |
//ss.begin(GPSBaud); | |
Serial1.begin(GPSBaud); | |
while (!Serial) ; | |
} | |
double last_lon=0.; | |
double last_lat=0.; | |
void loop() | |
{ | |
// Dispatch incoming characters | |
if (Serial1.available() > 0) | |
{ | |
gps.encode(Serial1.read()); | |
if (gps.location.isValid()) | |
{ | |
last_lon=double(gps.location.lng()); | |
last_lat=double(gps.location.lat()); | |
} | |
} | |
else { // grab last location values and send over radio | |
Serial.print(F("(lat,lon): ")); | |
Serial.print(last_lat,6); | |
Serial.print(F(",")); | |
Serial.println(last_lon,6); | |
delay(1000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment