logo elektroda
logo elektroda
X
logo elektroda

[BK7231N ] Teardown of TH08 LCD Calendar/clock/temperature/humidity, 3xAAA battery, backlight

morgan_flint 29781 225
ADVERTISEMENT
  • #211 21378297
    p.kaczmarek2
    Moderator Smart Home
    What sending of flags, what is it? Maybe there is something to correct.

    BatteryLevelPercent I will check in the Simulator right away and if there is seriously a bug I will fix it and upload the Release. Many people just do their Yaml because then there is 100% control over everything

    Ready channel settings - i.e. for the dpID of this device? My TH06 only offered humidity and temperature, no alarms, so I had no way to check that

    Added after 24 [minutes]:

    @GAAD added:
    
    setChannelType 2 BatteryLevelPercent
    setChannelLabel 2 MyBatteryABC
    
    .
    WinTest_3145CAFF diagnostic screen showing battery level at 67%, channel info, and MQTT status. .
    User interface of an application with device information and sensor status .
    Posted at:
    https://github.com/openshwprojects/OpenBK7231...mmit/3a1c3e9bbf6105e43d16653139a321a860de5207

    What is needed next? What else is missing?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #212 21379117
    GAAD
    Level 17  
    Generally, it is already ok.

    As for the rest, I think colleague @divadiow pasted the whole thing on the previous page
    I've experimented with these channels even started to configure them as read or text channels but it didn't really work out for me.

    
    {
      "1": {
        "name": "Temperature",
        "type": "obj",
        "mode": "ro",
        "trigger": "direct",
        "property": {
          "type": "value",
          "min": -200,
          "max": 600,
          "scale": 1,
          "step": 1
        }
      },
      "2": {
        "name": "Humidity",
        "type": "obj",
        "mode": "ro",
        "trigger": "direct",
        "property": {
          "type": "value",
          "min": 0,
          "max": 100,
          "scale": 0,
          "step": 1
        }
      },
      "3": {
        "name": "Battery level state",
        "type": "obj",
        "mode": "ro",
        "trigger": "direct",
        "property": {
          "type": "enum",
          "range": ["low", "middle", "high"]
        }
      },
      "4": {
        "name": "Battery level",
        "type": "obj",
        "mode": "ro",
        "trigger": "direct",
        "property": {
          "type": "value",
          "min": 0,
          "max": 100,
          "scale": 0,
          "step": 1
        }
      },
      "9": {
        "name": "Unit convert",
        "type": "obj",
        "mode": "rw",
        "property": {
          "type": "enum",
          "range": ["c", "f"]
        }
      },
      "10": {
        "name": "Set maxtemp",
        "type": "obj",
        "mode": "rw",
        "property": {
          "type": "value",
          "min": -200,
          "max": 600,
          "scale": 1,
          "step": 1
        }
      },
      "11": {
        "name": "Set minitemp",
        "type": "obj",
        "mode": "rw",
        "property": {
          "type": "value",
          "min": -200,
          "max": 600,
          "scale": 1,
          "step": 1
        }
      },
      "12": {
        "name": "Set maxhum",
        "type": "obj",
        "mode": "rw",
        "property": {
          "type": "value",
          "min": 0,
          "max": 100,
          "scale": 0,
          "step": 1
        }
      },
      "13": {
        "name": "Set minihum",
        "type": "obj",
        "mode": "rw",
        "property": {
          "type": "value",
          "min": 0,
          "max": 100,
          "scale": 0,
          "step": 1
        }
      },
      "14": {
        "name": "Temp alarm",
        "type": "obj",
        "mode": "ro",
        "property": {
          "type": "enum",
          "range": ["loweralarm", "upperalarm", "cancel"]
        }
      },
      "15": {
        "name": "Humidity alarm",
        "type": "obj",
        "mode": "ro",
        "property": {
          "type": "enum",
          "range": ["loweralarm", "upperalarm", "cancel"]
        }
      },
      "17": {
        "name": "Temperature report",
        "type": "obj",
        "mode": "rw",
        "property": {
          "type": "value",
          "min": 1,
          "max": 120,
          "scale": 0,
          "step": 1
        }
      },
      "18": {
        "name": "Humidity report",
        "type": "obj",
        "mode": "rw",
        "property": {
          "type": "value",
          "min": 1,
          "max": 120,
          "scale": 0,
          "step": 1
        }
      },
      "19": {
        "name": "Temp sensitivity",
        "type": "obj",
        "mode": "rw",
        "property": {
          "type": "value",
          "min": 3,
          "max": 20,
          "scale": 1,
          "step": 1
        }
      },
      "20": {
        "name": "Humidity sensitivity",
        "type": "obj",
        "mode": "rw",
        "property": {
          "type": "value",
          "min": 3,
          "max": 20,
          "scale": 0,
          "step": 1
        }
      }
    }
    


    It would be nice to complete:
    9 "Unit convert", this has already been tackled by colleague @smoeller95s
    10 "Set maxtemp",
    11 "Set minitemp",
    12 "Set maxhum",
    13 "Set minihum",
    14 "Temp alarm",
    15 "Humidity alarm",
    17 "Temperature report",
    18 "Humidity report",
    19 "Temp sensitivity",

    This would give the full functionality of the device and the convenience of configuration and, after all, we are reworking these devices not to lose but to gain. In most threads it is the case that if it works for someone, they write the rest either in OBK or in HA and no longer share it.
  • #213 21379148
    p.kaczmarek2
    Moderator Smart Home
    A lot of things like the alarm can be done in OBK itself, you don't have to do it on TuyaMCU, but if you need something I'll help. I can introduce new channels, and I'm also working on some more advanced options so that you can script the settings as you like. We already have an HTML Widgets system, so you can make any control you want, but it's probably too advanced for such a simple device....

    What was the problem with channels? You give a text field type then you can both receive and send. Unless you want to add a comma delimited text field type?

    Unit convert is supposed to be a radio button with two options?

    PS: Are you using the OBK simulator? It might be faster that way... for testing with HA
    Helpful post? Buy me a coffee.
  • #214 21379298
    GAAD
    Level 17  
    Do we stand a chance of something like this for example:
    
        visual:
          min_temperature: 10 °C      
          max_temperature: 30 °C      
          temperature_step: 0.1 °C
    
    switch:
      - platform: tuya
        name: "Power"
        icon: mdi:power
        switch_datapoint: 1           
        internal: True                
    
    sensor:
      - platform: tuya
        name: "Temperatura"
        device_class: "temperature"
        sensor_datapoint: 3
        unit_of_measurement: "°C"
        accuracy_decimals: 1
        filters:
          - multiply: 0.1
    
    number:
    - platform: "tuya"
      name: "Histereza"
      number_datapoint: 101
      min_value: 0.3
      max_value: 10.0
      step: 0.1
      multiply: 10
    
    - platform: "tuya"
      name: "Cool del"
      number_datapoint: 102
      min_value: 1
      max_value: 10
      step: 1
    
    - platform: "tuya"
      name: "Korekta T"
      number_datapoint: 103
      min_value: -10
      max_value: 10
      step: 0.1
      multiply: 10
    
    .


    User interface with thermostat settings .

    I know it takes more time in ESP it's not a web selector and probably autoexec won't solve the problem but maybe there are parameters for channels that can be set like range from to, divide by 10?
    Maybe it would be better to make one type for channels with data, e.g. temperature and as another option multiplier?
    With the development of the software, there will be more and more functions and options, so maybe it would be possible to sort this list alphabetically?
    You would certainly have to make a LowAlarm/HighAlarm channel for the alarm channels.

    My autoexec now looks like this:
    
    clearIO
    PowerSave 1
    startDriver NTP
    ntp_setServer 192.168.1.253
    waitFor NTPState 1
    ntp_timeZoneOfs 1
    startDriver TuyaMCU
    startDriver tmSensor
    // Flags 134743044
    
    setChannelType 1 temperature_div10
    linkTuyaMCUOutputToChannel 1 val 1
    
    setChannelType 2 Humidity
    linkTuyaMCUOutputToChannel 2 val 2
    
    setChannelType 3 ReadOnlyLowMidHigh
    setChannelLabel 3 "Batt_state"
    linkTuyaMCUOutputToChannel 3 val 3
    
    setChannelType 4 BatteryLevelPercent
    setChannelLabel 4 "Batt_level"
    linkTuyaMCUOutputToChannel 4 val 4
    
    setChannelType 10 TextField
    setChannelLabel 10 "Set maxtemp"
    linkTuyaMCUOutputToChannel 10 val 10
    
    setChannelType 11 TextField
    setChannelLabel 11 "Set minitemp"
    linkTuyaMCUOutputToChannel 11 val 11
    
    setChannelType 12 TextField
    setChannelLabel 12 "Set maxhum"
    linkTuyaMCUOutputToChannel 12 val 12
    
    setChannelType 13 TextField
    setChannelLabel 13 "Set minihum"
    linkTuyaMCUOutputToChannel 13 val 13
    
    setChannelType 14 ReadOnly
    setChannelLabel 14 "Temp alarm"
    linkTuyaMCUOutputToChannel 14 val 14
    
    setChannelType 15 ReadOnly
    setChannelLabel 15 "Humidity alarm"
    linkTuyaMCUOutputToChannel 15 val 15
    
    setChannelType 17 TextField
    setChannelLabel 17 "Temperature report"
    linkTuyaMCUOutputToChannel 17 val 17
    
    setChannelType 18 TextField
    setChannelLabel 18 "Humidity report"
    linkTuyaMCUOutputToChannel 18 val 18
    
    setChannelType 19 TextField
    setChannelLabel 19 "Temp sensitivity"
    linkTuyaMCUOutputToChannel 19 val 19
    
    .

    typing a value e.g. 240 for max. temp. in the text field to trigger an alarm saves it in the OBK but does not send it to the MCU because after a reboot the old values still entered in the cloud are shown again.

    Edit: the sensor is powered by batteries and the MCU switches on the wifi module when sending the data, so the parameter changes must rather be saved in the HA and sent when the wifi is switched on, therefore these channels must be "editable" and "writable" in the HA.

    I don't use the simulator it's not a problem I have the sensor next to my PC and am testing but you may need to - is it under windows or linux?
    You asked about flags.
    The problem with sending flags is quite troublesome and I have read about it already with blinds.
    When I send in the autoexec setting the flags for example.
    "Flags 134743044"
    then the flags should turn on: 2,10,19,27,43,47
    but, unfortunately, above the 30th one, completely different flags are switched on.
    With roller shutters it is similar - I send flags and they move and other flags are switched on, most often button locking, as my colleagues wrote about in threads about roller shutters.
    It looks as if one of the higher flags is not included in the counting/recounting from bin to hex because I think that is how it is done and then the shift occurs but as I wrote I am not a programmer, it is just my thoughts.

    I have checked on WBR1 that the 31st flag is the last one to change the value of the flags, if you select all the flags from 1-30 there are enough digits, adding 31 causes overflow.
  • ADVERTISEMENT
  • #215 21382506
    GAAD
    Level 17  
    I apologise for re-writing the post below the post but this is probably more readable and easier to translate to a non-Polish version.

    I have set up the low/high temperature and humidity alarms:
    For channels 14 and 15 as "ReadOnly"
    exceeding the lower threshold - value 0
    exceeding of the upper threshold - value 1
    no alarms, i.e. normal state - value 2

    So we need e.g. the following channels: LowAlarm / HighAlarm / Normal
    I think this will be fairly universal.

    Still a question what are the errors and info in the logs?
    
    Warn:CFG:CFG_InitAndLoad: Correct config has been loaded with 881 changes count.
    Info:CFG:####### Flash Save Can't Get Channel 14 (not enough space in array) #######
    Info:CFG:####### Flash Save Can't Get Channel 15 (not enough space in array) #######
    Error:CMD:no file early.bat err -2
    
    .

    Before I can do the thermostat settings from HA or the web I wanted to set the alarm values from autoexec but the command:
    "SetChannel" does not work:
    
    setChannelType 10 ReadOnly
    setChannelLabel 10 "Set max temp"
    linkTuyaMCUOutputToChannel 10 val 10
    SetChannel 10 250
    
    .
    maybe because the channel is read-only?
  • ADVERTISEMENT
  • #216 21384337
    p.kaczmarek2
    Moderator Smart Home
    Thank you for your submissions! Your comments are very much appreciated.

    I may think about a system in this style, although in principle a lot of this can already be done via HTML Widgets and a custom page in HTML hosted on LittleFS:
    Alternative HTML control page for TOMPD-63-WIFI .
    Still, I think it will be worth adding what you say.

    I'm working on the flags problem, but sprintf/sscanf on MCU is different than on Win32 simulator and I'm a bit stuck:
    https://github.com/openshwprojects/OpenBK7231T_App/pull/1494

    
    Info:CFG:####### Flash Save Can't Get Channel 15 (not enough space in array) #######
    
    .
    If you did SetStartValue to -1 for channel 15 then this won't work, only the first channels have flash writes, due to saving flash cycles (we have a system that does one erase for many writes over several sectors, but the side effect is that the flashvars structure has a fixed size and has to be quite small).

    
    Error:CMD:no file early.bat err -2
    
    .
    This could be changed to a warning, this means that there is simply no early.bat in LittleFS

    In my opinion, this code:
    
    setChannelType 10 ReadOnly
    setChannelLabel 10 "Set max temp"
    linkTuyaMCUOutputToChannel 10 val 10
    SetChannel 10 250
    
    .
    should work. I typed it into the simulator and it goes through:
    https://github.com/openshwprojects/OpenBK7231...mmit/b1f745deb151019878b0718bdb1b4cce9ba78831
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #217 21385809
    GAAD
    Level 17  
    p.kaczmarek2 wrote:
    My opinion is that this code:
    Code: [expand][collapse][select all][copy to clipboard].
    setChannelType 10 ReadOnly
    setChannelLabel 10 "Set max temp"
    linkTuyaMCUOutputToChannel 10 val 10
    setChannel 10 250

    should work. I typed it into the simulator and it goes through:
    https://github.com/openshwproj...51019878b0718bdb1b4cce9ba78831
    .

    Unfortunately the values appear on the web page for a while and then the MCU sends the old ones.
    I guess it just doesn't accept them.
  • #218 21385904
    p.kaczmarek2
    Moderator Smart Home
    I have had no such problems, and have even recently operated an Atorch advanced meter in TuyaMCU:
    Advanced energy meter/thermostat with LCD Atorch S1TW-FR - cloudless operation .
    But that may be because the device in question here is a battery-powered device....
    I read somewhere that someone succeeded as he added:
    
    delay_s 0.5
    

    before sending the initial state.

    And yes you would have to look up how in the original firmware this is sent:
    TuyaMCU analyser - UART packet decoder for Tuya devices - dpID detector .

    You can also use tuyaMcu_sendState to send a packet directly.
    Here is the command documentation:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md
    Instead of using setChannel then try while the device is running, live use tuyaMcu_sendState from the documentation to set the dpID (here 10) to a value of 250, complete its type itself, here you have a screenshot of the self-tests so that there is no doubt that it works and sends the packet:
    Screenshot of source code inside an editor, displaying tuyaMcu_sendState commands and test results. .


    Maybe it also needs to be sent via dpCache.
    The battery-powered TuyaMCU devices also have a so-called dpCache. In this case, this device queries the WiFi module itself at startup for these values:
    Code: C / C++
    Log in, to see the code
    .
    The WiFi module responds with a packet 0x10:
    Code: C / C++
    Log in, to see the code
    .
    I wrote about dpCache in this post:
    https://www.elektroda.com/rtvforum/topic3975583.html#20584330
    You use dpCache in two steps:
    1. you set a given channel to be remembered in Flash memory between reboots, here remember that only the first 10-12 channels are remembered, so use channels sequentially, not that you give the number 30....
    Suppose we use channel 5:
    
    // Make value persistant (stored between reboots), 
    // start value -1 means "remember last"
    SetStartValue 5 -1
    
    .
    2. when mapping a dpID to a channel you specify an additional argument, append 1, that is true for bDPCache:
    
    // link dpID 17 to channel 5, the type is val, extra '1' means that its dpCache variable
    linkTuyaMCUOutputToChannel 17 val 5 1
    
    .
    Configured this way, the device knows that when the MCU queries the dpCache, you need to send it the value of channel five in response.
    Helpful post? Buy me a coffee.
  • #219 21503091
    smoeller95s
    Level 3  
    Hello
    I have a strange Problem. My updated devices work fine and im very happy. But sometimes when the Battery runs out and i not change it fast enough (some days) the firmware seems lost.
    The wifi icon on the lcd allways flash but the obk never come alive. No Wifi connection no hotspot. The only solution is erase all and then re flash. Only re flash is not enough.
    Had someone had the same problem before? I have ~ 15 devices and today the 4. had this Problem.
  • #220 21503990
    GAAD
    Level 17  
    I have the same problem with one TH08. I haven't resuscitated it yet but the symptoms are the same: when the battery is discharged the Wifi module is dead. The thermometer itself measures and displays measurements correctly i.e. the Tuya MCU is working properly.
  • #221 21513410
    GAAD
    Level 17  
    I uploaded the OBK again yesterday. After connecting it, it gave programming but the WiFi network did not appear. I had to remove the CB3S upload the Tuya soft and again the OBK then worked. By the way the update to the latest version went. Now I am waiting for the battery to drain ;-) .
  • #222 21513752
    p.kaczmarek2
    Moderator Smart Home
    @insmod creates "fast wifi connect" modification, it should help with battery life in this type of device
    Helpful post? Buy me a coffee.
  • #223 21550631
    silver_mc
    Level 13  
    Hello,
    Has anyone encountered a version where the units are in °F and °C? In the Tuya app, it was possible to change them. In OpenBK, the units on the display are showing in °F. Is it possible to change this via a dpID? Unfortunately, I no longer have the original firmware as I lost it somewhere. :/

Topic summary

The discussion revolves around the TH08 LCD Calendar/Clock/Temperature/Humidity device, focusing on its teardown, firmware flashing, and integration with OpenBK. Users share experiences with the device's functionality, including issues with sensor readings, MQTT communication, and NTP server configuration. Key points include the necessity of desoldering RX and TX pins for successful firmware flashing, the importance of correct NTP server settings for time synchronization, and methods to maintain Wi-Fi connectivity. Users also explore power management strategies for the device, including the implications of using external power sources and the impact on battery life. Solutions for ensuring accurate temperature and humidity readings are discussed, along with troubleshooting steps for connectivity issues.
Summary generated by the language model.
ADVERTISEMENT