logo elektroda
logo elektroda
X
logo elektroda

Uploading OpenBK software to MOES BHT-002-GCLW v4 thermostat with TUYA CB3S BK7231N chip

tomik67 12792 133
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #91 21147106
    hard3d
    Level 7  
    p.kaczmarek2 wrote:
    Are you really sure that your device uses UART 2 for TuyaMCU?

    I also attached a photo of the device

    Image of a section of a red printed circuit board with visible traces and electronic components. Green and blue lines indicate UART1 and UART2 connections.
    UART1 Green lanes
    Blue UART2

    p.kaczmarek2 wrote:
    Have you tried to do Tuya config extraction to check the baud rate of the UART?

    I tried, but when reading I get the error "Failed to extract keys"
  • ADVERTISEMENT
  • #92 21147113
    p.kaczmarek2
    Moderator Smart Home
    Ok how do you power this device? Can you try to capture UART2 movement at 9600 and at 115200 bauds?
    Helpful post? Buy me a coffee.
  • #93 21147810
    hard3d
    Level 7  
    Hi. I calculated the exchange rate using the selection method. 34800 baud

    That's what the module sends to the MCU:
    Enabling adding to the app:
    //R 08.07.2024 22:39:00 WiFi received:
    55AA0001000000
    //R 08.07.2024 22:39:00 WiFi received:
    55AA000300010003
    //R 08.07.2024 22:39:00 WiFi received:
    55AA0004000003


    When adding an application:
    //R 08.07.2024 22:41:09 WiFi received:
    55AA000300010003
    //R 08.07.2024 22:41:17 WiFi received:
    55AA000300010205
    //R 08.07.2024 22:41:21 WiFi received:
    55AA000300010306
    //R 08.07.2024 22:41:21 WiFi received:
    55AA0008000007
    //R 08.07.2024 22:41:21 WiFi received:
    55AA00070002010009
    //R 08.07.2024 22:41:21 WiFi received:
    55AA0007000202000A
    //R 08.07.2024 22:41:21 WiFi received:
    55AA0007000224002C
    //R 08.07.2024 22:41:21 WiFi received:
    55AA000700020A0012
    //R 08.07.2024 22:41:21 WiFi received:
    55AA00070002100018
    //R 08.07.2024 22:41:21 WiFi received:
    55AA00070002180020
    //R 08.07.2024 22:41:21 WiFi received:
    55AA000700021F0027
    //R 08.07.2024 22:41:21 WiFi received:
    55AA00070002280030
    //R 08.07.2024 22:41:22 WiFi received:
    55AA000700022D0035
    //R 08.07.2024 22:41:22 WiFi received:
    55AA0007000213001B
    //R 08.07.2024 22:41:22 WiFi received:
    55AA000700021A0022
    //R 08.07.2024 22:41:22 WiFi received:
    55AA0007000217001F
    //R 08.07.2024 22:41:22 WiFi received:
    55AA0007000265006D
    //R 08.07.2024 22:41:22 WiFi received:
    55AA0007000266006E
    //R 08.07.2024 22:41:22 WiFi received:
    55AA00070002690071
    //R 08.07.2024 22:41:22 WiFi received:
    55AA000700021E0026
    //R 08.07.2024 22:41:22 WiFi received:
    55AA000700026A0072
    //R 08.07.2024 22:41:22 WiFi received:
    55AA000700026C0074
    //R 08.07.2024 22:41:22 WiFi received:
    55AA000700026D0075
    //R 08.07.2024 22:41:23 WiFi received:
    55AA000700026E0076
    //R 08.07.2024 22:41:23 WiFi received:
    55AA000700026F0077
    //R 08.07.2024 22:41:23 WiFi received:
    55AA00070002700078
    //R 08.07.2024 22:41:23 WiFi received:
    55AA00070002710079
    //R 08.07.2024 22:41:23 WiFi received:
    55AA0007000273007B
    //R 08.07.2024 22:41:24 WiFi received:
    55AA001C00080118070816291901A4
    //R 08.07.2024 22:41:24 WiFi received:
    55AA00070002100018
    //R 08.07.2024 22:41:24 WiFi received:
    55AA0034000A01020010020152030101AA
    
  • ADVERTISEMENT
  • #94 21147820
    p.kaczmarek2
    Moderator Smart Home
    Wait a second, are you sure? Please double check. 34800 baud? That's not a standard one. So far we've only seen 9600 and 115200 bauds on TuyaMCU devices.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #97 21149060
    divadiow
    Level 34  
    hard3d wrote:
    I tried, but when reading I get the error "Failed to extract keys"


    file contains below. no mention of baud tho

    Code: Text
    Log in, to see the code
  • #98 21174914
    tomik67
    Level 12  
    p.kaczmarek2 wrote:
    Counter I can't specifically add, but if there was already a change handler, you could simply increment the selected channel by 1 at the time of such an event (i.e., you could script a counter yourself)


    Could you help me to create such a reset script ?
    I gave up using an optocupler because it caused voltage drops, resulting in erroneous temperature readings from the sensor.
    I used a MOSFET transistor to cut the ground from the MCU. Now just this script controlling the communication.
  • #99 21253455
    hard3d
    Level 7  
    Hello friends! I decided to return to the issue of installing the Openbox firmware on my thermostat. I installed version 1.17.740 on it today and was finally able to run it. This is what my autoexec.bat looks like now:
    
    SetFlag 26 1
    
    startDriver NTP
    ntp_timeZoneOfs 3
    
    startDriver TuyaMCU
    tuyaMcu_setBaudRate 38400
    uartSendHex 55AA000300010306
    
    delay_s 20
    tuyaMcu_sendCurTime
    
    waitFor NTPState 1
    echo "NTP is ready"
    


    The time is set. But nothing comes to the log from TuyaMCU. Apparently, something was added to the firmware that the device started working on UART2. But something is missing to accept the answers.
  • ADVERTISEMENT
  • #100 21253543
    p.kaczmarek2
    Moderator Smart Home
    Maybe you're missing a tuyaMcu_defWiFiState call with a proper WiFi state?
    Helpful post? Buy me a coffee.
  • #101 21253590
    hard3d
    Level 7  
    p.kaczmarek2 wrote:
    Maybe you're missing a tuyaMcu_defWiFiState call with a proper WiFi state?

    I added this parameter. It does not affect the operation of the WiFi module in any way.
  • #102 21254152
    p.kaczmarek2
    Moderator Smart Home
    You need to set it after starting TuyaMCU and you need to power off and on whole device so it can take effect.

    Futhermore, waiting for NTPState after 20 seconds delay and after tuyaMcu_sendCurTime makes no sense.
    Helpful post? Buy me a coffee.
  • #103 21254483
    hard3d
    Level 7  
    I removed the specified resistors and connected the MCU to UART1

    PCB with removed resistors and MCU connected to UART1 with a blue outline.

    And with this autoexec.bat configuration, the module started receiving messages from the MCU

    
    startDriver NTP
    ntp_timeZoneOfs 3
    
    startDriver TuyaMCU
    tuyaMcu_setBaudRate 38400
    
    uartSendHex 55AA0001000000
    uartSendHex 55AA000300010003
    uartSendHex 55AA000300010205
    uartSendHex 55AA000300010306
    uartSendHex 55AA0008000007
    
    delay_s 20
    tuyaMcu_sendCurTime
    


    I have a list of DP IDs. I managed to manage some of them. And the part I don't understand is how to send a command.
    D PID 106 must turn on the backlight.

    Thermostat...07_05.xlsx Download (12.5 kB)

    
    // Send and Report
    setChannelType 1 Toggle
    setChannelLabel 1 "01 - Switch"
    
    // Send and Report
    setChannelType 2 ReadOnly
    setChannelLabel 2 "02 - Mode"
    
    // Send and Report
    setChannelType 3 Toggle
    setChannelLabel 3 "03 - Frost protection"
    
    // Send and Report
    setChannelType 4 Temperature_div10
    setChannelLabel 4 "04 - Set temperature"
    
    // Send and Report
    setChannelType 5 Temperature_div10
    setChannelLabel 5 "05 - Set temperature ceiling"
    
    // Send and Report
    setChannelType 6 ReadOnly
    setChannelLabel 6 "06 - Temperature scale"
    
    // Report Only
    setChannelType 7 Temperature_div10
    setChannelLabel 7 "07 - Current temperature"
    
    // Send and Report
    setChannelType 8 Temperature_div10
    setChannelLabel 8 "08 - Set temperature flooring"
    
    // Send and Report
    setChannelType 9 ReadOnly
    setChannelLabel 9 "09 - Weekly program"
    
    // Send and Report
    setChannelType 10 ReadOnly
    setChannelLabel 10 "10 - Working day setting"
    
    // Report Only
    setChannelType 11 ReadOnly
    setChannelLabel 11 "11 - Valve state"
    
    // Send and Report
    setChannelType 12 Toggle
    setChannelLabel 12 "12 - Child lock"
    
    // Report Only
    setChannelType 13 ReadOnly
    setChannelLabel 13 "13 - Fault warning"
    
    // Report Only
    setChannelType 14 ReadOnly
    setChannelLabel 14 "14 - Support features"
    
    // Report Only
    setChannelType 15 ReadOnly
    setChannelLabel 15 "15 - Temperature adjust step"
    
    // Report Only
    setChannelType 16 ReadOnly
    setChannelLabel 16 "16 - Mfg model"
    
    // Send and Report
    setChannelType 17 ReadOnly
    setChannelLabel 17 "17 - Backlight Setting"
    
    // Report Only
    setChannelType 18 ReadOnly
    setChannelLabel 18 "18 - Battery power"
    
    // Report Only
    setChannelType 19 ReadOnly
    setChannelLabel 19 "19 - Temp calibration step"
    
    // Send and Report
    setChannelType 20 ReadOnly
    setChannelLabel 20 "20 - Temp calibration"
    
    // Report Only
    setChannelType 21 ReadOnly
    setChannelLabel 21 "21 - Valve state"
    
    // Report Only
    setChannelType 22 ReadOnly
    setChannelLabel 22 "22 - Software version"
    
    // Send and Report
    setChannelType 23 ReadOnly
    setChannelLabel 23 "23 - Switch diff"
    
    // Send and Report
    setChannelType 24 ReadOnly
    setChannelLabel 24 "24 - Sensor type"
    
    // Send and Report
    setChannelType 25 ReadOnly
    setChannelLabel 25 "25 - Floor sensor type"
    
    // Send and Report
    setChannelType 26 Temperature_div10
    setChannelLabel 26 "26 - Floor temperature"
    
    
    // linkTuyaMCUOutputToChannel dpId verType tgChannel
    linkTuyaMCUOutputToChannel 1 1 1
    linkTuyaMCUOutputToChannel 2 4 2
    linkTuyaMCUOutputToChannel 10 1 3
    linkTuyaMCUOutputToChannel 16 2 4
    linkTuyaMCUOutputToChannel 19 2 5
    linkTuyaMCUOutputToChannel 23 4 6
    linkTuyaMCUOutputToChannel 24 2 7
    linkTuyaMCUOutputToChannel 26 2 8
    linkTuyaMCUOutputToChannel 30 0 9
    linkTuyaMCUOutputToChannel 31 4 10
    linkTuyaMCUOutputToChannel 36 4 11
    linkTuyaMCUOutputToChannel 40 1 12
    linkTuyaMCUOutputToChannel 45 5 13
    linkTuyaMCUOutputToChannel 101 2 14
    linkTuyaMCUOutputToChannel 102 2 15
    linkTuyaMCUOutputToChannel 105 3 16
    linkTuyaMCUOutputToChannel 106 0 17
    linkTuyaMCUOutputToChannel 107 2 18
    linkTuyaMCUOutputToChannel 108 2 19
    linkTuyaMCUOutputToChannel 109 2 20
    linkTuyaMCUOutputToChannel 110 1 21
    linkTuyaMCUOutputToChannel 111 3 22
    linkTuyaMCUOutputToChannel 112 2 23
    linkTuyaMCUOutputToChannel 113 4 24
    linkTuyaMCUOutputToChannel 114 2 25
    linkTuyaMCUOutputToChannel 115 2 26
    
  • #104 21254908
    p.kaczmarek2
    Moderator Smart Home
    hard3d wrote:
    And the part I don't understand is how to send a command.
    D PID 106 must turn on the backlight.

    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md
    You can use tuyaMcu_sendState command. You should also try using tuyaMcu_sendCmd instead lf Uart send, so it calculates checksum on it's own.
    Sample usage:
    
    // tuyaMcu_sendCmd 0x30 000000
    // This will send 55 AA 00 30 00 03 00 00 00 32
    
    Helpful post? Buy me a coffee.
  • #105 21255785
    Janco245
    Level 10  
    Hello everyone,

    I have 12 Moes BHT-002 thermostats at home, which originally used WB3S chips. I replaced these with ESP12 and uploaded the thermostat-v1.22-fas.bin.gz firmware. It works great, but the thermostats occasionally freeze, and I have to disconnect and reconnect the power to get them running again. I decided to revert back to the WB3S chips and try using the OpenBK firmware. However, I read that Tomik67 is also having freezing issues with this firmware.

    I am trying to use the code that Tomik67 wrote. The communication through the web interface works well, but I’m struggling to add the thermostat to Home Assistant (HA). It adds automatically, but the temperature is displayed incorrectly— the value of 17 is shown as 17x2/10=3.4. Additionally, there is no option to change the temperature.

    Is there a way to modify the code in OpenBK so that HA recognizes the thermostat correctly? Or is the only option to add it directly through YAML? I’ve tried to add the thermostat to the configuration.yaml following Tomik67 instructions, but I haven’t been successful so far. I don’t have much programming knowledge, so I would greatly appreciate any help.


    Thank you very much for any assistance!

    Thermostat user interface displaying settings and status. Thermostat control panel in an app.
  • #106 21257041
    tomik67
    Level 12  
    Janco245 wrote:
    It works great, but the thermostats sometimes hang up
    .

    Hi. Unfortunately the problem with the thermostat hanging up is due to instability of the MCU or its software. I have returned the hanging thermostats, leaving one for testing purposes. Because of such cases, I always make a backup of the original to restore it in case of problems and advertise the unit.
    As for the Home Assistrant - you need to add the config file yourself to configuration.yaml and declare the device as mqtt: climate: as in my earlier example, then HA will recognise it as a thermostat.
    The only trouble for you will be with the entity showing the actual state of the thermostat relay, ( mode_state_topic: 'BHT_B_cabinet/5/get', " because originally the thermostat does not send a state, the TUYA application infers the state based on comparing the actual temperature with the desired temperature, you need to rework the thermostat to read the presence of the voltage controlling the relay and pass this information to the free WB3S pin and include this in the configuration.
    The topic has been covered here before, do a search, this has also been written about on the Tasmota forum, if you have trouble finding topics let me know, I can help.
  • #107 21257408
    Janco245
    Level 10  
    Thank you for your response. I haven't yet added the thermostat to Home Assistant, and it has already frozen. In this case, it doesn't make sense for me to try to integrate the thermostat into HA with the openBK software if it freezes just like it does with the thermostat-v1.22-fas.bin.gz firmware on the ESP8266. I was under the impression that the thermostats were freezing due to the replacement of WB3S with ESP12.

    I had the thermostats running for about 3 months with Tuya software, and they never froze. Do you think the Tuya software somehow detects a freeze and restarts the MCU? I also have 10 other thermostats at work, which I purchased a bit earlier, and those have the ESP8266 chip straight from the factory. The PCB is slightly different, but they look the same, and their labeling is identical. After flashing the software, those thermostats don’t have any freezing issues.

    The thermostats that are freezing were purchased from AliExpress about a year ago, so I can't return them anymore. Do you think there’s any way to resolve the freezing issue? Or would it be better to switch back to Tuya software and add them through the cloud?
  • #108 21257466
    hard3d
    Level 7  
    Hello friends!
    I'm still working on my thermostat. And there are 2 questions.
    1) There is DPIP 106 "Backlight Setting". 55 AA 03 07 00 0C 6A 00 00 08 04 B0 01 E0 00 00 64 00 80
    Which indicates the operating time of the backlight, brightness and status. Is it possible to somehow decompose blocks into variables and manage them from the main interface of the module? And how can HEX be sent from MQTT to TuyaMCU to manage this DPID?

    2) The thermostat has 4 icons of the current weather.
    Digital thermostat display with weather icons and temperature information.
    I know how to turn them on. Are there any developments on the request of the current weather by the module and the execution of any actions?
  • #109 21257841
    p.kaczmarek2
    Moderator Smart Home
    1. it looks like a raw data packet:
    TuyaMCU Explorer software with data analyzer in hex format.
    Value seems to be 04 B0 01 E0 00 00 64 00, it should be possible to guess the meaning of each bytes but we would need to have separate captures with noted settings, like "this packet set 90% brightness" and then you look for value 90 (as hex), then the same for date, etc, etc. I don't think I can guess that without such sample data captures.
    2. I don't understand the question. Can you be more specific?
    How do you turn those icons on?
    You can request TuyaMCU data points via tuyaMcu_sendQueryState command, if that's what you're asking for?
    Or do you want OpenBeken to request weather from web?
    Helpful post? Buy me a coffee.
  • #110 21257968
    hard3d
    Level 7  
    1) I have an explanation for each byte from the seller.
    Byte0 - Byte1: 完全关闭背光的起始时间,距离00:00的分钟数
    Byte2 - Byte3:完全关闭背光的结束时间,距离00:00的分钟数
    Byte4 - Byte5:屏幕熄灭到夜模式生效前的时间,单位秒
    Byte6:屏幕熄灭到夜模式生效前的背光亮度,1-100
    Byte7:夜模式是否使能

    2) Here is the HEX of enabling three icons.

    // The Sun
    55AA0034000A010200030201510301019C

    // Cloudy
    55AA0034000A01020012020146030102A1

    // Rain
    55AA0034000A010200030201500301039D

    As far as I understand, the original firmware determines the location of the device and the current weather by IP and includes the desired icon.
  • #111 21259744
    tomik67
    Level 12  
    >>21257408 .
    Unfortunately nothing will help, neither swapping modules nor TUYA servers, the fault is either a faulty MCU or badly written MCU firmware which leads to a "Memory Leak" and freezes the MCU.
    Your earlier thermostats may have a different MCU, I have already had to deal with three different mudules (ESP8266, WB3S, CB3S) and four different MCUs when ordering the BHT-002 and WHT-002, working on 3.3V and others on 5V.
    The Chinese ship whatever they have on hand or a foot, three months ago I ordered four black BHT-002s for a friend from one vendor, received two with ESP8266 and two WB3S. Even the model designations sometimes don't matter to them, your thermostats came with WB3S modules so they should be marked WHT-002 not BHT.
  • #112 21296420
    mvz0209
    Level 5  
    Hello! Thank you for your work. tomik67 and p.kaczmarek2 did a great job.
    I connected the thermostat to Home Assistant, found the output to reset the thermostat. Soldered it to pin P26.

    Electronic thermostat circuit on a printed circuit board.[/url]

    Please help me write the correct script in autoexecs.bat
    I would like the thermostat to reboot at 30 messages with
    heartbeat_valid = 0
    , and there would be a reboot counter

    Thanks
  • #113 21298207
    mvz0209
    Level 5  
    Please tell me which command can be used to find
    heartbeat_valid = 0

    Added after 4 [hours] 39 [minutes]:

    p.kaczmarek2 wrote:
    I can plug the counting of seconds without heartbeat into events and then using addChangeHandler will be able to trigger the handling of this.


    Please tell me how to run such a counter?
  • #114 21319850
    p.kaczmarek2
    Moderator Smart Home
    With todays update, I've added support for "MissedHeartbeats" to the main releases.
    Sample usage:
    
    addChangeHandler MissedHeartbeats > 4 setChannel 0 1
    

    This should fire event when number of missed heartbeats becomes larger than 4 (i.e. on transition from 4 to 5). It will NOT fire again once it changes from like 5 to 6, etc. It detects transition.

    The more missed heartbeats, the longer TuyaMCU is offline.

    See code:
    https://github.com/openshwprojects/OpenBK7231...mmit/8c0bafc0626157e1eeab1fb210a2f84b8d5d0097
    Helpful post? Buy me a coffee.
  • #115 21326317
    mvz0209
    Level 5  
    p.kaczmarek2 wrote:
    With today's update, I've added support for "MissedHeartbeats" to the main releases.
    Sample usage:
    
    addChangeHandler MissedHeartbeats > 4 setChannel 0 1
    

    This should fire event when number of missed heartbeats becomes larger than 4 (i.e. on transition from 4 to 5). It will NOT fire again once it changes from like 5 to 6, etc. It detects transition.

    The more missed heartbeats, the longer TuyaMCU is offline.


    Thank you very much for your work! I will definitely test it and supplement it. BHT-002 thermostats are very common.
  • #116 21330239
    mvz0209
    Level 5  
    Great, today I caught the thermostat hanging by turning on pin 26. Now it just turned off when it freezes.


    now I have made a script where channel 10 is a hang counter. We are testing further:

    setChannel 10 0
    alias FaltHeartbeats backlog setChannel 0 1; addChannel 10 1; delay_s 2; setChannel 0 0
    addChangeHandler MissedHeartbeats > 4 FaltHeartbeats

    Moderated By p.kaczmarek2:


    Please note that delay_s in backlog will work only in OBK builds later than 2025.06.19. It was not supported before.

  • #117 21330264
    divadiow
    Level 34  
    Can anyone with a factory firmware backup please send me a copy. Thanks!
  • #118 21333687
    mvz0209
    Level 5  
    p.kaczmarek2 Thank you very much, my thermostat is working. There have already been 2 reboots due to the freeze
  • #119 21358174
    tomik67
    Level 12  
    >>21330264 .
    I don't know what firmware you are referring to, I have copies of all the modules (CB3S, WB3S) in the thermostats I converted from TUYA to OBK at my disposal.
    However, if it is the MCU software that is causing the problems and is described in the last posts of this thread then I don't know how to go about reading it.
    I have kept one thermostat with a freezing problem and am willing to experiment if I get instructions on how to go about it.
  • #120 21358422
    p.kaczmarek2
    Moderator Smart Home
    I think he asked for original Tuya 2MB backup. It can be used to extract some more information about the device.
    Helpful post? Buy me a coffee.

Topic summary

The discussion revolves around uploading OpenBK software to the MOES BHT-002-GCLW v4 thermostat, which contains a TUYA CB3S BK7231N chip. Users share their experiences with flashing the device, including the need to identify dpIDs for proper functionality. The conversation highlights challenges such as the absence of relay status reporting, the necessity of mapping dpIDs to channels, and the importance of configuring the autoexec.bat file correctly. Users also discuss issues with the thermostat freezing and potential solutions, including using a MOSFET for power control and implementing a reset script. Additionally, there are inquiries about integrating the thermostat with Home Assistant and managing temperature settings through MQTT.
Summary generated by the language model.
ADVERTISEMENT