#rgb #light-sensor #sensor #ir #embedded-hal-driver #color

no-std isl29125

Platform-agnostic Rust driver for the ISL29125 low-power digital RGB color light sensor with IR blocking filter

1 unstable release

0.1.0 Apr 14, 2020

#2311 in Embedded development

MIT/Apache

28KB
406 lines

Rust ISL29125 Digital RGB Color Light Sensor with IR Blocking Filter Driver

crates.io Docs Build Status Coverage Status

This is a platform agnostic Rust driver for the low-power digital RGB color light sensor with IR blocking filter using the embedded-hal traits.

This driver allows you to:

  • Read all colors. See: read().
  • Read red/green/blue colors individually. See: red().
  • Set operating mode. See: set_operating_mode().
  • Set ADC resolution. See: set_resolution().
  • Set RGB data sensing range. See: set_range().
  • Set IR filtering. See: set_ir_filtering().
  • Read the status flags. See: status().
  • Clear the status flags. See: clear_status().
  • Read the device ID. See: device_id().
  • Perform a software reset. See: reset().
  • Interrupts:
    • Set interrupt thresholds. See: set_interrupt_thresholds().
    • Set interrupt threshold assignment. See: set_interrupt_threshold_assignment().
    • Set the fault count. See: set_fault_count().
    • Set interrupt pin mode. See: set_interrupt_pin_mode().
    • Enable/Disable generating an interrupt after a conversion is done. See: enable_interrupt_on_conversion_done().

The device

The ISL29125 is a low power, high sensitivity, RED, GREEN and BLUE color light sensor (RGB) with an I2C (SMBus compatible) interface. Its state-of-the-art photodiode array provides an accurate RGB spectral response and excellent light source to light source variation (LS2LS).

The ISL29125 is designed to reject IR in light sources allowing the device to operate in environments from sunlight to dark rooms. The integrating ADC rejects 50Hz and 60Hz flicker caused by artificial light sources. A selectable range allows the user to optimize sensitivity suitable for the specific application. In normal operation mode the device consumes 56μA, which reduces to 0.5μA in power-down mode.

The ISL29125 supports hardware and software user programmable interrupt thresholds. The Interrupt persistency feature reduces false trigger notification.

Datasheet: ISL29125

Usage

To use this driver, import this crate and an embedded_hal implementation, then instantiate the device.

Please find additional examples using hardware in this repository: driver-examples

extern crate linux_embedded_hal as hal;
use isl29125::{Isl29125, OperatingMode};

fn main() {
    let dev = hal::I2cdev::new("/dev/i2c-1").unwrap();
    let mut sensor = Isl29125::new(dev);
    sensor
        .set_operating_mode(OperatingMode::RedGreenBlue)
        .unwrap();
    loop {
        let m = sensor.read().unwrap();
        println!("R: {}, G: {}, B: {}", m.red, m.green, m.blue);
    }
}

Support

For questions, issues, feature requests, and other changes, please file an issue in the github project.

License

Licensed under either of

at your option.

Contributing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~71KB