logo elektroda
logo elektroda
X
logo elektroda

[BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis

p.kaczmarek2 6840 10
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis
    I will show you how to connect a calendar/thermometer/hygrometer model TH06 with the Home Assistant LCD. This calendar is based on the WB3S/BK7231T WiFi module connected to an additional microcontroller that communicates with the WiFi module via the TuyaMCU protocol. The WiFi module is responsible for providing the microcontroller with the current time from the Internet (obtained via NTP) and for receiving temperature and humidity measurements from it.
    In order to connect to Home Assistant, we will change the BK7231T firmware - we will upload it OpenBeken . At OpenBeken, we will properly configure the TuyaMCU and NTP driver so that it works with the calendar.

    An older topic about the TH06 calendar
    I have discussed this product before, but I did not change its firmware:
    The inside of the TH06 clock/thermometer/hygrometer and reverse engineering its protocol
    This was before I even started OpenBeken and I knew the BK7231 was programmable with free tools. I recommend reading this topic.


    TH06 programming
    This calendar, like other devices using TuyaMCU, connects to the microcontroller through the same UART port (TXD1, RXD1) that is used for programming. In order to change the firmware, you need to cut off the paths going to the MCU, then you can normally change the batch through bkWriter 1.60, as in similar topics from the series.
    [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis
    Photos before the operation and a description of the plate are in the previous topic, previously linked.
    This is what mine looks like after surgery:
    [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis
    I did the programming as follows:
    - cut off RX/TX from MCU
    - I connected my USB to UART converter to TXD1 and RXD1, additionally I connected its mass
    - in bkWriter 1.60 I started writing the batch
    - when bkWriter 1.60 was waiting for the module to reboot, I cut off and connected it to the power supply through its USB connector
    - the batch has been uploaded correctly

    OpenBeken configuration
    I assume that the reader already knows how to configure WiFi and MQTT passwords.
    In OpenBeken, we open the Web Application (the second WWW panel):
    [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis
    In it, the FileSystem tab:
    [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis
    There CreateFile to create autoexec.bat:
    [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis
    Paste the contents of the script, save:
    
    startDriver TuyaMCU
    startDriver NTP
    // dpID 1 is tempererature div 10
    setChannelType 1 temperature_div10
    linkTuyaMCUOutputToChannel 1 val 1
    // dpID 2 is % humidity
    setChannelType 2 Humidity
    linkTuyaMCUOutputToChannel 2 val 2
    

    We are rebooting.

    But we will explain the script step by step.
    - startDriver TuyaMCU - starts the TuyaMCU driver
    - startDriver NTP - starts the NTP driver (network time)
    - setChannelType 1 temperature_div10 - sets the type of channel 1 (selected freely) to temperature times 10 (i.e. 23.5C written as 235 integer, as this notation is used by Tuya), thanks to which OpenBeken knows how to display its value on the panel
    - linkTuyaMCUOutputToChannel 1 val 1 - maps dpID from TuyaMCU (variable identifier) 1 to channel 1, value type. In this particular device, dpID 1 is temperature. dpID roles vary by device
    - setChannelType 2 Humidity - sets channel 2 type to humidity
    - linkTuyaMCUOutputToChannel 2 val 2 - as before, here dpID 2 is humidity
    Additionally, you can add - ntp_timeZoneOfs [Number of Hours] - time zone offset.

    After reboot we get:
    [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis
    I will improve the display of these variables even further.


    Connection with Home Assistant
    Before writing Yaml, it is worth enabling additional publishing of MQTT variables, which is disabled by default - that is, periodically publishing full status and publishing full status on connection. In addition, we will enable full publishing of TuyaMCU variables - just as a rule. It's possible that some of these flags will turn on automatically in future versions, but for now it's worth checking to make sure they're checked. In Options->General/Flags:
    [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis
    Then, in Home Assistant, we write the YAML code:
    Code: YAML
    Log in, to see the code

    Indexes 1 and 2 here are the indexes of the channels to which we have mapped the TuyaMCU variables. Nothing is "rigid" here - the same procedure allows you to get to other values from TuyaMCU, dimmer, battery value and so on.
    In addition, there is also a correction of the value - replacing the internal representation of the TuyaMCU temperature (an integer, temperature multiplied by 10) to the normal temperature - hence the multiplication by 0.1. Round rounds to one decimal place.
    [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis
    In this way, we get a full history of measurements in HA:
    [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis

    Summary
    I like this calendar very much - one of its advantages is that it is powered via USB. No problem with changing the battery.
    The disadvantages of this product include the inability to change the time display to 24-hour mode - that is, we will always have AM/PM.
    In addition, the display is not very clear from certain angles, especially when it is not well lit.
    What more could you do with this calendar?
    It could be used as an IR receiver - the WB3S has free pins, just solder three connections (ground, power and signal) and you can mount an additional IR receiver outside, perhaps recovered for free from electro-waste. Then, in OpenBeken, it could be scripted so that it reacts to the remote control selected by us and, for example, controls other IoT devices (through Home Assistant automation, or through the Tasmota Device Group, or by sending a GET request to a given address).
    After changing the firmware to open, the possibilities are really big...

    Cool? Ranking DIY
    Helpful post? Buy me a coffee.
    About Author
    p.kaczmarek2
    Moderator Smart Home
    Offline 
    p.kaczmarek2 wrote 11955 posts with rating 9993, helped 572 times. Been with us since 2014 year.
  • ADVERTISEMENT
  • #2 20344782
    Karol966
    Level 31  
    p.kaczmarek2 wrote:
    calendar/thermometer/hygrometer model TH06
    - a hygrometer would be useful to me, a thermometer possibly also - how do you assess the accuracy of these measurements?
    p.kaczmarek2 wrote:
    no possibility to change the time display to 24-hour mode - that is, we will always have AM/PM.
    - probably that's why there are 2 different 24H/12H versions available separately.
    p.kaczmarek2 wrote:
    - cut off RX/TX from MCU
    - you still didn't mention reconnection, you naturally merged them right?
    I found the cheapest version for PLN 55 on aliexpress but there were other, more popular, more expensive, rather closer to PLN 70. Do you think the one in my link will be ok?
    And the last thing, the same seller it also has a wifi remote control on ir in its offer. Was such a device already launched/tested/flashed somewhere?
  • #3 20344836
    p.kaczmarek2
    Moderator Smart Home
    Karol966 wrote:
    a hygrometer would be useful to me, a thermometer possibly also - how do you assess the accuracy of these measurements?

    You will find the answer here - paragraph "Measurements comparison"
    https://www.elektroda.pl/rtvforum/topic3806108.html


    Karol966 wrote:
    p.kaczmarek2 wrote:
    - cut off RX/TX from MCU
    - you still didn't mention reconnection, you naturally merged them right?

    Jumper from the resistor leg, the picture shows at least one connection:
    [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis
    And if you don't want to cut it, maybe desolder the entire MCU like here:
    Close-up of a circuit board with a component being desoldered using a soldering tool.
    https://www.youtube.com/watch?v=Yb3zXtBdSnE&ab_channel=Elektrodacom

    Karol966 wrote:

    I found the cheapest version for PLN 55 on aliexpress but there were other, more popular, more expensive, rather closer to PLN 70. Do you think the one in my link will be ok?

    It's hard for me to say, but this user recently reported that he got a calendar on CB3S and OpenBeken supports him too:
    https://www.elektroda.com/rtvforum/topic3933836.html

    Karol966 wrote:

    seller it also has a wifi remote control on ir in its offer. Was such a device already launched/tested/flashed somewhere?

    I guess it's a related topic?
    https://www.elektroda.com/rtvforum/topic3920360.html
    You can also search here under IR:
    https://openbekeniot.github.io/webapp/devicesList.html
    IR support is already in OpenBeken.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #4 20359256
    juan3211
    Level 5  
    May be someone from this post could help me:

    Hi, nice post.

    I have a new version with the infrared stuff. But I did a big error. I desoldered the WB3S IC before trying to find this info.

    I have flash and solder an ESP12F to the board with tasmote firmware, I am trying to know how protocol works.

    I ahve found several things useful with tasmota firmware:

    I can get (once a minute) this info from the Tuya IC: {"SerialReceived":"55AA0307000865020004000000C54155AA030700086602000400000042BF"}
    These are two strings of information:
    55AA0307000865020004000000C642 and 55AA03070008660200040000003FBC
    55AA0307 - 0008 length - 65 dpId(101) - 02 dataType - 0004 length - 000000C6 value(=198) 42 (checksum) --> 19.8ªC temp
    55AA0307 - 0008 length - 66 dpId(102) - 02 dataType - 0004 length - 0000003F value(=63) BC (checksum) --> 63% humidity

    I dont mind about IR stuff at this moment, but I have a problem.
    I need to know which is the command that the WIFI MODULE sends to the TUYA IC to update DATETIME at boot.

    Probably, after booting up, the wifi module sends "something" to tuya IC (tx pin in wb3s) similar to hour time year, ....

    Could you please sniff it?

    I could give you all information about soldering and configuring tasmota firmware to get all data. It will be perfect to collaborate.

    I have only missing tha datetime stuff so the screen will look pretty!!!!

    Thanks a lot
  • #5 20359454
    p.kaczmarek2
    Moderator Smart Home
    Hello, I have replied to you in this topic:
    https://www.elektroda.com/rtvforum/topic3819498.html
    Please keep discussion there.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #6 20504170
    spin55
    Level 17  
    >>20342890

    Hello. I have the same device in 24 hour version. I have flashed it with OpenBeken version Build on Feb 12 2023 19:36:28 version 1.15.440 and everything works fine, except that it disconnects and reconnects every 4 minutes approximately, as can be seen in the following Log:

    1679560042: New client connected from 192.168.1.60 as obk1F42E4C5 (p2, c1, k100, u'homeassistant').
    1679560308: New connection from 192.168.1.60 on port 1883.
    1679560308: Client obk1F42E4C5 already connected, closing old connection.
    1679560308: New client connected from 192.168.1.60 as obk1F42E4C5 (p2, c1, k100, u'homeassistant').
    1679560590: New connection from 192.168.1.60 on port 1883.
    [INFO] found homeassistant on local database
    1679560591: Client obk1F42E4C5 already connected, closing old connection.
    1679560591: New client connected from 192.168.1.60 as obk1F42E4C5 (p2, c1, k100, u'homeassistant').
    1679560829: New connection from 192.168.1.60 on port 1883.
    1679560829: Client obk1F42E4C5 already connected, closing old connection.
    1679560829: New client connected from 192.168.1.60 as obk1F42E4C5 (p2, c1, k100, u'homeassistant').
    1679561087: New connection from 192.168.1.60 on port 1883.
    [INFO] found homeassistant on local database
    1679561088: Client obk1F42E4C5 already connected, closing old connection.
    1679561088: New client connected from 192.168.1.60 as obk1F42E4C5 (p2, c1, k100, u'homeassistant').
    1679561349: New connection from 192.168.1.60 on port 1883.
    1679561349: Client obk1F42E4C5 already connected, closing old connection.
    1679561349: New client connected from 192.168.1.60 as obk1F42E4C5 (p2, c1, k100, u'homeassistant').
    1679561588: Saving in-memory database to /data/mosquitto.db.
    1679561591: New connection from 192.168.1.60 on port 1883.
    [INFO] found homeassistant on local database
    1679561592: Client obk1F42E4C5 already connected, closing old connection.
    1679561592: New client connected from 192.168.1.60 as obk1F42E4C5 (p2, c1, k100, u'homeassistant').


    Any solution?
  • ADVERTISEMENT
  • #7 20504189
    p.kaczmarek2
    Moderator Smart Home
    @spin55 probably related:
    https://github.com/openshwprojects/OpenBK7231T_App/pull/722
    but it's already merged....

    Does it reconnect/disconnect because the MCU resets WiFi module?
    Helpful post? Buy me a coffee.
  • #8 20504226
    spin55
    Level 17  
    Updated to Build on Mar 14 2023 20:31:25 version 1.15.592 and it is now stable.
    And now you don't need the tuyaMcu_sendRSSI command in autoexec.bat
  • #9 20504233
    p.kaczmarek2
    Moderator Smart Home
    Wow, that's a good news. That fix worked for you! If you have a Github account, please also write in that issue that it helped in your case as well.
    Helpful post? Buy me a coffee.
  • #11 21274798
    p.kaczmarek2
    Moderator Smart Home
    Helpful post? Buy me a coffee.

Topic summary

The discussion revolves around connecting the TH06 LCD calendar/thermometer/hygrometer, which utilizes the BK7231T WiFi module and communicates via the TuyaMCU protocol, to Home Assistant. Users share experiences with flashing the device using OpenBeken firmware, configuring NTP for time synchronization, and troubleshooting connectivity issues. Some users report successful firmware updates that stabilize connections, while others seek advice on measurement accuracy and IR control integration. The conversation includes links to related topics and resources for further assistance in reverse engineering and calibration of the device.
Summary generated by the language model.
ADVERTISEMENT