Skip to content

Commit 8b9bba9

Browse files
authored
add note about I2C issues with certain microcontrollers (#35)
* fix example in README the example wasn't aligned anymore with the current implementation and thus didn't compile if copied directly. * add note about I2C issues with certain microcontrollers while i can use the sensor (& library) directly with my STM32F4 it doesn't work out of the box with my ESP32C6. after some digging & debugging i found [esp-hal#352] which explains this same problem (though for a BNO080) and the solution for it (increased timeout). i think it's worth adding a note here as people will find this library more easily than the solution (esp. since Adafruit doesn't mention the solution and kind-of just says "meh, don't use it with those microcontrollers"). [esp-hal#352]: esp-rs/esp-hal#352 * add note about sensor startup
1 parent f8a4151 commit 8b9bba9

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

README.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ Uses and re-exports [mint](https://crates.io/crates/mint)'s
1919
and [EulerAngles](https://docs.rs/mint/0.5.1/mint/struct.EulerAngles.html) for Euler angles
2020
and [Vector3](https://docs.rs/mint/0.5.1/mint/struct.Vector3.html) for sensor readings.
2121

22+
## Usage notes
23+
### Important note on I2C issues
24+
As [noted e.g. by Adafruit](https://learn.adafruit.com/adafruit-bno055-absolute-orientation-sensor) the sensor has issues
25+
with its I2C implementation, which causes it to not work correctly with certain microcontrollers.
26+
27+
This seems to be caused by clock stretching, thus running at lower I2C speeds and with increased I2C timeouts should
28+
resolve the issue.
29+
30+
### Initial startup delay
31+
The sensor has an initial startup time during which interaction with it will fail.
32+
As per [the documentation](https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bno055-ds000.pdf)
33+
this is in the 400ms - 650ms range (consult chapter 1.2 / page 14 for further details).
34+
If your microcontroller is faster in starting up you might have to delay before talking to the sensor (or retry on failure).
35+
2236
## Feature flags
2337

2438
### `std`
@@ -49,12 +63,12 @@ so be careful that you're not enabling `serde`'s `std` feature by accident (see
4963
// let delay = ...;
5064
5165
// Init BNO055 IMU
52-
let imu = bno055::Bno055::new(i2c);
66+
let mut imu = bno055::Bno055::new(i2c);
5367
5468
imu.init(&mut delay)?;
5569
5670
// Enable 9-degrees-of-freedom sensor fusion mode with fast magnetometer calibration
57-
imu.set_mode(bno055::BNO055OperationMode::NDOF)?;
71+
imu.set_mode(bno055::BNO055OperationMode::NDOF, &mut delay)?;
5872
5973
Ok(imu)
6074
```

0 commit comments

Comments
 (0)