Skip to content

Commit 8e39672

Browse files
authored
Create GPStest.ino
1 parent f3a157a commit 8e39672

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/ Test code for Adafruit GPS modules using MTK driver
2+
// such as www.adafruit.com/products/660 (discontinued)
3+
// For new use see www.adafruit.com/products/746 (needs different code)
4+
// help support open source hardware & software! -adafruit
5+
6+
#include <SoftSerial.h>
7+
SoftSerial mySerial(2, 3);
8+
9+
// Connect the GPS Power pin to 3.3V
10+
// Connect the GPS Ground pin to ground
11+
// Connect the GPS VBAT pin to 3.3V if no battery is used
12+
// Connect the GPS TX (transmit) pin to Digital 2
13+
// Connect the GPS RX (receive) pin to Digital 3
14+
// For 3.3V only modules such as the UP501, connect a 10K
15+
// resistor between digital 3 and GPS RX and a 10K resistor
16+
// from GPS RX to ground.
17+
18+
// different commands to set the update rate from once a second (1 Hz) to 10 times a second (10Hz)
19+
#define PMTK_SET_NMEA_UPDATE_1HZ "$PMTK220,1000*1F"
20+
#define PMTK_SET_NMEA_UPDATE_5HZ "$PMTK220,200*2C"
21+
#define PMTK_SET_NMEA_UPDATE_10HZ "$PMTK220,100*2F"
22+
23+
// turn on only the second sentence (GPRMC)
24+
#define PMTK_SET_NMEA_OUTPUT_RMCONLY "$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29"
25+
// turn on ALL THE DATA
26+
#define PMTK_SET_NMEA_OUTPUT_ALLDATA "$PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
27+
28+
// to generate your own sentences, check out the MTK command datasheet and use a checksum calculator
29+
// such as the awesome http://www.hhhh.org/wiml/proj/nmeaxor.html
30+
31+
void setup()
32+
{
33+
Serial.begin(57600);
34+
Serial.println("Adafruit MTK3329 NMEA test!");
35+
36+
// 9600 NMEA is the default baud rate
37+
mySerial.begin(9600);
38+
39+
// uncomment this line to turn on only the "minimum recommended" data for high update rates!
40+
//mySerial.println(PMTK_SET_NMEA_OUTPUT_RMCONLY);
41+
42+
// uncomment this line to turn on all the available data - for 9600 baud you'll want 1 Hz rate
43+
mySerial.println(PMTK_SET_NMEA_OUTPUT_ALLDATA);
44+
45+
// Set the update rate
46+
// 1 Hz update rate
47+
mySerial.println(PMTK_SET_NMEA_UPDATE_1HZ);
48+
// 5 Hz update rate- for 9600 baud you'll have to set the output to RMC only (see above)
49+
//mySerial.println(PMTK_SET_NMEA_UPDATE_5HZ);
50+
// 10 Hz update rate - for 9600 baud you'll have to set the output to RMC only (see above)
51+
//mySerial.println(PMTK_SET_NMEA_UPDATE_10HZ);
52+
53+
}
54+
55+
void loop() // run over and over again
56+
{
57+
58+
if (mySerial.available()) {
59+
Serial.print((char)mySerial.read());
60+
}
61+
if (Serial.available()) {
62+
mySerial.print((char)Serial.read());
63+
}
64+
}

0 commit comments

Comments
 (0)