logo elektroda
logo elektroda
X
logo elektroda

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

divadiow 22365 128
ADVERTISEMENT
  • #31 20934447
    jaimembranco
    Level 1  

    Is it possible to calibrate temperature and humidity? Because the temperature is off by +/-2º and the humidity...
  • ADVERTISEMENT
  • #32 20952524
    hojnikb
    Level 11  

    I found a rather odd behavior on low battery. I've noticed that once the battery gets very low, it starts to bootloop, as it probably doesn't have enough power to complete the boot process and post the MQTT value. So the device unsuccessfully reboots like 100s of times before the battery gets completely depleted. This in itself wouldn't be an issue, but once you put fresh batteries in, the device is in recovery mode every time, so it needs to be reset back to the normal state. And that's pretty annoying.

    Any chance a script could be made that would hold the device in deep sleep until appropriately high voltage is present?
  • #33 20969163
    divadiow
    Level 34  
    I've updated the first post with a work-in-progress OBK template.

    wifiled_n and btn confirmed.

    Unsure/unknown:
    -should all have different channels?
    -P7 - BAT_Relay?

    I have continuity between P7 and this component with the red dot, does this indicate BAT_RELAY @artin961 ?
    Close-up of a PCB with model CBU, showing electronic components and a connector.

    @p.kaczmarek2 interesting there are 3 devices with "CHT83x" in the keywords, but none with pin assignments.
    also, can the template creation/import function add secondary channel support so ""CHT8305_SDA;0;1" is valid
    Fragment of configuration code with assigned values for pins.

    console using ext psu to CBU pins

    Screenshot displaying diagnostic data of the CHT8305 temperature and humidity sensor and battery level.


    console on 2x AAA batteries
    Screenshot displaying temperature, humidity, and battery status data from the OpenBK system.
  • #34 20969906
    kuncy7
    Level 9  
    kuncy7 wrote:

    I tried using cloudcutter, without success.

    Is there a chance for a profile for this sensor?


    I've asked this before.
    Is it now possible to generate a profile for this sensor based on the data we have?
  • #35 20969944
    divadiow
    Level 34  
    kuncy7 wrote:
    I've asked this before.
    Is it now possible to generate a profile for this sensor based on the data we have?


    it seems you can generate your own cloudcutter profile using a firmware dump, so I guess it's possible. Cloudcutter is a different team, unrelated to Elektroda, I think.
  • Helpful post
    #36 20969948
    p.kaczmarek2
    Moderator Smart Home
    divadiow wrote:

    @p.kaczmarek2 interesting there are 3 devices with "CHT83x" in the keywords, but none with pin assignments.
    also, can the template creation/import function add secondary channel support so ""CHT8305_SDA;0;1" is valid

    Good point, I will add a fix for that soon, I'm on it:
    Screenshot of TypeError: Failed to fetch error during JSON template export.
    Helpful post? Buy me a coffee.
  • Helpful post
    #37 20970005
    kuncy7
    Level 9  

    divadiow wrote:
    kuncy7 wrote:
    I've asked this before.
    Is it now possible to generate a profile for this sensor based on the data we have?


    it seems you can generate your own cloudcutter profile using a firmware dump, so I guess it's possible. Cloudcutter is a different team, unrelated to Elektroda, I think.


    There is such a post: https://www.elektroda.com/rtvforum/topic3979215.html
    I quote:
    "How to create new Tuya-cloudcutter profile?
    If your device is not supported, then we can add support for that.
    Please take 2MB flash backup with BK7231 Easy GUI flasher (instruction on Github):
    https://github.com/openshwprojects/BK7231GUIFlashTool
    Then please submit 2MB flash here, with specific information what kind of device is that, model name, etc, and we will get you a profile."

    I just don't know where to send this flash, but @p.kaczmarek2 probably knows.
    I found this profile: https://github.com/tuya-cloudcutter/tuya-clou...08-temperature-and-humdity-sensor-v1.0.0.json
    I wonder if it's from our sensor?
    I have to check it out.
  • ADVERTISEMENT
  • #38 20970026
    divadiow
    Level 34  
    >>20969948

    amazing. let me know when to test.
  • ADVERTISEMENT
  • #39 20970141
    p.kaczmarek2
    Moderator Smart Home
    Sure, I can get a profile for you, please wait a moment. I will let you know the results.
    Helpful post? Buy me a coffee.
  • #41 20970455
    p.kaczmarek2
    Moderator Smart Home
    @kuncy7 I got a reply:
    Quote:

    This device was already added as Tuya Generic TH08 Temperature and Humdity Sensor v1.0.0

    However, this is an NL (battery) device, and these sometimes will not work correctly work with the cutting process. They will cut and get an A- prefix, but they may not activate and receive a schema or flash 3rd party firmware. NL uses a modified join, and is much more sensitive to network timing than other devices. You're welcome to attempt the existing profile, but serial flashing may still be necessary.

    Screenshot showing Cloudcutter profile with TH08 filter for temperature and humidity sensor.
    Helpful post? Buy me a coffee.
  • #42 20971369
    divadiow
    Level 34  
    p.kaczmarek2 wrote:
    Just choose an unused one so it does not interfere with anything


    ah, my previous question is already answered. BAT_ADC and BAT_Relay should have channels set that are different to each other and to any other channel set on the same device.

    Added after 14 [minutes]:

    final template and PR https://github.com/OpenBekenIOT/webapp/pull/77

    Code: JSON
    Log in, to see the code
  • Helpful post
    #43 20971396
    p.kaczmarek2
    Moderator Smart Home
    @divadiow I will be adding final part for second channel import in a moment:
    https://github.com/OpenBekenIOT/webapp/commit/685ba7730ff502695000f451710e97756f3ae924
    We need to wait for web app to update and check if it works for your template.

    Added after 16 [minutes]:

    It seems to work on my side:
    Screenshot showing the OpenBeken Configuration Generator tool for generating configurations from Tuya JSON data.
    Remember that you need to update OBK as well in order for setPinChannel to support secondary channel
    Helpful post? Buy me a coffee.
  • #44 20971420
    hojnikb
    Level 11  

    Now that we have battery monitoring working, would it be possible to set up autoexec script in such a manner, that the script would check for battery state and if for example battery reports 5%, instead of deep sleeping for 15 minutes (or whatever) it sleeps indefinitely or for a very long time. So the next time you change the batteries, it will skip this (since the battery is above 5%) and work as normal and not bootloop itself 100s of times.
  • #45 20971435
    divadiow
    Level 34  
    p.kaczmarek2 wrote:
    Remember that you need to update OBK as well in order for setPinChannel to support secondary channel


    of course. I have been testing with 1.17.474. I even factory reset and imported again and SDA was 0 0. no matter. I'll try another device, I'm sure it's fine.

    Added after 6 [minutes]:

    >>20917860
    @hojnikb I have not noticed this but I haven't really used the device for anything but flashing and playing.
  • #46 20972286
    TheNitek
    Level 3  

    Are you sure on the button pin? For me it seems to be 14, not 15.
  • ADVERTISEMENT
  • #48 20973625
    hojnikb
    Level 11  
    >>20971435
    Probably why didn't you. Keep one device working till the battery drains and see how it behaves.
  • #49 20974558
    p.kaczmarek2
    Moderator Smart Home
    @hojnikb do you have a lab power supply or something, to replicate that scenario? I think I could help with that but we still would need to test the new mechanism well before releasing it.
    Helpful post? Buy me a coffee.
  • #50 20974881
    hojnikb
    Level 11  

    p.kaczmarek2 wrote:
    @hojnikb do you have a lab power supply or something, to replicate that scenario? I think I could help with that but we still would need to test the new mechanism well before releasing it.


    Yes, i have a lab bench supply, so i can replicate that pretty easily. But i'm fairly certain this happens all the time.

    This device seems to have a very low required voltage to operate (below 1V). When device dies, one of the cells is at 0.1V, other ~0.9V (can't really explain why one cell is so much more discharged). And i'm assuming when the voltage/power capability of the battery drops, device starts bootlooping and thus forces itself into recovery mode (multiple unsuccessful boots). Which means every time you change the batteries, you first have to get it out of the recovery mode.

    Added after 3 [hours] 46 [minutes]:

    divadiow wrote:
    p.kaczmarek2 wrote:
    Just choose an unused one so it does not interfere with anything


    ah, my previous question is already answered. BAT_ADC and BAT_Relay should have channels set that are different to each other and to any other channel set on the same device.

    Added after 14 [minutes]:

    final template and PR https://github.com/OpenBekenIOT/webapp/pull/77

    Code: JSON
    Log in, to see the code


    I tried the new template. Battery monitoring seems to work, but it's not accurate. With 2.7V it shows around 3.15V... Is there an offset/factor, that can be set?

    Added after 12 [minutes]:

    p.kaczmarek2 wrote:
    @hojnikb do you have a lab power supply or something, to replicate that scenario? I think I could help with that but we still would need to test the new mechanism well before releasing it.


    So i did some preliminary tests at different voltages. At about 1.0-1.2V, devices works fine. It draws quite a bit of current at those low voltages (around 200mA) but it works. After the voltage drops to below 1V, it starts heavily bootlooping. With just a minute of being at 1V, i got this:

    User interface screen of a device in safe mode

    So clearly, this devices acts very strange at low battery levels. Not to mention what discharging to such low levels will do to NiMH cells.

    So low voltage cutoff/shutdown/deepsleep is needed for reliable operation. And obviously, this won't put device in safemode every time battery discharges.
  • #51 20975259
    TheNitek
    Level 3  

    According to home assistant my sensor reported 255.9°C tonight (twice). Has anyone else seen this?
  • #52 20975669
    insmod
    Level 22  
    TheNitek wrote:

    According to home assistant my sensor reported 255.9°C tonight (twice). Has anyone else seen this?

    Had the same problem, i believe it means that the temperature is lower than 0.0°C.
    Solved with this simple sensor template
    
    {% if states('your_temperature_sensor')|float > 200 %}
    {{states('your_temperature_sensor')|float - 256}}
    {% else %}
    {{states('your_temperature_sensor')}}
    {% endif %}
    
  • #53 20976454
    hojnikb
    Level 11  

    I was able to calibrate the voltage and % measurement for my Ni-MH batteries and they seem to be accurate. But I can't seem to be able to report that information to the MQTT?

    What am I missing?
  • #54 20976486
    p.kaczmarek2
    Moderator Smart Home
    The Home Assistant discovery must be done after configuring the Battery driver. If you have run the Discovery first, then you must run it again.
    Helpful post? Buy me a coffee.
  • #55 20977072
    hojnikb
    Level 11  

    p.kaczmarek2 wrote:
    The Home Assistant discovery must be done after configuring the Battery driver. If you have run the Discovery first, then you must run it again.


    Smashing! I've done that and it works. Looks like battery report isn't on the regular 0 or 1 channel, but its own separate.

    In any case, the whole low battery behavior still needs to be resolved I'd think.
  • #56 20977099
    p.kaczmarek2
    Moderator Smart Home
    hojnikb wrote:

    Yes, i have a lab bench supply, so i can replicate that pretty easily. But i'm fairly certain this happens all the time.

    That's a very good news, so how do you suggest we handle the battery issue?

    First of all you need to have a properly calibrated battery driver. Then we may try doing something, maybe, if battery driver detects, then force deep sleep for 1h? Or for 6h? The only problem is.... if user replaces the battery, it will still sleep. I am not sure. What do you think?

    This could be done even with :
    
    $batteryVoltage
    

    in script
    Helpful post? Buy me a coffee.
  • #57 20977221
    hojnikb
    Level 11  

    p.kaczmarek2 wrote:
    hojnikb wrote:

    Yes, i have a lab bench supply, so i can replicate that pretty easily. But i'm fairly certain this happens all the time.

    That's a very good news, so how do you suggest we handle the battery issue?

    First of all you need to have a properly calibrated battery driver. Then we may try doing something, maybe, if battery driver detects, then force deep sleep for 1h? Or for 6h? The only problem is.... if user replaces the battery, it will still sleep. I am not sure. What do you think?

    This could be done even with :
    
    $batteryVoltage
    

    in script


    I suggest doing an if statement within the autoexec script, if that is even possible.

    For example, a regular autoexec will check mqtt connection, post required channels and then sleep for a predetermined time. Now before it goes to deep sleep for a short period of time (for example 60 minutes) it checks if battery voltage/percentage is above a certain value (5%?).
    If that value is above, go to sleep for 60 minutes, if below sleep for maximum amount of time (a day, a week? as long as possible).

    This way, when user replaces the battery, the script will again check the state of the battery and go to the regular 60 minute sleep.

    Hopefully, with properly tuned values we can avoid bootloops and dreaded safemode after battery was discharged.
  • #58 20979739
    TheNitek
    Level 3  

    Does anyone already have a useful autoexec script which extends the battery life beyond half a day?
  • #59 20980120
    insmod
    Level 22  
    
    PowerSave 1
    Battery_cycle 3
    addEventHandler OnHold 14 SafeMode
    Battery_Setup 2000 3000 2
    waitFor MQTTState 1
    delay_s 6
    DeepSleep 900
    

    Works for about 2 weeks on 2x 1.5v Li-ion batteries
  • #60 20981590
    TheNitek
    Level 3  

    thanks, but two weeks still sounds pretty bad, doesn't it? Any chances to improve that further?

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