9DoF Breakout + Redboard Plus + Qwiic - Basics Example Error

Hello all!

I’m kicking off a new prototyping project and wanted to hit the ground running as quickly as possible. When I caught up on the latest with Sparkfun’s board, including the Qwiic system I was stoked to get a redboard and some Qwiic accessories. Currently I am rolling with a Redboard Plus and the 9DoF IMU breakout connect via a Qwiic cable. Following the instructions in the guide for the IMU, I flashed onto the redboard the basics example. Unfortunately, I immediately ran into a problem:

Initialization of the sensor returned: Data Underflow
Trying again...

I found one issue on Github with the same error, but both that one and the other post I can find on the forums here seem to be related to other boards, not my redboard plus. Naively, I expected this to be almost plug and play with the example code plus the Qwiic system, but clearly I’m missing something. Anyone else come across this issue?

Thanks!

Tim

Make sure you have the drivers installed https://learn.sparkfun.com/tutorials/re … ng-drivers ; and test with Arduino IDE instead if you are using PlatformIO (that error seems specific to an incorrect PlatformIO settings file) https://community.platformio.org/t/micr … rmio/22128

Make sure the board defs and/or custom entries are made, then re-try the basic example

It also might help to start over witht he basic ‘blink’, then move on to using the 9dof

Thank you for your reply! I should have mentioned that the 9DoF example wasn’t the first I tried. I did indeed load the blink example successfully to the redboard. I’ve also successfully tried the Qwiic LED Stick example suite and those work fine as well. So I2C is working correctly. It’s specifically the base example for the 9DoF breakout. All of which I’m doing entirely through the Arduino IDE. Hope that’s helpful!

Hi,

The ICM-20948 supports two different I2C addresses - selected by the ADR jumper pad. The “data underflow” error is normally a sign that the code is trying to use the wrong address. Please try changing the AD0_VAL from 1 to 0. This will tell the code to use the alternate address. This shouldn’t make any difference, but it might…?

I hope this helps,

Paul

Hi Paul!

Thank you for the reply and apologies for the delay to follow up, we were away from the holiday weekend. I was able to test the change you suggested, setting AD0_VAL from 1 to 0. Unfortunately no dice. I have also tested running the example on a Redboard Artemis Nano as well, with the same result. This is just about as vanilla a setup as I think you can get. So strange!

Cheers,

Tim

Hi Tim,

It does sound like you might have a faulty sensor. You are welcome to return it if needed: http://www.sparkfun.com/returns

But can I just check which 9-DoF board you have? The library example we’ve been discussing is for the ICM-20948 ( https://www.sparkfun.com/products/15335 ), but we also have a different 9-DoF board which uses completely different ICs and libraries ( https://www.sparkfun.com/products/19895 ). I’m assuming you do have the ICM-20948?

Apologies for the inconvenience,

Paul

TLDR; For anyone in the future that comes across this post, check your IMU carefully to confirm you’re using the right board with the right library! In this case I am using the ISM330DHCX and MMC5983MA breakout, but there’s also an ICM-20948 breakout. There are libraries available in the Arduino Library Manager for both.

Hi Paul,

You got me. I was using the wrong library. The two boards looked so similar I didn’t think anything of it. I sincerely apologize for the wild goose chase. I’ve successfully tested both the 6DoF library with the accelerometer and gyroscope as well as the magnetometer with the digital compass. The digital compass only seems to return values around 188 to 189, but I’m sure that’s some sort of calibration or setting that I need to tweak. I’ll research that one independently. Thank you so much for the help.

Cheers,

Tim

Hi Tim,

No worries - glad that’s working for you.

The MMC5983 “digital compass” examples are really simplistic. They assume the nominal zero (mid) point of the X and Y axes is 131072 (2^17) and then do a simple arctan2 to calculate an approximate heading. In reality, the mid point can be very different and changes with temperature especially.

Example7 is better. It does a proper set-reset of the sensor - when you press a key (send a character via the serial monitor) - and uses the difference as the sensor offset. But, it’s still not perfect as it does not calibrate the gain of each channel. There’s a lengthy discussion about it here: viewtopic.php?p=241235#p241235

Anyway, Example7 is a good place to start your compass adventure…! :smiley:

Best wishes,

Paul

The digital compass only seems to return values around 188 to 189

Magnetometers don’t work “out of the box” as compasses, because they need to be individually calibrated for their environment. At the very minimum an offset needs to be subtracted from each axis, and to determine that, you will need to run a separate program to collect data for a number of different sensor orientations, and estimate the offsets.

Complete calibration requires estimating nine parameters, as described in this forum post and the links therein: https://forum.pololu.com/t/correcting-t … eter/14315