4 releases (breaking)

Uses old Rust 2015

new 0.4.0 May 5, 2024
0.3.0 Oct 31, 2023
0.2.0 Oct 31, 2023
0.1.0 Mar 18, 2018

#281 in Embedded development

Download history 3/week @ 2024-01-17 7/week @ 2024-02-14 31/week @ 2024-02-21 30/week @ 2024-02-28 20/week @ 2024-03-06 36/week @ 2024-03-13 2/week @ 2024-03-20 24/week @ 2024-03-27 62/week @ 2024-04-03 10/week @ 2024-04-10 2/week @ 2024-04-17 3/week @ 2024-04-24 132/week @ 2024-05-01

147 downloads per month

MIT/Apache

36KB
818 lines

mcp9808-rs

Rust MCP9808 Driver

This is a platform agnostic Rust driver for the MCP9808, based on the embedded-hal traits.

The Device

The MCP9808 digital temperature sensor converts temperatures between -20°C and +100°C to a digital word with ±0.5°C (max.) accuracy.

The device has an I²C interface and user-selectable settings such as Shutdown or low-power modes and the specification of temperature Event and Critical output boundaries.

Details and datasheet: http://www.microchip.com/wwwproducts/en/en556182

Status

Feature complete, but needs more testing.

  • temperature register
  • configuration register
  • resolution register
  • manufacturer ID and device ID
  • temperature alert upper & lower
  • critical temperature

Usage

Assuming you have a reference to the HAL's I2C bus:

    let mut mcp9808 = MCP9808::new(i2c);

    // how to read & write register
    let mut conf = mcp9808.read_configuration().unwrap();
    conf.set_shutdown_mode(ShutdownMode::Shutdown);
    let _c = mcp9808.write_register(conf);
    
    // read temperature register
    let temp = mcp9808.read_temperature().unwrap();
    temp.get_celsius(ResolutionVal::Deg_0_0625C)

License

Licensed under either of

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.

Dependencies

~110KB