AutoPVT and autoNAVODO issue

I am trying to use the auto pvt and auto ODO callbacks to preocess speed, heading, altitude, and also odometer readings from the ublox max-M10. The callback for auto PVT works as expected, however the Odometer callback rarely gets called. It does eventually get called, and updates my readings locally, but it is random when it updates. Do i need to call checkUblox twice and specify the Class ID when calling checkUblox(), once for PVT, and once for ODO? any help would be appreciated.

setup

GPS.begin();
GPS.setI2COutput(COM_TYPE_UBX);
GPS.setNavigationFrequency(5);
GPS.enableOdometer();
GPS.resetOdometer();
GPS.setAutoPVTcallbackPtr(&PVT_callback);
GPS.setAutoNAVODOcallbackPtr(&ODO_callback);

loop

if (millis() - gps_check > 50) {
gps_check = millis();
GPS.checkUblox(); // Check for the arrival of new data and process it.
GPS.checkCallbacks(); // Check if any callbacks are waiting to be processed.


callbacks

void PVT_callback(UBX_NAV_PVT_data_t *ubxDataStruct) {
update_local_data = true;
int32_t speed_raw = ubxDataStruct->gSpeed;
int32_t heading_raw = ubxDataStruct->headMot;
int32_t altitude_raw = ubxDataStruct->hMSL;
altitude = (float)altitude_raw * 0.00328084;
speed = (float)speed_raw * 0.00223694;
heading = (float)heading_raw * 0.00001; }

void ODO_callback(UBX_NAV_ODO_data_t *ubxDataStruct) {
unsigned long distance = ubxDataStruct->distance; // Print the distance
miles = (float)distance * 0.0006213712;
odometer = (previous_odometer + miles);
trip_meter = (previous_trip_meter + miles);
}

Hi @andrewhawn ,

Which version of the library are you using? v3 (#include <SparkFun_u-blox_GNSS_v3.h>)?

I wonder if you are overloading the UART1 port? Unless you’ve disabled it, UART1 will be trying to output the standard NMEA messages. At 5Hz and the standard baud rate, you might be overloading it, producing weird results on it and the other ports. Please try adding GPS.setUART1Output(COM_TYPE_UBX); // Disable NMEA output on UART1

Everything else looks OK. You only need to call checkUblox once per loop. It will process all available messages.

You can remove the 50 millisecond gps_check timer. The library has a built-in timer to prevent you from pounding the I2C bus.

Just in case you have anything strange configured, maybe try GPS.factoryDefault(); delay(5000); immediately after the GPS.begin(); to reset the module back to its defaults. You only need to call this once; you can comment it after calling it once.

Let me know how it goes,
Paul

Thanks for the reply! I am using the v3 library. This project is on a boat, so i wont be able to test until this weekend but thank you for some direction. Does the module still send out data on the UART even though we are using i2c? But it makes sense it could overload with how big the PVT read is

Yes, UART1 will be trying to output the standard NMEA messages at the navigation rate. At 5Hz, that’s almost certainly more than the standard baud rate can handle.

Let us know how it goes and if you need more help,
Paul