logo elektroda
logo elektroda
X
logo elektroda

[BK7231N/CBU] Tuya TH01? Generic Wi-Fi Temperature & Humidity Sensor [CHT8310]

divadiow 22371 128
ADVERTISEMENT
  • #61 20981813
    insmod
    Level 22  

    It can be easily improved, for example, use Ni-MH, or even better - alkaline batteries. I use Li-ion, and they have much less energy capacity in AAA format. But I use them as they, when discharged, drop voltage to zero, and so the MCU will not try to start and fail, and eventually drop to safe mode. Another solution is longer deep sleep. I have 15 minutes, you can stretch it to 30, or even longer. I believe that with 1hr deep sleep and alkaline batteries it will work at least half a year.
  • ADVERTISEMENT
  • #62 20981885
    p.kaczmarek2
    Moderator Smart Home
    WiFi is not a suitable protocol for battery-powered devices by design and I'd always opt for Zigbee in such cases, but you can still improve the script that has been shown above.

    For example, I think it may be worth to add some kind of fallback case for the situation when MQTT is not up, some kind of timeout. A single repeating event can be used for that. It would have to be inserted before waitFor . Otherwise , this script will wait forever for MQTT to connect and it can quickly discharge battery when your HA is off for maintance.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #63 20982640
    hojnikb
    Level 11  

    p.kaczmarek2 wrote:
    WiFi is not a suitable protocol for battery-powered devices by design and I'd always opt for Zigbee in such cases, but you can still improve the script that has been shown above.

    For example, I think it may be worth to add some kind of fallback case for the situation when MQTT is not up, some kind of timeout. A single repeating event can be used for that. It would have to be inserted before waitFor . Otherwise, this script will wait forever for MQTT to connect and it can quickly discharge battery when your HA is off for maintenance.


    Could you give us an example of such timeout?
  • #64 20983428
    p.kaczmarek2
    Moderator Smart Home
    This can be easily done with addRepeatingEventID, for example:
    
    // [IntervalSeconds][RepeatsOr-1][UserID][CommandToRun]
    addRepeatingEventID 30 1 666 DeepSleep 900
    

    This will create an event with ID 666 with repeats count 1 and delay 30 seconds.
    Futhermore, if you want to create a config button, you can cancel it with:
    
    cancelRepeatingEvent 666 
    
    Helpful post? Buy me a coffee.
  • #65 21000232
    bl00dy
    Level 4  

    Have the same, successfully installed firmware with tuya-cloudcutter
  • ADVERTISEMENT
  • #66 21027475
    Zogdan
    Level 9  

    >>20981813
    The PW33 dc-dc boost converter used to boost the 2x1.5V to 3.3V is a PW5100 that can take up to 5V input voltage so you might consider using Li-ion.
    Maybe good to include I blew up mine by not disconnecting the 3.3V from the UART while inserting the batteries.
    Practically this led to a short in the PW33, shorting the battery now, waiting for PW33 to replace.
  • #67 21050429
    crispybeken
    Level 2  
    >>20876365

    @artin961 The problem with periodic wakeup from DeepSleep is we could miss changes in temperature and/or humidity if we sleep too long and waste battery by waking up even when nothing has changed.
    However, both CHT8310 and CHT8305 feature an ALERT mode, which can be used to wake up the BK7231N from DeepSleep when reaching temperature and/or humidity limitation programmed by setting temperature and/or high/low-limit registers of the sensor.
    All we need to do is set new limits based on last read value before activating Deep Sleep, for example at 22° set lower limit to 21.5° and upper limit to 22.5°. The BK7231N would stay asleep as long as the temperature stays between these values but immediately wake up when the limit is reached.
    The ALERT pin of CHT8310 is connected to P7 with a 10kΩ resistor in between. The I²C commands necessary are already shown to work in this arduino library: CHT8305.
    If we could add a setAltert([temp_high, temp_low, hum_high, hum_low]) function to OpenBeken it would greatly reduce power usage and make the readings more accurate, since we would get any change in temperature and/or humidity when they occur.
  • #68 21054403
    sanysneky
    Level 3  

    I have this temperature and humidity sensor with Bk7231n sht30. Everything was working fine until the batteries died. Now I can't connect it to the Live Smart app. I press the reset button and the device is visible but cannot be paired. What do I need to do to pair this sensor again
  • #69 21055193
    p.kaczmarek2
    Moderator Smart Home
    Wait, to be clear, you haven't flashed your device with OBK and it still died after batteries run out?
    Helpful post? Buy me a coffee.
  • #70 21055214
    sanysneky
    Level 3  

    Yes. After the battery runs out, it will not pair. I didn't flash it. After entering pairing mode, the app sees the device, but in the next step, after entering the code from my 2.4Ghz wifi network, it won't pair. Tried manual pairing with both modes and LED flashing fast and flashing slow. When it flashes slowly, the SSID of the device is visible and connects to it, but when I go back a step, the app searches for devices and does not connect.
  • #71 21058981
    sanysneky
    Level 3  

    solved the problem after the factory reset of the router
  • #72 21059351
    p.kaczmarek2
    Moderator Smart Home
    Wait, what? Are you saying that factory reset of the router made your Tuya device pair again?
    Helpful post? Buy me a coffee.
  • #73 21059651
    sanysneky
    Level 3  

    I reset the router to factory settings and after that the Tuya device paired with the app. Something was wrong with the router.
  • #74 21098612
    joseang
    Level 2  
    hojnikb wrote:

    Does anyone else experience very poor precision on lower temps? I've noticed that when temps drop below 10°C, its accuracy drops off even further. While at ~20-25°C, it's usually around 2°C off (easily fixed by offsetting), by 10 or even 0°C, it's easily off by ~5°C or more (shows higher than it actually is).

    Any way to calibrate or something? Or is CHT8310 just that inaccurate.


    I have the same issue. Temperature is 2ºC above the real temp.

    How can I fix it by offsetting? I'm using Smart Life app.

    Thanks.
  • #75 21100192
    vincenzoernst1
    Level 6  

    @p.kaczmarek2

    can you plz update the template in the wiki?

    @All

    would it be possible to use PinDeepSleep instead of Deepsleep? for Btn we could use the reset button of the unit? or will this interfere with general openbeken operation? with PinDeepSleep we would be able to wake up the unit at any time for maintenance reasons.

    also how to set temp/hum offsets in openbeken?
  • #76 21109748
    divadiow
    Level 34  
    vincenzoernst1 wrote:
    can you plz update the template in the wiki?


    with reference to: https://www.elektroda.com/rtvforum/topic4056603.html#21097621

    change template from this

    "14": "Btn;4",
    to
    "14": "dInput;4",
    or
    "14": ""DoorSnsrWSleep;4",
    ?
    I guess either make more sense than btn.

    Added after 2 [minutes]:

    joseang wrote:
    How can I fix it by offsetting? I'm using Smart Life app.


    @joseang you're using factory fw still?
  • #77 21109752
    p.kaczmarek2
    Moderator Smart Home
    @joseang if there is no calibration option in Tuya/SmartLife app, then I don't think it's possible. I tested quite a few Tuya/SmartLife device and I noticed that only more expensive models have calibration option.
    Helpful post? Buy me a coffee.
  • #78 21109755
    divadiow
    Level 34  
    Also. I think I should revise thread title and template to remove reference to TH08. I've seen elsewhere mention of incorrect label on package and have since seen Tuya's API response from info in the fw dump refer to this as a "TH01".

    Also, it's blatantly another TH01 going on looks alone.
  • #79 21109760
    p.kaczmarek2
    Moderator Smart Home
    Changed name to TH01:
    Screenshot of an online forum discussing the Tuya TH01 device, displaying views and replies statistics.
    You can update template if you want.
    Helpful post? Buy me a coffee.
  • #80 21109766
    joseang
    Level 2  

    joseang wrote:
    How can I fix it by offsetting? I'm using Smart Life app.


    @joseang you're using factory fw still?[/quote]

    Yes, I'm still using factory fw. I'll try the custom fw of this thread.

    I'm currently experimenting with a solar panel and a supercapacitor to charge and supply the TH08.
  • #81 21156905
    vincenzoernst1
    Level 6  
    maybe you could also add "CHT8310" to the templates keywords.

    Added after 6 [minutes]:

    divadiow wrote:
    Curious, mine has 8304 in the log, not 8305.

    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:125.000000C Humidity:100.000000%


    Info:SENSOR:DRV_CHT8305_init: ID: FF FF FFFF
    Error:CMD:command with name CHT_Calibrate already exists!
    Error:CMD:command with name CHT_Cycle already exists!
    Info:MAIN:Started cht8305.


    Screenshot of OpenBK software with temperature and humidity sensor readings.

    My startup command is

    backlog PowerSave 1; startDriver SSDP; startDriver Wemo; startDriver NTP; startDriver CHT8305


    What flags have you set @Baustromverteiler and what channel/pin settings?

    Added after 12 [minutes]:

    Silly me https://github.com/openshwprojects/OpenBK7231T_App/issues/983#issue-1997790886

    Screenshot showing interface elements with labels P20, P21, P22 and associated values CHT8305_SCK and CHT8305_SDA.

    Info:SENSOR:DRV_CHT8305_init: ID: 59 59 8215
    


    Screenshot of the OpenBK7231N interface displaying CHT8305 data and a channel configuration warning.

    Added after 9 [hours] 48 [minutes]:

    OBK template for this variant

    Code: JSON
    Log in, to see the code


    ah i see u already have the template updated. can you plz be sure to have the template in the inital post updated as well any time you update it in the thread...this would help a lot not to have to read the whole thing.... ;-)
  • #82 21160571
    vincenzoernst1
    Level 6  
    @p.kaczmarek2

    when i check the logs is see the CHT driver poll the temp/hum about every second, which is in any case never needed.
    @work i work with environment sensors all the time and we never poll that much, even on grid powered units, cause temp never changes that much (u never should apply sensors to direct sunlight.)

    on battery powered units this makes no sense at all. it drains the battery unnecessarily.

    can we adjust the polling rate? how?
    if not, maybe by adding a parameter to "startDriver CHT8305 x" where x is the poll rate in sec? this should be usefull for any kind of environmental sensor.

    
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.812500C Humidity:47.622680%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.812500C Humidity:47.564697%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.843750C Humidity:47.525024%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.906250C Humidity:47.409057%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.781250C Humidity:47.463989%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.812500C Humidity:47.421264%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.875000C Humidity:47.525024%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.843750C Humidity:47.479248%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.843750C Humidity:47.509765%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.875000C Humidity:47.409057%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.843750C Humidity:47.479248%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.843750C Humidity:47.393798%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.875000C Humidity:47.409057%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.812500C Humidity:47.406005%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.843750C Humidity:47.451782%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.906250C Humidity:47.338867%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.875000C Humidity:47.351074%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.875000C Humidity:47.393798%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.875000C Humidity:47.280883%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.875000C Humidity:47.409057%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.875000C Humidity:47.293090%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.875000C Humidity:47.250366%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.812500C Humidity:47.235107%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.875000C Humidity:47.250366%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.906250C Humidity:47.265625%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.906250C Humidity:47.280883%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.812500C Humidity:47.204589%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.906250C Humidity:47.296142%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.968750C Humidity:47.311401%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.906250C Humidity:47.265625%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.906250C Humidity:47.265625%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.906250C Humidity:47.323608%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.906250C Humidity:47.280883%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.906250C Humidity:47.409057%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.906250C Humidity:47.222900%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.906250C Humidity:47.265625%
    Info:SENSOR:DRV_CHT8304_readEnv: Temperature:29.906250C Humidity:47.238159%
  • #83 21160676
    p.kaczmarek2
    Moderator Smart Home
    startDriver CHT8305 x
    is out of the question because we are using the same syntax for passing pins to drivers.

    Maybe we should introduce something universal, per driver, like driverUpdateRate CHT8305 60 ?
    Helpful post? Buy me a coffee.
  • #84 21160993
    vincenzoernst1
    Level 6  
    hmmm.... sounds reasonable.

    universality is always a good thing.

    maybe we can also set the default poll time to something less bus stressing. lets say 5sec?
  • #86 21171229
    p.kaczmarek2
    Moderator Smart Home
    The following PR is now merged, thank you.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #87 21182138
    vincenzoernst1
    Level 6  
    >>21170847

    how to use it correctly?!

    Added after 7 [minutes]:

    >>21170847

    for eg bathrooms it would also be handy to have the same with humidity.
  • #89 21182369
    insmod
    Level 22  
    >>21182153 Looks accurate enough. Though you have to edit the source file, not .md one. Will add humidity on the weekends if I don't forget.

Topic summary

The discussion revolves around the Tuya TH01 and its variations, particularly focusing on the CHT8310 temperature and humidity sensor. Users share experiences with flashing the device using OpenBK firmware, troubleshooting issues related to incorrect temperature and humidity readings, and configuring the device for optimal battery performance. Key topics include the use of the ALERT pin for power-saving features, calibration of sensor readings, and the integration of the device with Home Assistant via MQTT. Users also discuss the challenges of using the device with low battery levels and the need for proper pin configuration to avoid boot loops. The conversation highlights the importance of firmware updates and community support in enhancing device functionality.
Summary generated by the language model.
ADVERTISEMENT