Crates.io | mcp9808 |
lib.rs | mcp9808 |
version | 0.4.0 |
source | src |
created_at | 2018-03-18 19:37:49.441868 |
updated_at | 2024-05-05 19:43:04.190755 |
description | Platform agnostic Rust driver for the Microchip MCP9808 temperature sensor. |
homepage | |
repository | https://github.com/MrBuddyCasino/mcp9808-rs |
max_upload_size | |
id | 56314 |
size | 46,532 |
This is a platform agnostic Rust driver for the MCP9808, based on the
embedded-hal
traits.
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
Feature complete, but needs more testing.
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)
Licensed under either of
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.