-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
100 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/******************** | ||
* Program: NEO 6M GPS sensor tester | ||
* Description: prints coordinates and date/time to serial | ||
* Connections: | ||
* NEO 6M GND -> GND | ||
* NEO 6M VCC -> VCC | ||
* NEO 6M TX -> D4 | ||
* NEO 6M RX -> D3 | ||
********************/ | ||
#include <TinyGPS++.h> | ||
#include <SoftwareSerial.h> | ||
|
||
static const int RXPin = 4, TXPin = 3; | ||
static const uint32_t GPSBaud = 9600; | ||
|
||
// The TinyGPS++ object | ||
TinyGPSPlus gps; | ||
void displayInfo(); | ||
|
||
// The serial connection to the GPS device | ||
SoftwareSerial ss(RXPin, TXPin); | ||
|
||
void setup() | ||
{ | ||
Serial.begin(38400); | ||
ss.begin(GPSBaud); | ||
|
||
Serial.println(F("DeviceExample.ino")); | ||
Serial.println(F("A simple demonstration of TinyGPS++ with an attached GPS module")); | ||
Serial.print(F("Testing TinyGPS++ library v. ")); Serial.println(TinyGPSPlus::libraryVersion()); | ||
Serial.println(F("by Mikal Hart")); | ||
Serial.println(); | ||
} | ||
|
||
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.print(F(" Date/Time: ")); | ||
if (gps.date.isValid()) | ||
{ | ||
Serial.print(gps.date.month()); | ||
Serial.print(F("/")); | ||
Serial.print(gps.date.day()); | ||
Serial.print(F("/")); | ||
Serial.print(gps.date.year()); | ||
} | ||
else | ||
{ | ||
Serial.print(F("INVALID")); | ||
} | ||
|
||
Serial.print(F(" ")); | ||
if (gps.time.isValid()) | ||
{ | ||
if (gps.time.hour() < 10) Serial.print(F("0")); | ||
Serial.print(gps.time.hour()); | ||
Serial.print(F(":")); | ||
if (gps.time.minute() < 10) Serial.print(F("0")); | ||
Serial.print(gps.time.minute()); | ||
Serial.print(F(":")); | ||
if (gps.time.second() < 10) Serial.print(F("0")); | ||
Serial.print(gps.time.second()); | ||
Serial.print(F(".")); | ||
if (gps.time.centisecond() < 10) Serial.print(F("0")); | ||
Serial.print(gps.time.centisecond()); | ||
} | ||
else | ||
{ | ||
Serial.print(F("INVALID")); | ||
} | ||
|
||
Serial.println(); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include ../../../../WaziDev.mk |