veml6070-rs

Platform-agnostic Rust driver for the VEML6070 UVA light sensor.

APACHE-2.0 License

Downloads
7.6K
Stars
2
Committers
1

Rust VEML6070 UVA Light Sensor Driver

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. See: enable().
  • Read the UV measurement. See: read_uv().
  • Set the integration time. See: set_integration_time().
  • Enable/disable ACK signal. See: enable_ack().
  • Set ACK threshold value. See: set_ack_threshold().

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 example

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

Please find additional examples in this repository: driver-examples

use linux_embedded_hal::I2cdev;
use veml6070::Veml6070;

fn main() {
    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 reading = uv_light_sensor.read_uv().unwrap();
    println!("UV reading: {}", reading);
}

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.

Package Rankings
Top 29.39% on Crates.io
Badges
Extracted from project README
crates.io Docs Build Status Coverage Status
Related Projects