![[BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis](https://obrazki.elektroda.pl/8668296200_1671383374_thumb.jpg)
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 [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis](https://obrazki.elektroda.pl/1363810000_1671050077_thumb.jpg)
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](https://obrazki.elektroda.pl/5342452700_1671459494_thumb.jpg)
![[BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis](https://obrazki.elektroda.pl/6772105700_1671459494_thumb.jpg)
![[BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis](https://obrazki.elektroda.pl/6739540600_1671459494_thumb.jpg)
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 [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis](https://obrazki.elektroda.pl/5503901000_1671050197_thumb.jpg)
In it, the FileSystem tab:
![[BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis](https://obrazki.elektroda.pl/6931461700_1671050218_thumb.jpg)
There CreateFile to create autoexec.bat:
![[BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis](https://obrazki.elektroda.pl/9563721300_1671050239_thumb.jpg)
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 [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis](https://obrazki.elektroda.pl/8764921500_1671050430_thumb.jpg)
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 [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis](https://obrazki.elektroda.pl/1222251100_1671382530_thumb.jpg)
Then, in Home Assistant, we write the YAML code:
Code: YAML
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 [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis](https://obrazki.elektroda.pl/6651935000_1671383450_thumb.jpg)
In this way, we get a full history of measurements in HA:
![[BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis [BK7231T] LCD calendar/thermometer/hygrometer TH06 WiFi for TuyaMCU - Home Assis](https://obrazki.elektroda.pl/9765862100_1671383489_thumb.jpg)
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.