Skip to content

Commit 1285f61

Browse files
committed
Create Example33_NAVSAT.ino
1 parent c4bbe44 commit 1285f61

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
Polling NAV SAT
3+
By: Paul Clark
4+
SparkFun Electronics
5+
Date: June 5th, 2023
6+
License: MIT. See license file for more information.
7+
8+
Feel like supporting open source hardware?
9+
Buy a board from SparkFun!
10+
SparkFun GPS-RTK2 - ZED-F9P (GPS-15136) https://www.sparkfun.com/products/15136
11+
SparkFun GPS-RTK-SMA - ZED-F9P (GPS-16481) https://www.sparkfun.com/products/16481
12+
SparkFun MAX-M10S Breakout (GPS-18037) https://www.sparkfun.com/products/18037
13+
SparkFun ZED-F9K Breakout (GPS-18719) https://www.sparkfun.com/products/18719
14+
SparkFun ZED-F9R Breakout (GPS-16344) https://www.sparkfun.com/products/16344
15+
16+
Hardware Connections:
17+
Plug a Qwiic cable into the GPS and a BlackBoard
18+
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
19+
Open the serial monitor at 115200 baud to see the output
20+
*/
21+
22+
#include <Wire.h> //Needed for I2C to GPS
23+
24+
#include <SparkFun_u-blox_GNSS_v3.h> //http://librarymanager/All#SparkFun_u-blox_GNSS_v3
25+
SFE_UBLOX_GNSS myGNSS;
26+
27+
void setup()
28+
{
29+
Serial.begin(115200);
30+
while (!Serial); //Wait for user to open terminal
31+
Serial.println("SparkFun u-blox Example");
32+
33+
Wire.begin();
34+
35+
//myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
36+
37+
myGNSS.setPacketCfgPayloadSize(UBX_NAV_SAT_MAX_LEN); // Allocate extra RAM to store the full NAV SAT data
38+
39+
if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
40+
{
41+
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
42+
while (1);
43+
}
44+
45+
myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
46+
myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
47+
48+
myGNSS.setNavigationFrequency(1); //Produce one solution per second
49+
}
50+
51+
void loop()
52+
{
53+
if (myGNSS.getNAVSAT()) // Poll the latest NAV SAT data
54+
{
55+
Serial.println();
56+
57+
// See u-blox_structs.h for the full definition of UBX_NAV_SAT_data_t
58+
Serial.print(F("New NAV SAT data received. It contains data for "));
59+
Serial.print(myGNSS.packetUBXNAVSAT->data.header.numSvs);
60+
if (myGNSS.packetUBXNAVSAT->data.header.numSvs == 1)
61+
Serial.println(F(" SV."));
62+
else
63+
Serial.println(F(" SVs."));
64+
65+
// Just for giggles, print the signal strength for each SV as a barchart
66+
for (uint16_t block = 0; block < myGNSS.packetUBXNAVSAT->data.header.numSvs; block++) // For each SV
67+
{
68+
switch (myGNSS.packetUBXNAVSAT->data.blocks[block].gnssId) // Print the GNSS ID
69+
{
70+
case 0:
71+
Serial.print(F("GPS "));
72+
break;
73+
case 1:
74+
Serial.print(F("SBAS "));
75+
break;
76+
case 2:
77+
Serial.print(F("Galileo "));
78+
break;
79+
case 3:
80+
Serial.print(F("BeiDou "));
81+
break;
82+
case 4:
83+
Serial.print(F("IMES "));
84+
break;
85+
case 5:
86+
Serial.print(F("QZSS "));
87+
break;
88+
case 6:
89+
Serial.print(F("GLONASS "));
90+
break;
91+
default:
92+
Serial.print(F("UNKNOWN "));
93+
break;
94+
}
95+
96+
Serial.print(myGNSS.packetUBXNAVSAT->data.blocks[block].svId); // Print the SV ID
97+
98+
if (myGNSS.packetUBXNAVSAT->data.blocks[block].svId < 10) Serial.print(F(" "));
99+
else if (myGNSS.packetUBXNAVSAT->data.blocks[block].svId < 100) Serial.print(F(" "));
100+
else Serial.print(F(" "));
101+
102+
// Print the signal strength as a bar chart
103+
for (uint8_t cno = 0; cno < myGNSS.packetUBXNAVSAT->data.blocks[block].cno; cno++)
104+
Serial.print(F("="));
105+
106+
Serial.println();
107+
}
108+
}
109+
}

0 commit comments

Comments
 (0)