1 unstable release
| 0.1.0 | Feb 10, 2026 |
|---|
#1015 in Embedded development
28KB
315 lines
bh1750-embedded
A platform-agnostic, no_std driver for the BH1750 / BH1750FVI ambient light sensor, built on the embedded-hal traits.
This implementation is a clean reimplementation based on the existing Rust crate:
bh1750by Jona Wilmsmann: https://github.com/jona-wilmsmann/bh1750-rs
Features
- Blocking (synchronous) API using
embedded-hal1.0 (I2c+DelayNs) - Optional async I2C + delay API behind the
asyncfeature usingembedded-hal-async
Feature flags
async: enable async driver API (embedded-hal-async)
Blocking example
use bh1750_embedded::{Bh1750, Resolution};
# let i2c = todo!("provide an embedded-hal I2C implementation");
# let delay = todo!("provide an embedded-hal DelayNs implementation");
let mut sensor = Bh1750::new(i2c, delay, bh1750_embedded::Address::Low);
let lux = sensor.one_time_measurement(Resolution::High)?;
# Ok::<(), bh1750_embedded::Error<_>>(())
Async example
Enable the feature:
[dependencies]
bh1750-embedded = { version = "0.1", features = ["async"] }
use bh1750_embedded::r#async::Bh1750Async;
use bh1750_embedded::Resolution;
# let i2c = todo!("provide an embedded-hal-async I2C implementation");
# let delay = todo!("provide an embedded-hal-async DelayNs implementation");
let mut sensor = Bh1750Async::new(i2c, delay, bh1750_embedded::Address::Low);
let lux = sensor.one_time_measurement(Resolution::High).await?;
# Ok::<(), bh1750_embedded::Error<_>>(())
License
MIT
Dependencies
~61KB