[OpenBeken] SHT Sensor configuration, commands, and deep sleep usage with wake up on pin change

dheenhasty 1650 2
  • Hello,

    Here's a quick Cheat Sheet regarding the available commande on SHT Sensor to be able to manage it completely.

    First to make command available you need to start the SHT Driver :
    StartDriver SHT3X

    it will start by default a measurement every 10 seconds.

    Once driver is avalaible you have access to all the command for the sensor :
    - Status command :
    "SHT_GetStatus" will return the status of the sensor once convert to binary you can apply this table :
    [OpenBeken] SHT Sensor configuration, commands, and deep sleep usage with wake up on pin change

    "SHT_ClearStatus" you can clear the status for all the checksum, alert bit with the command "SHT_ClearStatus"

    to gather Temp and Humidity measurement you have 2 method :
    - Single Shot mode
    "SHT_Measure" : Straight forward it mesure and update channel with value. (Default method when starting the driver)

    - Periodical measurement.
    this mode will ask sensor to capture data regularly without external command, then you juste add to read the buffer.
    "SHT_LaunchPer" <msb> <lsb> : Launch the periodical capture with below parameter :
    [OpenBeken] SHT Sensor configuration, commands, and deep sleep usage with wake up on pin change
    if you don't indicate argument 0x23 0x22 will be used by default so Medium 4 mps mesurement.
    it will change the cycle measurement with SHT_MeasurePer

    "SHT_MeasurePer" : Will read the buffer on SHT and update Channel with value
    "SHT_StopPer" : Will stop the periodical capture (and change back the default measurement of driver to SHT_Measure)

    - Measurement Cycle
    "SHT_cycle" <second> : will change the cycle of measurement for the driver. default to 10

    - Calibration.
    by default the sensor doesn't need any calibration, but it's very sensitive so a small led near him can impact the measurement.
    So you can use the command SHT_Calibrate to change the offset of temperature and humidity before measurement.
    "SHT_Calibrate" -0.5 +10.00 will lower temperature measurement for 0.5 and upper the humidity to 10

    - Alert Mode :
    The SHT posses an internal alert mode who can send an high signal to pin of the Beken chip if some measurement reach limit.
    So you can monitor Low and High Temperature and Low and High Humidity. it permit to wake a device from PinDeepSleep if you assign the alert pin to a dinput
    There's a offset between value to avoid excessive flapping on the pin :
    [OpenBeken] SHT Sensor configuration, commands, and deep sleep usage with wake up on pin change

    "SHT_ReadAlert" : Below command will read the current value of the alert and show them in OpenBeken Log

    "SHT_SetAlert" temperatureHighSet temperatureLowSet humidityHighSet humidityLowSet : will set the limit on SHT Sensor.
    The temperature clear value has an offset of 0,5 and the humidity an offset of 2

    This mode will only work when Periodical measurement if activated. (if not SHT will not be able to compare limit to measurement).

    Heater :
    SHT Sensor have embeded heater who can be usefull to dissipate to much humidity but will impact measurement.
    "SHT_Heater" Binary : will activate Heater if set to 1 and deactivate it if set to 0

    Added after 3 [hours] 48 [minutes]:

    Here's an example of script implementation :
    it will put wake up the device is temperature is lower than 16°c or upper than 22°c or if any button is pushed on device


    echo "PowerSaving mode"
    echo "activate startDriver sht3x"
    startDriver SHT3X
    echo "Clearing Status as after reboot alert trigger is passed to 1"
    echo "Setting Alert parameter"
    SHT_SetAlert 22 16 20 90
    delay_s 1
    echo "activate periodical measurement"
    SHT_LaunchPer 0x23 0x22
    delay_s 1
    echo "keep up for 2 min"
    delay_s 120
    echo "DeepSleep with pin detection"
    goto loop_mes

    Cool? Ranking DIY
    About Author
    Level 13  
    dheenhasty wrote 111 posts with rating 16, helped 2 times. Been with us since 2023 year.
  • #2
    Moderator Smart Home
    Very nice guide. It is also worth noting that "PinDeepSleep" will also work with simpler functional IOs, such as buttons. PinDeepSleep can be used without SHT sensor as well.
  • #3
    Level 13  
    Exactly, In case of the CBU generic temperature and humidity sensor you can use the same script to permit a manual measurement by pressing the button.