XIAO BLE SENSE cannot communicate with IMU sensor

Hello community,

I have just received two XIAO BLE SENSE boards and try to run the IMU examples. However, I am not able to properly initialize the sensor and read actual values. I have followed the example from the wiki, programming via the latest Arduino IDE (after installing the board support package, confirming blink to work and installing the library for the IMU sensor) and have also tried the CircuitPython example on using the IMU as per the posing on this forum.

IMU.begin() fails with error code 1 - hardware error.

When running the i2c_scanner from the Arduino Playground, I do not detect the IMU device on the I2C bus, which may be due to the fact that the device is not properly powered. I have tried to include

#define PIN_LSM6DS3TR_C_POWER (15)
...
pinMode(PIN_LSM6DS3TR_C_POWER, OUTPUT);
digitalWrite(PIN_LSM6DS3TR_C_POWER, HIGH);

but to no avail. When I add another I2C sensor, it is properly detected so the I2C bus seems to be working OK.

Since the board is so compact, I do not see how I can 1) easily confirm presence of the sensor and 2) confirm (measure) power to the sensor. There is a microphone soldered on the board, so I expect to have a BLE SENSE board.

Any help is appreciated!

1 Like

Sigh…
I think that the XIAO BLE boards are terrific pieces of hardware, but the Seeed development software releases are VERRRRRY frustrating.

So, here’s a way to use the IMU on the XIAO BLE Sense. (You can try other board release package versions and different libraries, but this works for me. I won’t bore you with details of all of the stuff I tried that did not work. I tested the following today, August 15, 2022, but those Seeed guys might change something that screws the pooch. Wouldn’t be the first time. Sigh…)

First of all, if you have any libraries that have a file named LSM6DS3.h, move their directory away from your Sketchbook\Libraries directory. (I’m speaking specifically of the Arduino_LSM6DS3 library. Warning: Don’t just rename the library directory, move it to some place completely away from your Sketchbook and Sketchbook\Libraries).

Next, use the Arduino Libraries Manager to install the Seed Arduino LSM6DS3 library version 2.0.3

Now, if you have not installed the Seeed nrf52 mbed-enabled Boards package, version 2.7.2, use the Arduino Boards manager to install it.

For a new board installation, you may have to exit the Arduino IDE and re-invoke it to see the next results:

Select the Seeed XIAO BLE Sense - nrf52840 board from the board package you just installed.

Finally (well, almost finally):
There is a sketch named HighLevelExample in the Seeed Arduino LSM6DS3 library. It works for me with no modifications and no problems.

Not wanting to go through this every time I want to use (or tell someone how to use) the LSM6DS3 on the XIAO BLE Sense, I modified that file to print the board version and library version that I used to create the output, and I attached the zipped project below.

Finally (Yes, I promise: Finally!):
Here’s the output up to the end of the first time through loop():

XIAO BLE Sense test of LSM6DS3 compiled on Aug 15 2022 at 14:00:06
Seeed mbed-enabled nrf52 Boards-> Seeed XIAO BLE Sense - nrf52480
From board release verion 2.7.6
Using Seeed Arduino LSM6DS3 Library version 2.0.3

Device OK!

Accelerometer:
 X1 = -0.0039
 Y1 = -0.0590
 Z1 = 1.0287

Gyroscope:
 X1 = 0.4900
 Y1 = -2.3800
 Z1 = 0.2800

Thermometer:
 Degrees C1 = 29.9375
 Degrees F1 = 85.8875

Regards,

Dave

Seeed mbed-enabled nrf52 package.

Daves_HighLevelExample.zip (1.5 KB)

3 Likes

Hello Dave,

Thank you so much! Following your outline, I have reinstalled board package (took the mbed-enabled version) and the Arduino provided library (as opposed to the externally provided ZIP) and the IMU chip is now connecting and the HighLevelExample works as expected, generating proper data. I figure it must be due to an incorrect definition of the IMU (6D) power pin?

Thanks again, I can now move on with my project!

Ton

I think one big difference is that the XIAO BLE uses the second I2C interface with internal CPU connections not brought out to external package pins. The Seeed library code uses Wire1 rather than Wire used in non-Seeed libraries you may come across.

This excellent hardware design means that you can connect any I2C device to the external SDA and SCL pins without havig to worry about I2C address conflicts with the on-board stuff.

Regards,

Dave

That makes perfect sense. In hindsight, I could have picked this up from the schematic diagram…

Hi Dave, were you able to get it working with the Arduino/Adafruit based image (not the mbed OS one)

Didn’t try the Arduino_LSM6DS3 library with my XIAO BLE boards…

I consider it to be a major accomplishment for me to find and successfullly deploy Seeed-specific software such as the Seeed Arduino LSM6DS3 library with Seeed boards.

Regards,

Dave

:smiling_face_with_three_hearts: Thank you for the Boost…
worked like a charm…

XIAO BLE Sense test of LSM6DS3 compiled on Sep 16 2022 at 00:02:39
Seeed mbed-enabled nrf52 Boards-> Seeed XIAO BLE Sense - nrf52480
From board release verion 2.7.6
Using Seeed Arduino LSM6DS3 Library version 2.0.3
Device OK!
Accelerometer:
X1 = 0.0000
Y1 = 0.0259
Z1 = 0.9560
Gyroscope:
X1 = 32.0600
Y1 = 4.5500
Z1 = 12.6700
Thermometer:
Degrees C1 = 27.7188
Degrees F1 = 81.8938

I followed you post and When it got past the Lib error I began to smile.
too bad about the battery voltage issue. man!!, I want to send imu and battery data over the BLE link
to my phone app. I hope they get this tight little package correct soon.
thanks again.
Kings regards,
Pj

Hi everyone,
damn, why is the hardware of the Xiao-BLE Sense so good. I would love to throw it away because of the bad software(support). But it has everything I need in a super small format.
I run the board in the non-mbed version 1.0.0. these gives access to all Adafruit libraries which work great. Unfortunately I cannot access the IMU sensors LSM6DS3 or microphone. The Seeed Arduino LSM6DS3 Library seems to take the wrong wiring information from the incompatible board files.
Does it make sense to spend more time for a solution for the Adafriut-friendly 1.0.0 board or should I focus on board release version 2.7.6 for the Arduino33 way.
What is your opinion?

I’m having a similar(?) issue: I get static, incorrect readings from the IMU, but no errors.

 X1 = 13.7753
 Y1 = 13.7753
 Z1 = 13.7753

Gyroscope:
 X1 = -1623.2300
 Y1 = -1623.2300
 Z1 = -1623.2300

Thermometer:
 Degrees C1 = inf
 Degrees F1 = inf

I suspect this is because I’m using the 1.0.0 version of the mbed library, and not the 2.7.2 version.

The reason I’m doing this is that when I attempt to install the mbed-enabled library, I get errors:

Tool Seeeduino:openocd@0.11.0-arduino2 already installed
Tool Seeeduino:arm-none-eabi-gcc@7-2017q4 already installed
Tool Seeeduino:bossac@1.9.1-arduino2 already installed
Tool Seeeduino:dfu-util@0.10.0-arduino1 already installed
Downloading packages
Replacing platform Seeeduino:mbed@1.0.0 with Seeeduino:mbed@2.7.2
Uninstalling Seeeduino:mbed@1.0.0
Platform Seeeduino:mbed@1.0.0 uninstalled
Uninstalling Seeeduino:CMSIS@5.7.0, tool is no more required
Uninstalling Seeeduino:arm-none-eabi-gcc@9-2019q4, tool is no more required
Tool Seeeduino:arm-none-eabi-gcc@9-2019q4 uninstalled
Uninstalling Seeeduino:nrfjprog@9.4.0, tool is no more required
Tool Seeeduino:nrfjprog@9.4.0 uninstalled
Configuring platform.
**WARNING cannot configure platform: exit status 127**
Platform Seeeduino:mbed@2.7.2 installed

I get this error on both version 2.6.1 and 2.7.2. Then, as a result of the platform not being configured (I suspect), when I try to compile or upload, I get this error:

Error resolving FQBN: getting build properties for board Seeeduino:mbed:xiaonRF52840Sense: invalid option 'softdevice'

Compilation error: Error resolving FQBN: getting build properties for board Seeeduino:mbed:xiaonRF52840Sense: invalid option 'softdevice'

Any help would be appreciated.

Is there a trick to getting the 2.7.2 board release installed. I keep getting an error 127, and it fails to configure the platform = can’t compile.

I’m getting the same problem, did you manage to find a solution to this? I’m trying to have sleep mode and IMU working together. However it seems that I need version 1.0.0 for sleep, but version 2.6.1/2.7.2 for IMU to work.

Hi Rhys3logy,

It may not be the right way, but I am using the IMU implemented in “Seeed XIAO nRF52840 Sense” on “Seeed nRF52 Borads 1.0.0” (non mbed) in the following way

Board library: Seeed nRF52 Borads 1.0.0 (non mbed)
Board : Seeed nRF52 Borads / Seeed XIAO nRF52840 Sense
IMU library: Seeed_Arduino_LSM6DS3
–>Replace “Wire” in LSM6DS3.cpp with “Wire1”.
“#define Wire Wire1” does not work as expected, so I rewrote Wire to Wire1.

2 Likes

Works great! Thank you :smile:

Xiao BLE Sense IMU Activity Demo on Dev Board
Quick Video of the IMU activity Demo Running on the Xiao Development board. After Resetting the display shows “Grab Me Demo” if touched moved or vibrated (1.5 G) Sensitivity is set, Beeps, and displays “moved” whenever it’s disturbed…

HTH
AMA
GL :slight_smile:

Hi Dave,
I followed your steps and tried the HighLevelExample sketch but I get a device error and static values for the accelerometer and gyroscope. The only differences are that I’m on Mac OS and Arduino IDE version 2.0.3. Have you tried it on the latest Arduino IDE version or IDE version doesn’t matter?

The LED blink example works fine though.

Thanks for your help.
Hardeep.

Screenshots:

@ aovestdipaperino

I tried that library but no response in Serial Monitor. I even tried uninstalling Seeed Studio LSM6DS3 library. No luck.

Could it be the faulty chip? I bought this board just for the IMU application in my project. :frowning:

I ended up forking the Arduino library for Nano Sense and made it work with Xiao in RTOS world.

When using “Seeed nRF52 Boards 1.0.0”,
#include <Arduino.h>
#include <Adafruit_TinyUSB.h>
may be required.

Please also refer to the following

It may not be the right way, but I am using the IMU implemented in “Seeed XIAO nRF52840 Sense” on “Seeed nRF52 Borads 1.0.0” (non mbed) in the following way
Board library: Seeed nRF52 Borads 1.0.0 (non mbed)
Board : Seeed nRF52 Borads / Seeed XIAO nRF52840 Sense
IMU library: Seeed_Arduino_LSM6DS3
–>Replace “Wire” in LSM6DS3.cpp with “Wire1”.
“#define Wire Wire1” does not work as expected, so I rewrote Wire to Wire1.

Or if you use “Seeed nRF52 mbed-enabled Boards 2.8.1”, IMU will work without any problem.