Arduino Nano RP2040 Connect hangs/freezes when using IMU

Hi, I have an issue with both of my Nano RP2040 boards. They stop working after calling the IMU.accelerationAvailable function. After calling that function the board freezes and it gets very hard to connect to it and the Arduino editor prints errors like "Serial port busy" etc. Seemingly randomly I can connect to it and upload a sketch without the call to IMU.accelerationAvailable to unfreeze the board.

Is this a known issue with any possible workarounds?

#include <Arduino_LSM6DSOX.h>

void setup() {
  while (!Serial);

  Serial.print("Accelerometer sample rate = ");
  Serial.println(" Hz");
  Serial.println("Acceleration in g's");

void loop() {
  float x, y, z;

  Serial.println("Hangs just before calling IMU.accelerationAvailable()!");
  if (IMU.accelerationAvailable()) {
    Serial.println("It never reaches this line!");
    IMU.readAcceleration(x, y, z);


@monstersmurf, your topic has been moved to a more suitable section of the forum.

1 Like

I found the problem. I somehow managed to exclude this part of the code in the setup function:

  if (!IMU.begin()) {
    Serial.println("Failed to initialize IMU!");

    while (1);

After adding that code everything works as intended.

If you exclude that code the board will freeze and it gets quite tricky to reset it. I had to repeatedly mash the reset button and after a while I managed to get mass storage device opened so that I could upload the initial blink-sketch again.


Thanks for the feedback. You can mark your thread as solved by ticking the 'solution' checkbox of useful post that helped you ( post #3, your own one in this case :wink: ).


Makes it easier for others to find the solution.

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.