Go Down

Topic: Sketch for reading the accelerometer values on Nano 33 BLE doesn't work  (Read 388 times) previous topic - next topic

Birkedahl

I loaded the SimpleAccelerometer.ino sketch (code below) from GitHub onto my nano 33 BLE but the serial monitor says " Failed to Initialize IMU!" which indicates the IMU isn't set up. 

Has anybody got this working on the nano 33 BLE/ Sense?  What am I missing?

Thanks!   

/*
  Arduino LSM9DS1 - Simple Accelerometer
  This example reads the acceleration values from the LSM9DS1
  sensor and continuously prints them to the Serial Monitor
  or Serial Plotter.
  The circuit:
  - Arduino Nano 33 BLE Sense
  created 10 Jul 2019
  by Riccardo Rizzo
  This example code is in the public domain.
*/

#include <Arduino_LSM9DS1.h>

void setup() {
  Serial.begin(9600);
  while (!Serial);
  Serial.println("Started");

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

  Serial.print("Accelerometer sample rate = ");
  Serial.print(IMU.accelerationSampleRate());
  Serial.println(" Hz");
  Serial.println();
  Serial.println("Acceleration in G's");
  Serial.println("X\tY\tZ");
}

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

  if (IMU.accelerationAvailable()) {
    IMU.readAcceleration(x, y, z);

    Serial.print(x);
    Serial.print('\t');
    Serial.print(y);
    Serial.print('\t');
    Serial.println(z);
  }
}

gbafamily

Open the IDE library manager and search for "nano 33 ble". Install the desired libraries and see if this helps.

If you have connected anything to the Nano BLE pins, disconnect then try the example again.

Birkedahl

Thanks but all libraries installed and nothing is connected to the pins...

gbafamily


Jacks-Pixels

Same for me ... it works fine.
Look at Nano 33 BLE to find the specifics libs.

Birkedahl

So I have all libraries tagged with "nano 33 BLE" installed.  The SimpleAccelerometer sketch uploads and runs - but gives the "IMU Failed to Initialize!" message on the serial monitor.  Perhaps the board is bad? 

Also:  I have the nano 33 BLE (not Sense) board, but the sketch comments indicate it was created for the nano 33 BLE Sense.  I assumed the sketch would work for both models...
 

msdsmith

I have the nano 33 BLE (not Sense) board, but the sketch comments indicate it was created for the nano 33 BLE Sense.  I assumed the sketch would work for both models...
 
That sketch worked for me without modification on a nano 33 BLE. Perhaps it is an issue with your board?

Have you tried uploading any other sketches?

Birkedahl

The "Arduino people" had me run the sketch MultiSpeedI2CScanner.ino which shows the board is not reading I2C devices correctly..  So conclusion is a bad board - return it for replacement..

pert

Thanks for taking the time to post an update with the results of the investigation Birkedahl!

Go Up