forked from SlashDevin/NeoGPS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NMEAsimple.ino
72 lines (62 loc) · 2.21 KB
/
NMEAsimple.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <NMEAGPS.h>
#include <GPSport.h>
//======================================================================
// Program: NMEAsimple.ino
//
// Description: This program shows simple usage of NeoGPS
//
// Prerequisites:
// 1) NMEA.ino works with your device (correct TX/RX pins and baud rate)
// 2) At least one of the RMC, GGA or GLL sentences have been enabled in NMEAGPS_cfg.h.
// 3) Your device at least one of those sentences (use NMEAorder.ino to confirm).
// 4) LAST_SENTENCE_IN_INTERVAL has been set to one of those sentences in NMEAGPS_cfg.h (use NMEAorder.ino).
// 5) LOCATION and ALTITUDE have been enabled in GPSfix_cfg.h
//
// 'Serial' is for debug output to the Serial Monitor window.
//
// License:
// Copyright (C) 2014-2017, SlashDevin
//
// This file is part of NeoGPS
//
// NeoGPS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// NeoGPS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with NeoGPS. If not, see <http://www.gnu.org/licenses/>.
//
//======================================================================
NMEAGPS gps; // This parses the GPS characters
gps_fix fix; // This holds on to the latest values
void setup()
{
DEBUG_PORT.begin(9600);
while (!Serial)
;
DEBUG_PORT.print( F("NMEAsimple.INO: started\n") );
gpsPort.begin(9600);
}
//--------------------------
void loop()
{
while (gps.available( gpsPort )) {
fix = gps.read();
DEBUG_PORT.print( F("Location: ") );
if (fix.valid.location) {
DEBUG_PORT.print( fix.latitude(), 6 );
DEBUG_PORT.print( ',' );
DEBUG_PORT.print( fix.longitude(), 6 );
}
DEBUG_PORT.print( F(", Altitude: ") );
if (fix.valid.altitude)
DEBUG_PORT.print( fix.altitude() );
DEBUG_PORT.println();
}
}