Expand description
§TMP1075
A platform agnostic driver to interface with the TMP1075 temperature sensor.
The driver supports async and blocking mode, selectable wit hthe async
and blocking
features.
§TMP1075
Platform agnostic rust driver for the TMP1075 temperature sensor.
Can be used with async and sync I2C interfaces that implement the embedded_hal
or embedded_hal_async
traits.
§Resources
§Missing Features
- Set High and Low limit registers as floats for finer granularity. Currently only setting the MSB as i8 is supported.
§Example
This example runs the async configuration using embassy on an stm32.
ⓘ
use embassy_executor::Spawner;
use embassy_stm32::{
i2c,
time::Hertz,
};
use embassy_time::{Duration, Timer};
use fmt::{error, info};
use tmp1075::Tmp1075;
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let mut i2c_conf = i2c::Config::default();
i2c_conf.timeout = Duration::from_millis(500);
// Depending on your setup pullups might not be needed
i2c_conf.scl_pullup = true;
i2c_conf.sda_pullup = true;
let mut i2c = i2c::I2c::new(
p.I2C1,
p.PB6,
p.PB7,
Irqs,
p.DMA1_CH2,
p.DMA1_CH3,
Hertz::khz(400),
i2c_conf,
);
let mut temp_sens = Tmp1075::new(i2c);
loop {
match temp_sens.get_temperature().await {
Ok(temp) => info!("Temperature: {}", temp),
Err(e) => error!("Error: {:?}", e),
}
Timer::after_millis(500).await;
}
}
§Contributing
If you have any problems feel free to open an issue, if i find the time i might review and fix it.
Also feel free to open PRs if you miss some features or find bugs. PRs for documentation, tests, examples, etc. are also very welcome!
§License
Dual licensed under your choice of either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
Structs§
- Tmp1075
- TMP1075 driver
Enums§
- Alert
Function - ALERT pin functions See the datasheet (section 7.5.1.2) for more info.
- Alert
Polarity - Polarity of the ALERT Pin See the datasheet (section 7.5.1.2) for more info.
- Consecutive
Faults - Consecutive fault measurements to trigger the alert function See the datasheet (section 7.5.1.2) for more info.
- Conversion
Rate - Conversion Rate setting See the datasheet (section 7.5.1.2) for more info.
- Power
Mode - Shutdown Mode See the datasheet (section 7.5.1.2) for more info.