XIAO nRF52840 Sense: unable to access onboard IMU

I’m trying to read the onboard LSM6DS3TR-C IMU on a Seeed Studio XIAO nRF52840 Sense board using a small Arduino C test program. The setup is:

Board: Seeed Studio XIAO nRF52840 Sense
Core: Seeed nRF52 Boards, 1.1.13
Arduino IDE 1.8.19
Platform: macOS Sequoia

The program compiles and uploads successfully, but produces no output in Serial Monitor. It seems to be hanging when executing Wire1.endTransmission().

Test program:


#include <Wire.h>

void setup() {
  Serial.begin(9600);

  int powerpin = 15; // Enable the IMU power rail
  pinMode(powerpin, OUTPUT);
  digitalWrite(powerpin, HIGH);
  delay(10);
}

void loop() {
  Wire1.begin();
  Serial.println("Wire1 started");

  Wire1.beginTransmission(0x6A);
  Wire1.write(0x0F);
  Wire1.endTransmission(false);
  
  Wire1.requestFrom(0x6A, 1);
  Serial.print("WHO_AM_I = 0x");
  Serial.println(Wire1.read(), HEX);
  delay(1000);
}

I’ve tested the same program on a XIAO MG24, with the Silicon Labs core, with powerpin changed to 19, and this prints the expected values:

Wire1 started
WHO_AM_I = 0x6A

Any suggestions for further tests would be appreciated.

Hi there,

So t’s either the BSP or the LIB version, Look back there are some threads on it being documented, I think it was the wire or Wire1 that had the issue’s. it works with the seeed LIB though forsure. :grin: :+1:

HTH
GL :slight_smile: PJ :v:

I probably have the most demo’s of the IMU on here, btw. Check out the Motion, Fall and Park . demo’s for more.

Hi, thanks for the prompt reply! It seems to be a problem with Wire1 rather than the IMU.

it works with the seeed LIB though forsure

I don’t quite understand - which Seeed LIB?

I probably have the most demo’s of the IMU on here

Great - I’ll check them out, although at the moment I’ll be happy just to get WhoAmI working!

Hi there,
Here some tests you can try,
HTH
GL :slight_smile: PJ :v:

drag and drop the uf2 , and the INO. :+1:

should help narrow it down

IMU_CAP1.zip (77.6 KB)

Hi there,

So I just went and compiled the Low level example and uploaded and ran without issue.
I used the current BSP 1.1.13

FQBN: Seeeduino:nrf52:xiaonRF52840Sense
Using board 'xiaonRF52840Sense' from platform in folder: C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\nrf52\1.1.13
Using core 'nRF5' from platform in folder: C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\nrf52\1.1.13
----

Sketch uses 46880 bytes (5%) of program storage space. Maximum is 811008 bytes.
Global variables use 7652 bytes (3%) of dynamic memory, leaving 229916 bytes for local variables. Maximum is 237568 bytes.
Performing 1200-bps touch reset on serial port COM14
Waiting for upload port...
No upload port found, using COM14 as fallback
"C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\nrf52\1.1.13/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe" --verbose dfu serial -pkg "C:\Users\Dude\AppData\Local\arduino\sketches\853C867E6CF9E33730F30F970CE7DE42/LowLevelExample.ino.zip" -p COM14 -b 115200 --singlebank
Upgrading target on COM14 with DFU package C:\Users\Dude\AppData\Local\arduino\sketches\853C867E6CF9E33730F30F970CE7DE42\LowLevelExample.ino.zip. Flow control is disabled, Single bank, Touch disabled
Opened serial port COM14
Starting DFU upgrade of type 4, SoftDevice size: 0, bootloader size: 0, application size: 46888
Sending DFU start packet
Sending DFU init packet
Sending firmware file
########################################
########################################
############
Activating new firmware
Device programmed.

DFU upgrade took 3.405799150466919s


serial output

Device OK.

Accelerometer Counts:
 X = 0
 Y = 0
 Z = 0

Total reported Errors and Warnings: 0

Accelerometer Counts:
 X = -317
 Y = -143
 Z = 4061

Total reported Errors and Warnings: 0

HTH
GL :slight_smile: PJ :v:

I couldn’t try your example because I don’t have a XIAO expansion board. However I noticed that it refers to “built with BSP 2.9.2” which is the Seeed nRF52 mbed-enabled Boards core. So I tried the latest version of that, 2.9.3, with my test program and it worked:

Wire1 started
WHO_AM_I = 0x6A

So has anyone managed to access the IMU using the Seeed nRF52 Boards core (rather than the mbed core)?

Please install “Seeed Arduino LSM6DS3 by Seeed Studio”. If you select the “Seeed nRF52 Boards/Seeed XIAO nRF52840 Sense” board, the examples will run.

Hi there,

LOL
:grin:
Ah’ the one I just posted uses the BSP 1.1.13 Which is the latest “Seeed NRF52 Boards” NON- Mbed Scroll right the compiler output window.
I used the low lever example in Arduino.l

GL :slight_smile: PJ :v:

OK, thanks for that suggestion. On a hunch I did Burn Bootloader, and now both the LowLevelExample and my test program are working as expected. I think my board had become screwed up in some way.