Expand description
Sensirion SHT3x-DIS humidity and temperature sensor (SHT30, SHT31, SHT35).
The SHT3x returns fully calibrated, linearised 16-bit temperature and humidity words over I2C, each followed by a CRC-8, and converts to physical units with two fixed linear formulas. This module holds the command words, verifies the CRC, decodes a six-byte measurement frame, applies the datasheet’s conversion formulas in integer arithmetic, and decodes the status register, so a node reads degrees and percent relative humidity without carrying a floating-point library.
A caller writes a word from command most-significant byte first, waits the
measurement duration for the chosen repeatability, reads six bytes, and hands them
to Measurement::parse. In periodic mode the same six bytes follow
command::FETCH_DATA.
Temperatures are returned in millidegrees and humidity in thousandths of a percent, rounded to nearest, which is finer than the part’s 0.01 °C and 0.01 %RH resolution.
Modules§
- command
- The 16-bit command words, sent most-significant byte first.
Structs§
- Measurement
- One temperature and humidity data pair, as the part returns it.
- Status
- The status register, read with
command::READ_STATUSas one CRC-protected word.
Enums§
- Rate
- The periodic-mode acquisition rate, in measurements per second (mps).
- Repeatability
- The measurement repeatability, which sets noise, duration, and energy per sample.
Constants§
- I2C_
ADDRESS_ A - I2C address A, selected with the ADDR pin at logic low; the default.
- I2C_
ADDRESS_ B - I2C address B, selected with the ADDR pin at logic high.
- MIN_
COMMAND_ GAP_ MICROS - The shortest gap between two commands, in microseconds: the part needs 1 ms after a command before it accepts another.
Functions§
- celsius
- Converts a raw temperature word to degrees Celsius.
- crc
- Computes the CRC-8 the part appends to every data word.
- fahrenheit
- Converts a raw temperature word to degrees Fahrenheit.
- humidity_
raw_ from_ milli_ percent - Builds the raw humidity word a part reports for a relative humidity.
- humidity_
raw_ from_ relative_ humidity - Builds the raw humidity word a part reports for a relative humidity in percent.
- milli_
celsius - Converts a raw temperature word to millidegrees Celsius.
- milli_
fahrenheit - Converts a raw temperature word to millidegrees Fahrenheit.
- milli_
percent - Converts a raw humidity word to thousandths of a percent relative humidity.
- periodic
- Returns the periodic-mode command for a repeatability and rate.
- relative_
humidity - Converts a raw humidity word to percent relative humidity.
- single_
shot - Returns the single-shot measurement command for a repeatability and clock mode.
- temperature_
raw_ from_ celsius - Builds the raw temperature word a part reports for a temperature in Celsius.
- temperature_
raw_ from_ milli_ celsius - Builds the raw temperature word a part reports for a temperature.
- temperature_
raw_ from_ milli_ fahrenheit - Builds the raw temperature word a part reports for a temperature in Fahrenheit.
- word
- Decodes one CRC-protected 16-bit word as the part sends it.
- word_
bytes - Builds the three bytes that carry a 16-bit word with its CRC.