Crate hts221 [−] [src]
I2C interface to the HTS221.
This is a high-level API that provides functions to read humidity and temperature values from the chip, using a blocking I2C communication protocol.
The API is divided into two portions, the device:device module, which provides low-level access to the device registers, and the top-level module, which provides high level access. If you only need to read the temperature or humidity from the device, and do not need fine-grained control (such as disabling the device to save power), you can use a Builder to create a fully-configured HTS221 structure, then read the temperature and humidity as needed.
let hts221 = hts221::Builder::new(i2c) .with_data_rate(hts221::DataRate::Continuous1Hz) // other configuration... .build()?; let humidity = hts221.humidity_x2()? / 2; let temperature = hts221.temperature_x8()? / 8;
The humidity and temperature values are provided in 16-bit fixed point notation, in the resolution provided by the chip. Humidity is provided in half-percentage points, and is clamped to between 0% and 100% (i.e., 0 to 200). Temperature is provided in one-eighth degrees Celsius, and is clamped to between -40° C and 120° C (i.e., -320 and 960).
Modules
device |
I2C interface to the HTS221. |
Structs
Builder |
Builder for an HTS221 structure. This builder allows you to configure the chip without needing to access the device:device module. |
HTS221 |
Interface for the chip. |
Enums
AvgH |
Values for humidity configuration. Selects the number of internal humidity samples averaged into one sample. |
AvgT |
Values for temperature configuration. Selects the number of internal temperature samples averaged into one sample. |
DataRate |
Values of the output data rate. |
PinMode |
Options for the data ready pin output mode. |
Polarity |
Polarity options for the data-ready signal. Value is the polarity of the signal when data is ready. |
UpdateMode |
Values for block-update mode. |