Cannot initialize IMU on Xiao Sense when using PlatformIO

I’m programming using PlatformIO, for which there is unfortunately currently no official support (for reference this PR has been open for 2 years now…)

#include <Arduino_LSM6DS3.h>
IMU.begin(); // Returns 0
IMU.readAcceleration(..); // Returns bogus values

I checked that I’m testing on a Xiao Sense and not Xiao BLE classic.
From what I’ve gathered this could be due to the IMU reading from the wrong I2C bus but I’m not sure. If that’s the case the issue is probably more on the PlatformIO configuration side, but I figured I’d ask here if anyone has had this issue ?

Hi there,
It works fine… I use it.
What does you platform INI look like?
Be sure to check the box for use Arduino Libraries in the project open dialog.
Compiles, and works, allows Debugging as well.
GL :slight_smile: PJ

Thanks @PJ_Glasso,
here is my platformio.ini below. Note that I’m using I2C for other peripherals (EEPROM for instance) but IMU.begin() returns 0 even if it’s initialized before them.
I’ve read somewhere that IMU uses an internal I2C bus different from the one that is exposed on the Xiao to avoid conflicts, but I couldn’t find where this is set.

Note that I’m using the adafruit fork (which I believe uses this variant.cpp).

monitor_speed = 115200
upload_speed = 115200
build_flags = 

framework = arduino
lib_deps = 
	adafruit/Adafruit MCP23017 Arduino [email protected]
	robtillaart/[email protected]

platform =
board = xiaoblesense_adafruit

Okay I managed to get IMU to work using :

instead of :

I haven’t looked at how the libraries are different but it goes in the direction of the I2C bus being the wrong one (as in both cases the address is 0x6A).
Thanks anyway !

1 Like

Hi there,
Nice, As I stated it works properly and so does the Debugging So you are on the right path.
The trick is there are several libs, that work on certain INI environments you 'll find this as you proceed.
GL :slight_smile: PJ