Skip to main content

Module sht3x

Module sht3x 

Source
Expand description

Sensirion SHT3x-DIS humidity and temperature sensor (SHT30, SHT31, SHT35).

The SHT3x returns fully calibrated, linearized 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. The Sht3x driver (the embedded-hal feature) runs the single-shot sequence over an I2C bus.

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.
sim
An SHT3x that is not there.

Structs§

Measurement
One temperature and humidity data pair, as the part returns it.
Sht3x
An SHT3x on an I2C bus, measuring on demand in single-shot mode.
Status
The status register, read with command::READ_STATUS as 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.
SOFT_RESET_MICROS
How long the part takes to come back after command::SOFT_RESET, in microseconds: the datasheet’s maximum of 1.5 ms between the acknowledge of the command and the part entering idle state, which also covers the gap before the next command.

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.