Initial commit - based on v2_candidate

This commit is contained in:
PaulZC
2021-01-09 06:44:12 +00:00
commit 6627841e7d
89 changed files with 31927 additions and 0 deletions
@@ -0,0 +1,104 @@
/*
Configuring the GNSS to automatically send position reports over I2C and display them using a callback
By: Paul Clark
SparkFun Electronics
Date: December 30th, 2020
License: MIT. See license file for more information but you can
basically do whatever you want with this code.
This example shows how to configure the u-blox GNSS to send navigation reports automatically
and access the data via a callback. No more polling!
Feel like supporting open source hardware?
Buy a board from SparkFun!
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
NEO-M8P RTK: https://www.sparkfun.com/products/15005
SAM-M8Q: https://www.sparkfun.com/products/15106
Hardware Connections:
Plug a Qwiic cable into the GPS and a BlackBoard
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
Open the serial monitor at 115200 baud to see the output
*/
#include <Wire.h> //Needed for I2C to GPS
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
SFE_UBLOX_GPS myGPS;
// Callback: printPVTdata will be called when new NAV PVT data arrives
// See u-blox_structs.h for the full definition of UBX_NAV_PVT_data_t
// _____ You can use any name you like for the callback. Use the same name when you call setAutoPVTcallback
// / _____ This _must_ be UBX_NAV_PVT_data_t
// | / _____ You can use any name you like for the struct
// | | /
// | | |
void printPVTdata(UBX_NAV_PVT_data_t ubxDataStruct)
{
Serial.println();
Serial.print(F("Time: ")); // Print the time
uint8_t hms = ubxDataStruct.hour; // Print the hours
if (hms < 10) Serial.print(F("0")); // Print a leading zero if required
Serial.print(hms);
Serial.print(F(":"));
hms = ubxDataStruct.min; // Print the minutes
if (hms < 10) Serial.print(F("0")); // Print a leading zero if required
Serial.print(hms);
Serial.print(F(":"));
hms = ubxDataStruct.sec; // Print the seconds
if (hms < 10) Serial.print(F("0")); // Print a leading zero if required
Serial.print(hms);
Serial.print(F("."));
unsigned long millisecs = ubxDataStruct.iTOW % 1000; // Print the milliseconds
if (millisecs < 100) Serial.print(F("0")); // Print the trailing zeros correctly
if (millisecs < 10) Serial.print(F("0"));
Serial.print(millisecs);
long latitude = ubxDataStruct.lat; // Print the latitude
Serial.print(F(" Lat: "));
Serial.print(latitude);
long longitude = ubxDataStruct.lon; // Print the longitude
Serial.print(F(" Long: "));
Serial.print(longitude);
Serial.print(F(" (degrees * 10^-7)"));
long altitude = ubxDataStruct.hMSL; // Print the height above mean sea level
Serial.print(F(" Height above MSL: "));
Serial.print(altitude);
Serial.println(F(" (mm)"));
}
void setup()
{
Serial.begin(115200);
while (!Serial); //Wait for user to open terminal
Serial.println("SparkFun u-blox Example");
Wire.begin();
//myGPS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
{
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
while (1);
}
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
myGPS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
myGPS.setNavigationFrequency(2); //Produce two solutions per second
myGPS.setAutoPVTcallback(&printPVTdata); // Enable automatic NAV PVT messages with callback to printPVTdata
}
void loop()
{
myGPS.checkUblox(); // Check for the arrival of new data and process it.
myGPS.checkCallbacks(); // Check if any callbacks are waiting to be processed.
Serial.print(".");
delay(50);
}
@@ -0,0 +1,89 @@
/*
Configuring the GNSS to automatically send odometer reports over I2C and display the data using a callback
By: Paul Clark
SparkFun Electronics
Date: December 30th, 2020
License: MIT. See license file for more information but you can
basically do whatever you want with this code.
This example shows how to configure the u-blox GNSS to send odometer reports automatically
and display the data via a callback. No more polling!
Feel like supporting open source hardware?
Buy a board from SparkFun!
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
NEO-M8P RTK: https://www.sparkfun.com/products/15005
SAM-M8Q: https://www.sparkfun.com/products/15106
Hardware Connections:
Plug a Qwiic cable into the GPS and a BlackBoard
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
Open the serial monitor at 115200 baud to see the output
*/
#include <Wire.h> //Needed for I2C to GPS
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
SFE_UBLOX_GPS myGPS;
// Callback: printODOdata will be called when new NAV ODO data arrives
// See u-blox_structs.h for the full definition of UBX_NAV_ODO_data_t
// _____ You can use any name you like for the callback. Use the same name when you call setAutoNAVODOcallback
// / _____ This _must_ be UBX_NAV_ODO_data_t
// | / _____ You can use any name you like for the struct
// | | /
// | | |
void printODOdata(UBX_NAV_ODO_data_t ubxDataStruct)
{
Serial.println();
Serial.print(F("TOW: ")); // Print the Time Of Week
unsigned long iTOW = ubxDataStruct.iTOW; // iTOW is in milliseconds
Serial.print(iTOW);
Serial.print(F(" (ms)"));
Serial.print(F(" Distance: "));
unsigned long distance = ubxDataStruct.distance; // Print the distance
Serial.print(distance);
Serial.print(F(" (m)"));
Serial.print(F(" Total Distance: "));
unsigned long totalDistance = ubxDataStruct.totalDistance; // Print the total distance
Serial.print(totalDistance);
Serial.println(F(" (m)"));
}
void setup()
{
Serial.begin(115200);
while (!Serial); //Wait for user to open terminal
Serial.println("SparkFun u-blox Example");
Wire.begin();
//myGPS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
{
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
while (1);
}
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
myGPS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
myGPS.setNavigationFrequency(1); //Produce one solution per second
//myGPS.resetOdometer(); //Uncomment this line to reset the odometer
myGPS.setAutoNAVODOcallback(&printODOdata); // Enable automatic NAV ODO messages with callback to printODOdata
}
void loop()
{
myGPS.checkUblox(); // Check for the arrival of new data and process it.
myGPS.checkCallbacks(); // Check if any callbacks are waiting to be processed.
Serial.print(".");
delay(50);
}
@@ -0,0 +1,115 @@
/*
Configuring the GNSS to automatically send TIM TM2 reports over I2C and display the data using a callback
By: Paul Clark
SparkFun Electronics
Date: December 30th, 2020
License: MIT. See license file for more information but you can
basically do whatever you want with this code.
This example shows how to configure the u-blox GNSS to send TIM TM2 reports automatically
and display the data via a callback. No more polling!
Connecting the PPS (Pulse Per Second) breakout pin to the INT (Interrupt) pin with a jumper wire
will cause a TIM TM2 message to be produced once per second. You can then study the timing of the
pulse edges with nanosecond resolution!
Note: TIM TM2 can only capture the timing of one rising edge and one falling edge per
navigation solution. So with setNavigationFrequency set to 1Hz, we can only see the timing
of one rising and one falling edge per second. If the frequency of the signal on the INT pin
is higher than 1Hz, we will only be able to see the timing of the most recent edges.
However, the module can count the number of rising edges too, at rates faster than the navigation rate.
TIM TM2 messages are only produced when a rising or falling edge is detected on the INT pin.
If you disconnect your PPS to INT jumper wire, the messages will stop.
Feel like supporting open source hardware?
Buy a board from SparkFun!
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
NEO-M8P RTK: https://www.sparkfun.com/products/15005
NEO-M9N: https://www.sparkfun.com/products/17285
Hardware Connections:
Plug a Qwiic cable into the GPS and a BlackBoard
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
Open the serial monitor at 115200 baud to see the output
*/
#include <Wire.h> //Needed for I2C to GPS
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
SFE_UBLOX_GPS myGPS;
int dotsPrinted = 0; // Print dots in rows of 50 while waiting for a TIM TM2 message
// Callback: printTIMTM2data will be called when new TIM TM2 data arrives
// See u-blox_structs.h for the full definition of UBX_TIM_TM2_data_t
// _____ You can use any name you like for the callback. Use the same name when you call setAutoTIMTM2callback
// / _____ This _must_ be UBX_TIM_TM2_data_t
// | / _____ You can use any name you like for the struct
// | | /
// | | |
void printTIMTM2data(UBX_TIM_TM2_data_t ubxDataStruct)
{
Serial.println();
Serial.print(F("newFallingEdge: ")); // 1 if a new falling edge was detected
Serial.print(ubxDataStruct.flags.bits.newFallingEdge);
Serial.print(F(" newRisingEdge: ")); // 1 if a new rising edge was detected
Serial.print(ubxDataStruct.flags.bits.newRisingEdge);
Serial.print(F(" Rising Edge Counter: ")); // Rising edge counter
Serial.print(ubxDataStruct.count);
Serial.print(F(" towMsR: ")); // Time Of Week of rising edge (ms)
Serial.print(ubxDataStruct.towMsR);
Serial.print(F(" towSubMsR: ")); // Millisecond fraction of Time Of Week of rising edge in nanoseconds
Serial.print(ubxDataStruct.towSubMsR);
Serial.print(F(" towMsF: ")); // Time Of Week of falling edge (ms)
Serial.print(ubxDataStruct.towMsF);
Serial.print(F(" towSubMsF: ")); // Millisecond fraction of Time Of Week of falling edge in nanoseconds
Serial.println(ubxDataStruct.towSubMsF);
dotsPrinted = 0; // Reset dotsPrinted
}
void setup()
{
Serial.begin(115200);
while (!Serial); //Wait for user to open terminal
Serial.println("SparkFun u-blox Example");
Wire.begin();
//myGPS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
{
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
while (1);
}
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
myGPS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
myGPS.setNavigationFrequency(1); //Produce one solution per second
myGPS.setAutoTIMTM2callback(&printTIMTM2data); // Enable automatic TIM TM2 messages with callback to printTIMTM2data
}
void loop()
{
myGPS.checkUblox(); // Check for the arrival of new data and process it.
myGPS.checkCallbacks(); // Check if any callbacks are waiting to be processed.
Serial.print(".");
delay(50);
if (++dotsPrinted > 50)
{
Serial.println();
dotsPrinted = 0;
}
}
@@ -0,0 +1,117 @@
/*
By: Paul Clark
SparkFun Electronics
Date: December, 2020
License: MIT. See license file for more information but you can
basically do whatever you want with this code.
This example configures the High Navigation Rate on the NEO-M8U and then
reads and displays the attitude solution, vehicle dynamics information
and high rate position, velocity and time.
This example uses callbacks to process the HNR data automatically. No more polling!
Please make sure your NEO-M8U is running UDR firmware >= 1.31. Please update using u-center if necessary:
https://www.u-blox.com/en/product/neo-m8u-module#tab-documentation-resources
Feel like supporting open source hardware?
Buy a board from SparkFun!
NEO-M8U: https://www.sparkfun.com/products/16329
Hardware Connections:
Plug a Qwiic cable into the GPS and a Redboard Qwiic
If you don't have a platform with a Qwiic connection use the
SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
Open the serial monitor at 115200 baud to see the output
*/
#include <Wire.h> //Needed for I2C to GPS
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
SFE_UBLOX_GPS myGPS;
// Callback: printHNRATTdata will be called when new HNR ATT data arrives
// See u-blox_structs.h for the full definition of UBX_HNR_ATT_data_t
// _____ You can use any name you like for the callback. Use the same name when you call setAutoHNRATTcallback
// / _____ This _must_ be UBX_HNR_ATT_data_t
// | / _____ You can use any name you like for the struct
// | | /
// | | |
void printHNRATTdata(UBX_HNR_ATT_data_t ubxDataStruct)
{
Serial.println();
Serial.print(F("Roll: ")); // Print selected data
Serial.print((float)ubxDataStruct.roll / 100000.0, 2); // Convert roll to degrees
Serial.print(F(" Pitch: "));
Serial.print((float)ubxDataStruct.pitch / 100000.0, 2); // Convert pitch to degrees
Serial.print(F(" Heading: "));
Serial.println((float)ubxDataStruct.heading / 100000.0, 2); // Convert heading to degrees
}
// Callback: printHNRINSdata will be called when new HNR INS data arrives
// See u-blox_structs.h for the full definition of UBX_HNR_INS_data_t
void printHNRINSdata(UBX_HNR_INS_data_t ubxDataStruct)
{
Serial.print(F("xAccel: ")); // Print selected data
Serial.print(ubxDataStruct.xAccel);
Serial.print(F(" yAccel: "));
Serial.print(ubxDataStruct.yAccel);
Serial.print(F(" zAccel: "));
Serial.println(ubxDataStruct.zAccel);
}
// Callback: printHNRPVTdata will be called when new HNR PVT data arrives
// See u-blox_structs.h for the full definition of UBX_HNR_PVT_data_t
void printHNRPVTdata(UBX_HNR_PVT_data_t ubxDataStruct)
{
Serial.print(F("ns: ")); // Print selected data
Serial.print(ubxDataStruct.nano);
Serial.print(F(" Lat: "));
Serial.print(ubxDataStruct.lat);
Serial.print(F(" Lon: "));
Serial.println(ubxDataStruct.lon);
}
void setup()
{
Serial.begin(115200);
while (!Serial); //Wait for user to open terminal
Serial.println(F("SparkFun u-blox Example"));
Wire.begin();
//myGPS.enableDebugging(); // Uncomment this line to enable debug messages on Serial
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
{
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
while (1);
}
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
myGPS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
if (myGPS.setHNRNavigationRate(10) == true) //Set the High Navigation Rate to 10Hz
Serial.println(F("setHNRNavigationRate was successful"));
else
Serial.println(F("setHNRNavigationRate was NOT successful"));
if (myGPS.setAutoHNRATTcallback(&printHNRATTdata) == true) // Enable automatic HNR ATT messages with callback to printHNRATTdata
Serial.println(F("setAutoHNRATTcallback successful"));
if (myGPS.setAutoHNRINScallback(&printHNRINSdata) == true) // Enable automatic HNR INS messages with callback to printHNRINSdata
Serial.println(F("setAutoHNRINScallback successful"));
if (myGPS.setAutoHNRPVTcallback(&printHNRPVTdata) == true) // Enable automatic HNR PVT messages with callback to printHNRPVTdata
Serial.println(F("setAutoHNRPVTcallback successful"));
}
void loop()
{
myGPS.checkUblox(); // Check for the arrival of new data and process it.
myGPS.checkCallbacks(); // Check if any callbacks are waiting to be processed.
Serial.print(".");
delay(25);
}
@@ -0,0 +1,179 @@
/*
By: Paul Clark
SparkFun Electronics
Date: December, 2020
License: MIT. See license file for more information but you can
basically do whatever you want with this code.
This example configures the External Sensor Fusion messages on the NEO-M8U and
uses callbacks to process and display the ESF data automatically. No more polling!
Please make sure your NEO-M8U is running UDR firmware >= 1.31. Please update using u-center if necessary:
https://www.u-blox.com/en/product/neo-m8u-module#tab-documentation-resources
Feel like supporting open source hardware?
Buy a board from SparkFun!
NEO-M8U: https://www.sparkfun.com/products/16329
Hardware Connections:
Plug a Qwiic cable into the GPS and a Redboard Qwiic
If you don't have a platform with a Qwiic connection use the
SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
Open the serial monitor at 115200 baud to see the output
*/
#include <Wire.h> //Needed for I2C to GPS
#include <SparkFun_Ublox_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
SFE_UBLOX_GPS myGPS;
// Callback: printESFALGdata will be called when new ESF ALG data arrives
// See u-blox_structs.h for the full definition of UBX_ESF_ALG_data_t
// _____ You can use any name you like for the callback. Use the same name when you call setAutoESFALGcallback
// / _____ This _must_ be UBX_ESF_ALG_data_t
// | / _____ You can use any name you like for the struct
// | | /
// | | |
void printESFALGdata(UBX_ESF_ALG_data_t ubxDataStruct)
{
Serial.println();
Serial.print(F("TOW: ")); // Print the Time Of Week
unsigned long iTOW = ubxDataStruct.iTOW; // iTOW is in milliseconds
Serial.print(iTOW);
Serial.print(F(" (ms)"));
Serial.print(F(" Roll: ")); // Print selected data
Serial.print((float)ubxDataStruct.roll / 100.0, 2); // Convert roll to degrees
Serial.print(F(" Pitch: "));
Serial.print((float)ubxDataStruct.pitch / 100.0, 2); // Convert pitch to degrees
Serial.print(F(" Yaw: "));
Serial.print((float)ubxDataStruct.yaw / 100.0, 2); // Convert yaw to degrees
Serial.println(F(" (Degrees)"));
}
// Callback: printESFINSdata will be called when new ESF INS data arrives
// See u-blox_structs.h for the full definition of UBX_ESF_INS_data_t
void printESFINSdata(UBX_ESF_INS_data_t ubxDataStruct)
{
Serial.print(F("xAccel: ")); // Print selected data
Serial.print(ubxDataStruct.xAccel);
Serial.print(F(" yAccel: "));
Serial.print(ubxDataStruct.yAccel);
Serial.print(F(" zAccel: "));
Serial.print(ubxDataStruct.zAccel);
Serial.println(F(" (m/s^2)"));
}
// Callback: printESFMEASdata will be called when new ESF MEAS data arrives
// See u-blox_structs.h for the full definition of UBX_ESF_MEAS_data_t
// and UBX_ESF_MEAS_sensorData_t
void printESFMEASdata(UBX_ESF_MEAS_data_t ubxDataStruct)
{
Serial.println();
Serial.print(F("id: ")); // Print selected data
Serial.print(ubxDataStruct.id);
Serial.print(F(" numMeas: "));
Serial.println(ubxDataStruct.flags.bits.numMeas);
for (uint8_t num = 0; num < ubxDataStruct.flags.bits.numMeas; num++) // For each sensor
{
Serial.print(F("Sensor "));
Serial.print(num);
UBX_ESF_MEAS_sensorData_t sensorData;
myGPS.getSensorFusionMeasurement(&sensorData, ubxDataStruct, num); // Extract the data for one sensor
Serial.print(F(": Type: "));
Serial.print(sensorData.data.bits.dataType);
Serial.print(F(" Data: "));
Serial.println(sensorData.data.bits.dataField);
}
}
// Callback: printESFSTATUSdata will be called when new ESF STATUS data arrives
// See u-blox_structs.h for the full definition of UBX_ESF_STATUS_data_t
// and UBX_ESF_STATUS_sensorStatus_t
void printESFSTATUSdata(UBX_ESF_STATUS_data_t ubxDataStruct)
{
Serial.print(F("fusionMode: ")); // Print selected data
Serial.print(ubxDataStruct.fusionMode);
Serial.print(F(" numSens: "));
Serial.println(ubxDataStruct.numSens);
for (uint8_t num = 0; num < ubxDataStruct.numSens; num++) // For each sensor
{
Serial.print(F("Sensor "));
Serial.print(num);
UBX_ESF_STATUS_sensorStatus_t sensorStatus;
myGPS.getSensorFusionStatus(&sensorStatus, ubxDataStruct, num); // Extract the data for one sensor
Serial.print(F(": Type: "));
Serial.print(sensorStatus.sensStatus1.bits.type);
Serial.print(F(" Used: "));
Serial.print(sensorStatus.sensStatus1.bits.used);
Serial.print(F(" Ready: "));
Serial.print(sensorStatus.sensStatus1.bits.ready);
Serial.print(F(" Calib Status: "));
Serial.print(sensorStatus.sensStatus2.bits.calibStatus);
Serial.print(F(" Noisy: "));
Serial.println(sensorStatus.faults.bits.noisyMeas);
}
}
void setup()
{
Serial.begin(115200);
while (!Serial); //Wait for user to open terminal
Serial.println(F("SparkFun u-blox Example"));
Wire.begin();
//myGPS.enableDebugging(); // Uncomment this line to enable debug messages on Serial
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
{
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
while (1);
}
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
myGPS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
myGPS.setNavigationFrequency(1); //Produce one solution per second
myGPS.setHNRNavigationRate(1); //Set the High Navigation Rate to 1Hz
myGPS.setI2CpollingWait(50); //Allow checkUblox to poll I2C data every 50ms to keep up with the ESF MEAS messages
if (myGPS.setAutoESFALGcallback(&printESFALGdata) == true) // Enable automatic ESF ALG messages with callback to printESFALGdata
Serial.println(F("setAutoESFALGcallback successful"));
if (myGPS.setAutoESFINScallback(&printESFINSdata) == true) // Enable automatic ESF INS messages with callback to printESFINSdata
Serial.println(F("setAutoESFINScallback successful"));
if (myGPS.setAutoESFMEAScallback(&printESFMEASdata) == true) // Enable automatic ESF MEAS messages with callback to printESFMEASdata
Serial.println(F("setAutoESFMEAScallback successful"));
if (myGPS.setAutoESFSTATUScallback(&printESFSTATUSdata) == true) // Enable automatic ESF STATUS messages with callback to printESFSTATUSdata
Serial.println(F("setAutoESFSTATUScallback successful"));
}
void loop()
{
myGPS.checkUblox(); // Check for the arrival of new data and process it.
myGPS.checkCallbacks(); // Check if any callbacks are waiting to be processed.
Serial.print(".");
delay(25);
}