Sparkfun Ublox library doesn't work with I2C and Thing Plus C Board

Not sure this is in the right forum thread, but since I’m using the Thing Plus C board thought I’d put it here. I’m still working to integrate GPs and inertial measurement platform to my high altitude balloon payload package. Recently acquired a UBlox MAX M8C gps module that will work up to 150,000 feet. Have tried multiple libraries (serial and I2C) to get it to work. None have worked so far. Some serial libraries want to use Softserial on the ESP32 which seems stupid since the processor has two serial ports available. Would prefer to use I2C so have been concentrating on use of the Sparkfun uBlox library (2.2.10) which I downloaded from the Arduino site.

So far, I have been unable to get any of the examples to recognize the GPS module over the I2C bus. Upon initiation the the “begin” code returns a boolean false which halts the execution. When I scan the I2C bus it reports a device at 0x42 which is the address specified in the library as default address. All other devices on the bus are correctly reported with unique addresses.

I have confirmed that the module works using u center from Ublox and a serial link.

Would appreciate any help or suggestions that might help me get over this hump.

one of the Examples I’ve used is below:

[code}/*

Reading two altitudes - Mean Sea Level and Ellipsode

By: Nathan Seidle

SparkFun Electronics

Date: January 3rd, 2019

License: MIT. See license file for more information but you can

basically do whatever you want with this code.

This example shows how to query a Ublox module for its lat/long/altitude.

getAltitude() reports mm above ellipsode model of the globe. There are some

instances where altitude above Mean Sea Level is better. This example shows how

to use getAltitudeMSL(). The difference varies but is ~20m.

Ellipsoid model: https://www.esri.com/news/arcuser/0703/geoid1of3.html

Difference between Ellipsoid Model and Mean Sea Level: https://eos-gnss.com/elevation-for-beginners/

Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!

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;

long lastTime = 0; //Tracks the passing of 2000ms (2 seconds)

void setup()

{

Serial.begin(57600);

while (!Serial); //Wait for user to open terminal

Serial.println(“SparkFun Ublox Example”);

Wire.begin();

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);

}

}

void loop()

{

//Query module only every second. Doing it more often will just cause I2C traffic.

//The module only responds when a new position is available

if (millis() - lastTime > 1000)

{

lastTime = millis(); //Update the timer

long latitude = myGPS.getLatitude();

Serial.print(F("Lat: "));

Serial.print(latitude);

long longitude = myGPS.getLongitude();

Serial.print(F(" Long: "));

Serial.print(longitude);

Serial.print(F(" (degrees * 10^-7)"));

long altitude = myGPS.getAltitude();

Serial.print(F(" Alt: "));

Serial.print(altitude);

Serial.print(F(" (mm)"));

long altitudeMSL = myGPS.getAltitudeMSL();

Serial.print(F(" AltMSL: "));

Serial.print(altitudeMSL);

Serial.print(F(" (mm)"));

Serial.println();

}

}


Hi,

We don’t make or sell a MAX-M8C board. Can you please post a link to the exact board you are using and we will do our best to help. The GNSS library works just fine with the Thing Plus C - I use it every day. Let’s see if we can work out why you’re having issues.

Best wishes,

Paul

PS. It looks like you are trying to use an example from the obsolete version of the library. Please use the Arduino Library Manager to download the latest version of the SparkFun u-blox GNSS Library. The new library uses SFE_UBLOX_GNSS not SFE_UBLOX_GPS.

Ok, loaded new library and ran Example10_AltitudeMSL. Same result : “u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.”

Link to module vender: https://store.uputronics.com/index.php? … duct_id=72

Hi,

Thanks for the link. Anthony designs good boards and it will have a genuine MAX-M8 on it. No worries about it possibly being a cloned/copied part.

I’ve tried Example10 on a Thing Plus C connected to a MAX-M8Q board I used on an earlier project. It works just fine. (See photo below)

I don’t know what to suggest. Maybe try adding myGNSS.enableDebugging(); before the myGNSS.begin(). That should give some clues as to why the begin is failing?

Once you get this working, please remember to set the “Dynamic Model” to “Airborne < 1g” before you launch. That’s essential for high altitude. See Example19 for details.

Best wishes,

Paul

Another thought:

Please check that you have the UBX protocol enabled on the I2C port. It is enabled by default but maybe it has been disabled?

In u-center, use View \ Messages View and check UBX-CFG-PRT for the 0-I2C port. You should see UBX in both Protocol In and Protocol Out? (See image below).

Paul,

added that line of code. Here is what the Thing sent back:

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

configsip: 0, SPIWP:0xee

clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

mode:DIO, clock div:1

load:0x3fff0018,len:4

load:0x3fff001c,len:1216

ho 0 tail 12 room 4

load:0x40078000,len:10944

load:0x40080400,len:6388

entry 0x400806b4

E (144) psram: PSRAM ID read error: 0xffffffff

SparkFun u-blox Example

createFileBuffer: Warning. fileBufferSize is zero. Data logging is not possible.

begin: isConnected - second attempt

begin: isConnected - third attempt

u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.

OK. Please do check that UBX is enabled for both Protocol In and Protocol Out on the I2C port. If either is disabled, it will stop the library dead in its tracks…

You can factory-reset the module via u-center if required. Select View \ Message View. Select UBX-CFG-CFG.

Select “Revert to default configuration” and click “Send” at the bottom of the window.

Then select “Save current configuration” and click “Send” again.

(See attached image.)

Let me know if you need some pointers on how to use Serial instead of I2C.

Best wishes,

Paul

Paul,

I did the UBX check and everything was identical to your screen shot. If you have pointers for using the Thing Plus with HARDWARE serial, would love to have them at this point. Haven’t checked the new library yet for serial operation, but will now.

Thanks for your help!

Eric

Hi Eric,

OK. Here is where we get into the specifics of the Arduino Board definition.

Please have a look at this issue:

https://github.com/sparkfunX/SparkFun_E … C/issues/4

If, like me, you are using the ESP32 Dev Module board definition, then we need to define Serial1 so it uses the 17/TX and 16/RX breakout pins.

The critical lines in the following code are:

Serial1.begin(9600, SERIAL_8N1, 16, 17); // Configure Serial1: 9600 baud, TX on pin 17, RX on pin 16
if (myGNSS.begin(Serial1) == false) // Connect to the u-blox module using Serial1

The whole example - which is Example10 adapted for Serial1 on the Thing Plus C (ESP32 Dev Module) - is included below.

Let me know if this works.

Paul

#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS

SFE_UBLOX_GNSS myGNSS;

unsigned long lastTime = 0; //Tracks millis

void setup()
{
  Serial.begin(115200);
  while (!Serial); //Wait for user to open terminal
  Serial.println("SparkFun u-blox Example");

  Serial1.begin(9600, SERIAL_8N1, 16, 17); // Configure Serial1: 9600 baud, TX on pin 17, RX on pin 16

  if (myGNSS.begin(Serial1) == false) //Connect to the u-blox module using Serial1
  {
    Serial.println(F("u-blox GNSS not detected. Please check wiring. Freezing."));
    while (1);
  }
}

void loop()
{
  //Query module only every second. Doing it more often will just cause extra traffic.
  //The module only responds when a new position is available
  if (millis() - lastTime > 1000)
  {
    lastTime = millis(); //Update the timer
    
    long latitude = myGNSS.getLatitude();
    Serial.print(F("Lat: "));
    Serial.print(latitude);

    long longitude = myGNSS.getLongitude();
    Serial.print(F(" Long: "));
    Serial.print(longitude);
    Serial.print(F(" (degrees * 10^-7)"));

    long altitude = myGNSS.getAltitude();
    Serial.print(F(" Alt: "));
    Serial.print(altitude);
    Serial.print(F(" (mm)"));

    long altitudeMSL = myGNSS.getAltitudeMSL();
    Serial.print(F(" AltMSL: "));
    Serial.print(altitudeMSL);
    Serial.print(F(" (mm)"));

    Serial.println();
  }
}

Hi Eric,

A couple more thoughts on this:

Please make sure you have the latest ESP32 board package (v2.0.3) installed. v2.0.1 had a bug which stopped I2C working with devices which “clock-stretch”. The u-blox modules clock-stretch.

https://github.com/espressif/arduino-esp32/issues/5875

Also, please be careful which board you have selected. For the Thing Plus C, we recommend selecting the “ESP32 Dev Module”, not the “SparkFun ESP32 Thing Plus”. The ESP32 Dev Module has the correct pin definitions for Wire (SCL & SDA), but doesn’t define pins for Serial1 (hence the code in the previous post). The SparkFun ESP32 Thing Plus has the pin definitions for Serial1, but selects different pins for Wire (SCL & SDA). If you want to understand more about this, have a look at the pins_arduino.h for each:

ESP32 Dev Module:

https://github.com/espressif/arduino-es … .h#L17-L18

SparkFun ESP32 Thing Plus:

https://github.com/espressif/arduino-es … .h#L18-L25

Best wishes,

Paul

Paul,

Eureka! In the Arduino Board Manager I was using the Arduino ESP32 WROVER module since it seemed like the closest match and I knew the Thing Plus board had problems. Made the switch and it works over I2C. I feel a bit stupid since I knew that was the suggested board. But other I2C devices worked. Sure I tried it in the past and had problems, then made the switch to the WROVER.

Anyway, thanks so much for your help.

Eric

Hi Eric,

No worries - I’m glad that’s working for you!

Don’t forget about the dynamic model. Changing that is essential for high altitude work.

You might enjoy: https://arxiv.org/abs/1904.04321

(Click PDF in the top right corner to download the paper.)

Very best wishes,

Paul

Hi Technical Support,

I have been running into similar issues with the ZED-F9K module. While running some of the sample examples from the Sparkfun library, the serial monitor shows garbage output (picture attached below). I have tried to perform dynamic calibration at 15-25 mph speeds but the output is still the same. Any help in this matter is appreciated!

Hi @madyasha,

Garbage in the serial monitor is usually a sign of the baud rate not being correct. Our examples usually use 115200 baud. Please check you have 115200 selected in the serial monitor.

If that is not the cause then you will need to give us more details:

Which example(s) are you testing?

Which microcontroller board are you using?

How do you have the GNSS connected: UART or I2C (Qwiic)?

Have you made any changes to the examples?

Are you trying to print UBX data directly? (UBX data is ‘binary’ and not printable.)

Best wishes,

Paul