HTS221 Humidity and Temperature Sensor

Environmental Sensing in Rust

The HTS221 is a tiny (2x2x0.9mm) MEMS environmental sensor

HTS221

Basic Usage

API

Sensor-Level API

// given hts221
let rel_humidity = hts221.humidity_x2() / 2;
let temperature = hts221.temperature_x8() / 8;
let hts221 = hts221::Builder::new(i2c)
.with_avg_t(hts221::AvgT::Avg256)
.with_avg_h(hts221::AvgH::Avg512)
.powered_up() // default
.with_update_mode(hts221::UpdateMode::Block) // default
.with_data_rate(hts221::DataRate::Continuous1Hz)
.with_data_ready_disabled() // default
.build()?;

Register-Level API

let cr2 = hts221.cr2()?;
cr2.modify(|w| w.set_heater_on())?;
hts221.cr2()?.set_heater_on()?;
let h_out = hts221::device::HumidityOut::new(i2c)?;
let adc_value: i16 = h_out.value();
let calibration = hts221::device::Calibration::new(i2c)?;

Future Directions