This is the multi-page printable view of this section. Click here to print...

Return to the regular view of this page

As of 2025-07-24

SHT4x

Temperature and Humidity Sensor
    This is a temperature and humidity sensor that uses the I2C bus.

    Processing Flow

    1. Wire.begin(): Initialize the bus
    2. .begin(): Start sensor operation
    3. Wait a few milliseconds
    4. .available() becomes true
    5. .get_temp(), .get_humid(): Read the values

    Required Procedures for Operation

    Wire Bus

    Ensure the Wire is active using Wire.begin() before calling the begin() method.

    Procedure After Wake-up from Sleep

    Ensure the Wire bus is active just before entering sleep (it will be automatically recovered after waking up).

    Methods

    get_temp(), get_temp_cent()

    double get_temp()
    int16_t get_temp_cent()

    Reads the temperature. get_temp() returns the value in °C, and get_temp_cent() returns the temperature multiplied by 100 as an integer.

    On error, a value between -32760 and -32768 is returned.

    get_humid(), get_humid_per_dmil()

    double get_humid()
    int16_t get_humid_per_dmil()

    Reads the humidity. get_humid() returns the value in %, and get_humid_per_dmil() returns the humidity multiplied by 100 as an integer.

    On error, a value between -32760 and -32768 is returned.

    Common Methods

    setup()

    void setup()

    Allocates memory and performs initialization for the sensor.

    begin(), end()

    void begin()
    void end()

    Starts sensor data acquisition. It requires approximately 5ms of wait time before values can be read.

    end() is not supported.

    process_ev()

    void process_ev(uint32_t arg1, uint32_t arg2 = 0)

    For sensors requiring wait-time processing, pass E_EVENT_TICK_TIMER or E_EVENT_START_UP to arg1 to notify time progression. After calling this method and enough time has passed, the sensor becomes available and its value can be read.

    available()

    bool available()

    Returns true when the sensor meets the read condition.

    probe()

    bool probe()

    Returns true when the sensor is connected.