#temperature #sync #embedded-hal #async #temperature-sensor #no-std #no-alloc

no-std tmp1075

Platform-independent Rust driver for TMP1075 digital temperature sensor

4 releases

new 0.1.3 Feb 13, 2025
0.1.2 Feb 13, 2025
0.1.1 Feb 13, 2025
0.1.0 Feb 13, 2025

#1418 in Embedded development

Download history 424/week @ 2025-02-11

424 downloads per month

MIT/Apache

18KB
252 lines

TMP1075

Crate Docs Build Status dependency status MIT licensed

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:

Dependencies

~2MB
~42K SLoC