Code Monkey home page Code Monkey logo

hrs3300-rs's Introduction

Rust HRS3300 Heart Rate Sensor Driver

crates.io Docs Build Status Coverage Status

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

This driver allows you to:

  • Enable/disable heart rate sensor. See: enable_hrs().
  • Enable/disable oscillator. See: enable_oscillator().
  • Initialize the device. See: init().
  • Set the conversion delay. See: set_conversion_delay().
  • Set the gain. See: set_gain().
  • Set the ambient light sensor resolution. See: set_als_resolution().
  • Set the LED current. See: set_led_current().
  • Read the device id. See: device_id().
  • Read the last heart rate sensor measurement. See: read_hrs().
  • Read the last ambient light sensor measurement. See: read_als().
  • Write/Read a register with a custom value. See: write_register().

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

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

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

fn main() {
    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);
    }
}

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.

hrs3300-rs's People

Contributors

eldruin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.