Crate veml6070[][src]

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

This driver allows you to:

  • Enable/disable the sensor
  • Read the UV measurement
  • Set the integration time
  • Enable/disable ACK signal
  • Set ACK threshold value

The device

VEML6070 is an advanced ultraviolet (UV) light sensor with I2C protocol interface and designed by the CMOS process. It is easily operated via a simple I2C command. The active acknowledge (ACK) feature with threshold windows setting allows the UV sensor to send out a UVI alert message. Under a strong solar UVI condition, the smart ACK signal can be easily implemented by the software programming. VEML6070 incorporates a photodiode, amplifiers, and analog / digital circuits into a single chip. VEML6070's adoption of Filtron TM UV technology provides the best spectral sensitivity to cover UV spectrum sensing. It has an excellent temperature compensation and a robust refresh rate setting that does not use an external RC low pass filter. VEML6070 has linear sensitivity to solar UV light and is easily adjusted by an external resistor. Software shutdown mode is provided, which reduces power consumption to be less than 1 μA. VEML6070's operating voltage ranges from 2.7 V to 5.5 V.

Datasheet:

Application note:

Usage examples (see also examples folder)

Read UV

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

extern crate linux_embedded_hal as hal;
extern crate veml6070;

use hal::I2cdev;
use veml6070::VEML6070;

let dev = I2cdev::new("/dev/i2c-1").unwrap();
let mut uv_light_sensor = VEML6070::new(dev);
// initialization step is necessary
uv_light_sensor.init().unwrap();
uv_light_sensor.enable().unwrap();
let _uv_reading = uv_light_sensor.read_uv().unwrap();

Set integration time

extern crate linux_embedded_hal as hal;
extern crate veml6070;

use hal::I2cdev;
use veml6070::{ VEML6070, IntegrationTime };

let dev = I2cdev::new("/dev/i2c-1").unwrap();
let mut uv_light_sensor = VEML6070::new(dev);
// initialization step is necessary
uv_light_sensor.init().unwrap();
uv_light_sensor.enable().unwrap();
uv_light_sensor.set_integration_time(IntegrationTime::T1).unwrap();

Enable ACK and set a threshold of 145 steps

extern crate linux_embedded_hal as hal;
extern crate veml6070;

use hal::I2cdev;
use veml6070::{ VEML6070, AckThreshold };

let dev = I2cdev::new("/dev/i2c-1").unwrap();
let mut uv_light_sensor = VEML6070::new(dev);
// initialization step is necessary
uv_light_sensor.init().unwrap();
uv_light_sensor.enable().unwrap();
uv_light_sensor.enable_ack_with_threshold(AckThreshold::Steps145).unwrap();

Structs

VEML6070

VEML6070 device driver.

Enums

AckThreshold

ACK threshold

Error

All possible errors in this crate

IntegrationTime

Integration time