[][src]Crate hrs3300

This is a platform agnostic Rust driver for the HRS3300 heart rate sensor using the embedded-hal traits.

This driver allows you to:

The device

HRSS3300 is an optical digital heart rate sensor/monitor featuring a 525nm green LED and a reflection light detector for the PPG signal from the human body. The typical heart rate measurement samples the reflected PPG signal at 25Hz then the results can be read via the I2C bus.

Datasheet:

Usage examples (see also examples folder)

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

Initialize the device and take some measurements

extern crate linux_embedded_hal as hal;
extern crate hrs3300;
use hrs3300::Hrs3300;

let dev = hal::I2cdev::new("/dev/i2c-1").unwrap();
let mut sensor = Hrs3300::new(dev);
sensor.init().unwrap();
sensor.enable_hrs().unwrap();
sensor.enable_oscillator().unwrap();
loop {
    let hrs = sensor.read_hrs().unwrap();
    let als = sensor.read_als().unwrap();
    println!("HRS: {}, ALS: {}", hrs, als);
}

Change the parameters

extern crate linux_embedded_hal as hal;
extern crate hrs3300;
use hrs3300::{ConversionDelay, Gain, Hrs3300, LedCurrent};

let dev = hal::I2cdev::new("/dev/i2c-1").unwrap();
let mut sensor = Hrs3300::new(dev);
sensor.init().unwrap();
sensor.set_gain(Gain::Four).unwrap();
sensor.set_conversion_delay(ConversionDelay::Ms50).unwrap();
sensor.set_led_current(LedCurrent::Ma20).unwrap();

Structs

Hrs3300

HRS3300 device driver

Enums

AlsResolution

Ambient light sensor resolution

ConversionDelay

Wait time between each HRS conversion cycle

Error

All possible errors in this crate

Gain

HRS Gain

LedCurrent

LED drive current