Crate apds9253

source ·
Expand description

This crate implements the driver for the APDS9253 RGB, ambient and IR light sensor from Broadcom. The sensor can be initialized in RGB mode, where all color channels and the infrared channel is available or in ALS mode, where only the ambient light and the infrared light channel is available.

§Resources

Broadcom APDS9253

APDS9253 Datasheet

§Features

  • Up to 20-bit resolution
  • I2C compatible interface with dedicated interrupt pin
  • Individual channels for red (R), green (G), blue (B) and infrared (IR)
  • Approximate human eye response with green channel
  • ALS and RGB sensing with integrated IR-blocking filter
  • Low power consumption

§Examples

The APDS has to be configured in RGB or ALS mode.

ALS mode:

use apds9253::*;

let mut sensor = Apds9253::new_als(i2c);
sensor.init().unwrap();

let ambient = sensor.read_ambient_light();
let infrared = sensor.read_infrared();

log::info!("Ambient: {ambient:?}, Infrared: {infrared:?}");

RGB mode:

use apds9253::*;

let mut sensor = Apds9253::new_rgb(i2c);
sensor.init().unwrap();

let red = sensor.read_red_channel();
let green = sensor.read_green_channel();
let blue = sensor.read_blue_channel();
let infrared = sensor.read_infrared();

log::info!("Red: {red:?}, Green: {green:?}, Blue: {blue:?}, Infrared: {infrared:?}");

§License

Open Logistics Foundation License
Version 1.3, January 2023

See the LICENSE file in the top-level directory.

§Contact Information

Fraunhofer IML Embedded Rust Group - embedded-rust@iml.fraunhofer.de

Re-exports§

Modules§

  • Module containing markers to decide between RGB or ALS sensor mode

Structs§

  • Representation of an APDS9253
  • Representation of the sensors dark count register
  • Sensor Status as reported via the MAIN_STATUS register

Enums§

  • Light source channel. Ambient light channel is equivalent to the green channel.
  • Possible errors in this sensor
  • Gain of the sensor readings
  • Configuration for the sensors interrupt, can either be Threshold or Variance based
  • The measurement rate of the sensor controls the timing of the periodic measurements in active mode. Once the measurement is done the sensor will go back to inactive mode. If the MeasurementRate is smaller than the duration defined by the Resolution, the measurement rate will be lowered accordingly. Unit is milliseconds
  • The resolution of the sensor defines the duration in which a measurement takes place. A 20 bit resolution results in 400ms measurement duration. From 20 bit down to 13 bit this results in 400, 200, 100 (default), 50, 25, 3.125ms. If this duration is greater than the MeasurementRate, the MeasurementRate will be lowered.
  • Mode of the sensor, selects which channels are activated
  • State for activating or deactivating functions of the sensor
  • Variance for the interrupt capability