#instrument #temperature-sensor #digital #texas #linux #driver #tmp102-rs

tmp102

Driver for the Texas Instruments TMP102 digital temperature senor (for Linux)

1 stable release

Uses old Rust 2015

1.0.0 Sep 25, 2016

#19 in #texas

Apache-2.0

3KB

tmp102-rs

Rust library for the Texas Instruments TMP102 digital temperature sensor.

This library will only compile on Linux and has only been tested on the Raspberry Pi and with this TMP102 breakout: https://www.sparkfun.com/products/11931

extern crate tmp102;

use tmp102::{TMP102, TempScale};

fn main() {
    // address 0x48 assumes ADR0 is connected to GND
    let mut tmp = TMP102::new("/dev/i2c-1", 0x48).unwrap();
    println!("Temperature is {}", tmp.read(TempScale::Fahrenheit).unwrap());
}

If you are not sure what address the device is using, just use i2cdetect.

$ i2cdetect  -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

Dependencies

~2–3.5MB
~59K SLoC