imu_bhi260.ino
The BHI260AP 16-bit accelerometer opens with the Arduino_BHY2 library: accel.checkNewData then x/y/z in g. The docs insist: BHY2.update() is the hub mailbox pump — without it, no sensor answers.
Hardware
An Arduino Nicla Sense ME (nRF52832, BLE only) with Bosch BHI260AP hub, BMM150, BMP390, BME688 sensors, RGB LED on an I2C driver and LiPo charger. The board alone on USB; the BHI260AP and its BHY2 firmware are factory-flashed in its dedicated QSPI flash.
Wiring
No wiring: all Bosch sensors are soldered and internally wired to the hub. The connector pins stay free.
How it works
BHY2.begin boots the hub (prover/advanced); accel.begin enables the sensor in the BHY2 firmware; update() drains FIFOs, checkNewData reads the latest frame. Output in g, 1 g ≈ 9.81 m/s².
Running it
Programmed from the Arduino IDE (ArduinoCore-mbed); Arduino_BHY2 and Nicla_System libraries; USB through a serial bridge.
Variants
Add gyro and rotation vector (the hub BSX fusion), raise the update rate for real time, or stream the 9 axes over BLE.
imu_bhi260.ino
// Les capteurs du Sense ME ne pendent pas sur l'I2C direct :
// ils sont derrière le hub BHI260AP, servi par Arduino_BHY2.
// Règle docs-db : BHY2.update() est la pompe aux lettres du hub,
// à appeler en continu.
#include "Arduino_BHY2.h"
SensorAccel accel(0);
void setup() {
Serial.begin(115200);
BHY2.begin();
accel.begin();
BHY2.update(); // premier échange avec le hub
}
void loop() {
BHY2.update(); // OBLIGATOIRE à chaque tour de boucle
if (accel.checkNewData()) {
Serial.print("ax="); Serial.print(accel.x());
Serial.print(" ay="); Serial.print(accel.y());
Serial.print(" az="); Serial.println(accel.z());
}
delay(10);
}