A Quick Look at the BMI270 Sensor on the Arduino Nano 33 BLE Board
The Arduino Nano 33 BLE is a fantastic little board packed with sensors, and one of the key components for motion sensing is the integrated Bosch BMI270 Inertial Measurement Unit (IMU).
This powerful component combines a 3-axis accelerometer and a 3-axis gyroscope into one tiny package. It's what allows the Arduino to understand its orientation, detect motion, count steps, and track rotation in 3D space.
This code uses the BMI270 sensor on the board, to detect the motion when the board is moved clockwise or anti clockwise. Below is the snapshot of the BMI270 connection from the board schematic.
Important points for using BMI270 including calibration
- Arduino_BMI270_BMM150.h shall be used
- BMI270 uses I2C to interface to the NINA-B306 module
- I2C address - 0x68 (default) => This address is used when the SDO pin of the BMI270 is pulled to GND.
- I2C address - 0x69 => This alternative address is selected by pulling the SDO pin to VDDIO.
- The important point in the coding is the rate at which we are moving left or right. The slowest we move the lower threshold has to be set. In our code, the threshold was set after thorough testing. (call it calibration step)
- Data is output on the serial port for purpose of debug and value read
Coding in Arduino IDE
Whether you are building a gesture-controlled interface or a simple level indicator, the BMI270 is doing the heavy lifting behind the scenes. Here is a dive into the code using the Arduino IDE. Use this as a base to start using BMI270 in your next project!
#include <Arduino_BMI270_BMM150.h> // Correct library for Nano 33 BLE Sense
void setup() {
Serial.begin(115200);
delay(2000);
Serial.println("Starting IMU (BMI270)...");
if (!IMU.begin()) {
Serial.println("ERROR: BMI270 IMU not detected!");
while (1);
}
Serial.println("BMI270 IMU initialized");
}
void loop() {
float gx, gy, gz;
if (IMU.gyroscopeAvailable()) {
IMU.readGyroscope(gx, gy, gz);
Serial.print("Gyro Z = ");
Serial.println(gz);
if (gz > 0.6) {
Serial.println("→ Moving LEFT");
}
else if (gz < 0.12) {
Serial.println("← Moving RIGHT");
}
}
delay(200);
}
0 Comments