Crate max44009[][src]

This is a platform agnostic Rust driver for the MAX44009 ambient light sensor, based on the embedded-hal traits.

This driver allows you to:

  • Read lux measurement.
  • Set the measurement mode.

The device

The MAX44009 ambient light sensor features an I2C digital output that is ideal for a number of portable applications such as smartphones, notebooks, and industrial sensors. At less than 1μA operating current, it is the lowest power ambient light sensor in the industry and features an ultra-wide 22-bit dynamic range from 0.045 lux to 188,000 lux. Low-light operation allows easy operation in dark-glass applications. The on-chip photodiode's spectral response is optimized to mimic the human eye's perception of ambient light and incorporates IR and UV blocking capability. The adaptive gain block automatically selects the correct lux range to optimize the counts/lux.

Datasheet:

Usage examples (see also examples folder)

Read lux

Import this crate and an embedded_hal implementation, then instantiate the device:

extern crate linux_embedded_hal as hal;
extern crate max44009;

use hal::I2cdev;
use max44009::{ Max44009, SlaveAddr };

let dev = I2cdev::new("/dev/i2c-1").unwrap();
let address = SlaveAddr::default();
let mut sensor = Max44009::new(dev, address);
let lux = sensor.read_lux().unwrap();

Provide an alternative address

extern crate linux_embedded_hal as hal;
extern crate max44009;

use hal::I2cdev;
use max44009::{ Max44009, SlaveAddr };

let dev = I2cdev::new("/dev/i2c-1").unwrap();
let a0 = true;
let address = SlaveAddr::Alternative(a0);
let mut sensor = Max44009::new(dev, address);

Set the measurement mode to continuous

extern crate linux_embedded_hal as hal;
extern crate max44009;

use hal::I2cdev;
use max44009::{ Max44009, SlaveAddr, MeasurementMode };

let dev = I2cdev::new("/dev/i2c-1").unwrap();
let mut sensor = Max44009::new(dev, SlaveAddr::default());
sensor.set_measurement_mode(MeasurementMode::Continuous).unwrap();

Structs

Max44009

MAX44009 ambient light sensor driver.

Enums

Error

All possible errors in this crate

MeasurementMode

Measurement mode

SlaveAddr

Possible slave addresses