#i2c #embedded-hal #no-std #bh1750

no-std bh1750-embedded

no_std embedded-hal driver for the BH1750/BH1750FVI ambient light sensor (with optional async support)

1 unstable release

0.1.0 Feb 10, 2026

#1015 in Embedded development

MIT license

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:

Features

  • Blocking (synchronous) API using embedded-hal 1.0 (I2c + DelayNs)
  • Optional async I2C + delay API behind the async feature using embedded-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