logo elektroda
logo elektroda
X
logo elektroda

[BK7231N] [CB3S] [AHT20] TH01 Generic Temperature and Humidity Sensor Teardown

anthonythomas 56094 180
Best answers

How do I finish the OpenBK autoexec setup for a TH01 temperature and humidity sensor with TuyaMCU?

Add the TuyaMCU-to-channel mappings, not just the two drivers: `startDriver TuyaMCU; startDriver tmSensor; setChannelType 1 temperature_div10; linkTuyaMCUOutputToChannel 1 val 1; setChannelType 2 Humidity; linkTuyaMCUOutputToChannel 2 val 2; setChannelType 3 ReadOnlyLowMidHigh; linkTuyaMCUOutputToChannel 3 enum 3; setChannelLabel 3 Battery` [#20516557][#20516646][#20845707] dpID 1 is temperature in tenths of a degree, dpID 2 is humidity, and dpID 3 is the battery state (low/mid/high) [#20516557][#20516646] For battery-powered operation, the Wi‑Fi module is controlled by the MCU, so initial setup often needs external 3.3 V to the Wi‑Fi module; for no-MQTT use, OBK can either use `tuyaMcu_defWiFiState 0x04` or an empty MQTT host field in newer builds [#20642216][#20931402]
AI summary based on the discussion. May contain errors.
ADVERTISEMENT
  • Asking what autoexec.bat drivers are needed for TH01

    #1 20515876
    anthonythomas
    Level 9  
    Posts: 40
    Help: 4
    Rate: 16
    Teardown of TH01 Generic Temperature and Humidity Sensor
    Firmware dump attached.

    Managed to flash OpenBK7231N firmware but I'm now stuck.
    WiFi settings set. Running off 3V3 and bypassing the ground transistor I can access the WebUI to be able to setup.

    Any ideas what needs adding to autoexec.bat other than?
    startDriver TuyaMCU
    startDriver tmSensor


    Happy to try and dump other info if needed.

    [BK7231N] [CB3S] [AHT20] TH01 Generic Temperature and Humidity Sensor Teardown [BK7231N] [CB3S] [AHT20] TH01 Generic Temperature and Humidity Sensor Teardown [BK7231N] [CB3S] [AHT20] TH01 Generic Temperature and Humidity Sensor Teardown [BK7231N] [CB3S] [AHT20] TH01 Generic Temperature and Humidity Sensor Teardown [BK7231N] [CB3S] [AHT20] TH01 Generic Temperature and Humidity Sensor Teardown [BK7231N] [CB3S] [AHT20] TH01 Generic Temperature and Humidity Sensor Teardown
  • ADVERTISEMENT
  • Use OpenBeken logs to capture TuyaMCU dpIDs

    #2 20515887
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12865
    Hello,
    doing a RX/TX communication of TuyaMCU dump with original firmware could help, but you can also use already OpenBeken and just check in Web App Logs to see what kind of dpIDs and values are sent to the WiFi module from MCU. Please disconnect 3.3V bypass, keep Web App log open and wait until WiFI module is powered on by the MCU and then copy logs content to see what is being reported over UART>
    Helpful post? Buy me a coffee.
  • #3 20515889
    anthonythomas
    Level 9  
    Posts: 40
    Help: 4
    Rate: 16
    Sorry, forgot to attach the firmware dump
    Attachments:
    • readResult_BK7231N_QIO_2023-30-3--10-35-01.zip (1007.31 KB) You must be logged in to download this attachment.
  • TuyaMCU query state and dp parsing logs

    #4 20516504
    anthonythomas
    Level 9  
    Posts: 40
    Help: 4
    Rate: 16
    This is what I've got so far

    Info:TuyaMCU:TUYAMCU received: 55 AA 00 01 00 24 7B 22 70 22 3A 22 6C 66 33 36 79 35 6E 77 62 38 6A 6B 78 77 67 67 22 2C 22 76 22 3A 22 31 2E 30 2E 30 22 7D 99 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 1 (QueryProductInformation) with 43 bytes
    Info:TuyaMCU:TuyaMCU_ParseQueryProductInformation: received {"p":"lf36y5nwb8jkxwgg","v":"1.0.0"}
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 2 (MCUconf) with 7 bytes
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 08 00 0F 00 01 01 01 01 01 01 01 02 00 04 00 00 00 C8 EB 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 8 (QueryState) with 22 bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: processing dpId 1, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: raw data 4 int: 200
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 08 00 0F 00 01 01 01 01 01 01 02 02 00 04 00 00 00 49 6D 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 8 (QueryState) with 22 bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: processing dpId 2, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: raw data 4 int: 73
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 08 00 0C 00 03 03 03 03 03 03 03 04 00 01 00 2D 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 8 (QueryState) with 19 bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: processing dpId 3, dataType 4-DP_TYPE_ENUM and 1 data bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: raw data 1 byte: 
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 10 00 02 01 09 1B 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 16 (Unknown) with 9 bytes
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: unhandled type 16
    [/code]
  • #5 20516557
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12865
    Not bad. It seems that dpID 1 is a raw value 200, which is 20.0C (you have to divide it by 10) and that dpID 2 is 73 which is most likely 73% humidity.

    I don't know what is dpID 3, which is an enum type.

    Do you know how to write the autoexec.bat config needed to map those dpIDs to the OBK channels and later publish them via MQTT?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • TuyaMCU dp mappings for TH01 sensor values

    #6 20516646
    anthonythomas
    Level 9  
    Posts: 40
    Help: 4
    Rate: 16
    And some more

    Info:TuyaMCU:TUYAMCU received: 55 AA 00 01 00 24 7B 22 70 22 3A 22 6C 66 33 36 79 35 6E 77 62 38 6A 6B 78 77 67 67 22 2C 22 76 22 3A 22 31 2E 30 2E 30 22 7D 99 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 1 (QueryProductInformation) with 43 bytes
    Info:TuyaMCU:TuyaMCU_ParseQueryProductInformation: received {"p":"lf36y5nwb8jkxwgg","v":"1.0.0"}
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 02 00 00 01 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 2 (MCUconf) with 7 bytes
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 08 00 0F 00 01 01 01 01 01 01 01 02 00 04 00 00 00 D5 F8 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 8 (QueryState) with 22 bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: processing dpId 1, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: raw data 4 int: 213
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 08 00 0F 00 01 01 01 01 01 01 02 02 00 04 00 00 00 4E 72 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 8 (QueryState) with 22 bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: processing dpId 2, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: raw data 4 int: 78
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 08 00 0C 00 03 03 03 03 03 03 03 04 00 01 01 2E 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 8 (QueryState) with 19 bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: processing dpId 3, dataType 4-DP_TYPE_ENUM and 1 data bytes
    Info:TuyaMCU:TuyaMCU_V0_ParseRealTimeWithRecordStorage: raw data 1 byte: 
    Info:TuyaMCU:TUYAMCU received: 55 AA 00 10 00 02 01 09 1B 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 16 (Unknown) with 9 bytes
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: unhandled type 16


    Added after 16 [minutes]:

    I have them mapped
    Just need to figure out the MQTT part

    startDriver TuyaMCU
    startDriver tmSensor
    setChannelType 1 temperature_div10
    linkTuyaMCUOutputToChannel 1 val 1
    setChannelType 2 Humidity
    linkTuyaMCUOutputToChannel 2 val 2



    [BK7231N] [CB3S] [AHT20] TH01 Generic Temperature and Humidity Sensor Teardown
  • #7 20516914
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12865
    You might also want to select this flag:
    [BK7231N] [CB3S] [AHT20] TH01 Generic Temperature and Humidity Sensor Teardown

    Then check in readme to see how are channel values published.

    Also check "publish all mcu channels" flag and maybe "publish self state on connect".
    Helpful post? Buy me a coffee.
  • MQTT sensor entities found in Home Assistant

    #8 20517557
    anthonythomas
    Level 9  
    Posts: 40
    Help: 4
    Rate: 16
    I've added the following to configuration.yaml but don't see the sensor in the MQTT devices.

    mqtt:
     sensor:
       - unique_id: OpenBK7231N_1F70E60F_TH_1_T     
         name: "OpenBK7231N_1F70E60F_TH_1_T"
         state_topic: "obk1F70E60F/1/get"
         unit_of_measurement: 'C'
         value_template: "{{ (value | float * 0.1 | round(1)) }}"
         
       - unique_id: OpenBK7231N_1F70E60F_TH_1_H     
         name: "OpenBK7231N_1F70E60F_TH_1_H"
         state_topic: "obk1F70E60F/2/get"
         unit_of_measurement: '%'
         value_template: "{{ value }}"


    Added after 39 [minutes]:

    It works - I was expecting to see the device published in the MQTT integration menus but it isn't.
    Searched for the entity and it is there. Just got an issue that since restart the published data is being calculated down!
    Will adjust the MQTT template.

    [BK7231N] [CB3S] [AHT20] TH01 Generic Temperature and Humidity Sensor Teardown
  • Helpful post

    Use only one scaling method for the sensor value

    #9 20517650
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12865
    I can see something strange on this graph, but what do you mean by "calculated down"? Is it just a "0" value sent or something else?

    Btw you don't need thaT:
    
         value_template: "{{ (value | float * 0.1 | round(1)) }}"
    

    if you set this flag:
    [BK7231N] [CB3S] [AHT20] TH01 Generic Temperature and Humidity Sensor Teardown
    You can use either one of this options, but not two at them together.
    Helpful post? Buy me a coffee.
  • Flag 33 caused MQTT graph drop; dpID 3 likely battery state

    #10 20517669
    anthonythomas
    Level 9  
    Posts: 40
    Help: 4
    Rate: 16
    The drop in the graph looks to be when I enabled Flag 33 - so that makes sense.
    MQTT was working fine before that when I didn't realise.

    I've removed the calculation from the MQTT template and it's correct again.

    [BK7231N] [CB3S] [AHT20] TH01 Generic Temperature and Humidity Sensor Teardown

    Added after 18 [minutes]:

    I'm guessing dpID 3 is relating to the battery state/level.

    I have another of the same sensor still running through Tuya and the diagnostics from Home Assistant gives the following details.
    Obviously low/middle/high doesn't tell us much, but better than nothing.

          "battery_state": {
            "type": "Enum",
            "value": {
              "range": [
                "low",
                "middle",
                "high"
              ]
            }
  • #11 20517695
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12865
    I think it matches what I said in the Door Sensor topic:
    https://www.elektroda.com/rtvforum/topic3914412.html
    Helpful post? Buy me a coffee.
  • #12 20582527
    grericht
    Level 6  
    Posts: 13
    Rate: 1
    did you get it to work? have the same sensor and like to flash openbk
  • #13 20582536
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12865
    Do you mean humidity sensor?
    Yes, here is description in polish (use google translate):
    https://www.elektroda.com/rtvforum/topic3975583.html
    Here will be soon english version:
    https://www.elektroda.com/rtvforum/topic3975583.html
    Helpful post? Buy me a coffee.
  • #14 20582702
    grericht
    Level 6  
    Posts: 13
    Rate: 1
    but there is no tutorial for flashing? only configuration?!
  • Temporary RX/TX trace cuts needed for flashing

    #15 20582789
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12865
    Well, you flash it as usual, it's the same for all devices... well, maybe except, in this case you also have to cut temporarily RX/TX traces because TuyaMCU may interfere with the procedure. Or desolder WiFi module, or desolder TuyaMCU.
    Here is our flasher:
    https://github.com/openshwprojects/BK7231GUIFlashTool
    Here is a generic flashing guides playlist:
    https://www.youtube.com/playlist?list=PLzbXEc2ebpH0CZDbczAXT94BuSGrd_GoM
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #16 20588120
    anthonythomas
    Level 9  
    Posts: 40
    Help: 4
    Rate: 16
    I used the standard flashing procedure.
    Unsurprisingly the battery life isn't great, which seems similar for other WiFi sensors where you've got more frequent updates.

    Much prefer zigbee for these.
  • Helpful post
    #17 20588135
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12865
    The OBK battery powered devices driver (TuyaMCU) has been updated in a meantime, also a quick connect and static IP were introduces, the battery devices will last longer (much longer) with latest OBK builds.
    Helpful post? Buy me a coffee.
  • #18 20588136
    anthonythomas
    Level 9  
    Posts: 40
    Help: 4
    Rate: 16
    Thanks. I'll update and try
  • Need boot-mode bridge for TH01 flashing

    #19 20626300
    grericht
    Level 6  
    Posts: 13
    Rate: 1

    Hi,
    I try some options to flash the TH01. But nothing works. I don't get a connection for flashing with BK7231 GUI Flash Tool.
    Do I have to desolder or to bridge something?

    I try rx2 tx2 bat+ and - and bridged ground from chip
    and I try to connect tx rx + and - directly from the chip
    the th01 every time goes in slow blinking mode.
    for tasmota I had to bridge pin g01 and reset for boot mode. I can't find something to do for boot mode. only switch power off and on during flash. I have a separate 3.3v power supply. I also try to get in flash mode by bridging cen pin. but never get it work.

    [BK7231N] [CB3S] [AHT20] TH01 Generic Temperature and Humidity Sensor Teardown [BK7231N] [CB3S] [AHT20] TH01 Generic Temperature and Humidity Sensor Teardown [BK7231N] [CB3S] [AHT20] TH01 Generic Temperature and Humidity Sensor Teardown [BK7231N] [CB3S] [AHT20] TH01 Generic Temperature and Humidity Sensor Teardown [BK7231N] [CB3S] [AHT20] TH01 Generic Temperature and Humidity Sensor Teardown [BK7231N] [CB3S] [AHT20] TH01 Generic Temperature and Humidity Sensor Teardown
  • ADVERTISEMENT
  • TuyaMCU requires severing BK7231 serial link to flash

    #20 20626343
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12865

    @gerricht, this is TuyaMCU device, the BK7231 module is connected on TX1 and RX1 to the microcontroller on the board. It's not possible to flash it in this configuration. You have to sever the connection. You have about 3 options:
    - cut the traces and reconstruct them
    - desolder BK7231 module for the time of flashing
    - desolder microcontroller in SOIC case for the time of flashing.
    Then you have to flash, reconnect them again, and configure tmSensor driver, but take care - that MCU has transistor and it controls power of WiFi module!
    Read more: https://www.elektroda.com/rtvforum/topic3914412.html
    Helpful post? Buy me a coffee.
  • Clarifying CB3S flashing and trace-cutting options

    #21 20626372
    grericht
    Level 6  
    Posts: 13
    Rate: 1
    Thank you. I don't understand everything.

    1. Can I desolder the CB3's plate, flash it, and then reconnect it?

    2. Do I need to desolder the marked microcontroller in SOIC case for the time of flashing and then reconnect it? [BK7231N] [CB3S] [AHT20] TH01 Generic Temperature and Humidity Sensor Teardown

    3. Can you tell me which traces to cut and then reconnect after flashing?

    Anthonythomas did none of these options?! He only connected +, -, RX2, TX2, and GND pins: https://obrazki.elektroda.pl/4823984400_1680177825.png. Why does this work for him and not for me? What is the difference?
  • Cut the TuyaMCU UART traces before flashing

    #22 20626419
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12865

    I don't know this particular device, but usually TuyaMCU devices need to be disconnected from the MCU before flashing. I don't know what exactly the thread author did.

    First of all, I would suggest you check if the TX2 and RX2 pads on the board are connected to RX1 and TX1 of the WiFi module. If so, then they are the UART port used for both flashing and TuyaMCU communication.

    I am asking because there is also a UART2 port, also called TX2/RX2, on the WiFi module, but that's a separate thing. So the naming is confusing here.

    Which traces to cut in option three, you ask? Well, the TuyaMCU traces. The UART port connection between the SOIC microcontroller and the TX1/RX1 of the WiFi module.
    Helpful post? Buy me a coffee.
  • #23 20626502
    grericht
    Level 6  
    Posts: 13
    Rate: 1
    Thank you.
    Red and green are connected. I think it is possible for me to cut and then reconnect at the yellow traces.
    Maybe it would be easier to desolder, for example, the orange part and do power supply at the pins of CB3's plate. But is this not possible? [BK7231N] [CB3S] [AHT20] TH01 Generic Temperature and Humidity Sensor Teardown
  • Connect 3.3 V directly to CB3S VDD for flashing

    #24 20626759
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12865

    Why do you want to desolder the part in the orange circle, the Q1, the MOSFET that is controlled via MCU to turn on and off the CB3S power? It is not the problem.

    Now I think that maybe your issue is that you didn't connect 3.3V directly to CB3S. I can see that in your picture. Maybe no desoldering is needed.

    Please try connecting 3.3V directly to CB3S VDD pin. And then attempt flashing again. MAYBE it will work when the microcontroller in SOIC is sleeping. I am not sure. Attempt several times. If flashing still fails, you have to sever the UART connection.
    Helpful post? Buy me a coffee.
  • Ground loop between USB-serial and power supply suspected

    #25 20627237
    grericht
    Level 6  
    Posts: 13
    Rate: 1

    I also tried to connect 3.3V directly to CB3S, but same problem.
    Now I cut the RX and TX traces and got connection, but it stops. Why? Not same time every try but nearly, and with all baud rates. [BK7231N] [CB3S] [AHT20] TH01 Generic Temperature and Humidity Sensor Teardown
    I tried 2 serial-USB adapters and 2 types of power supply. Every time same error.

    Added after 3 [minutes]:

    Now it goes to 100%.
    "CRC matches 0xA4183270!
    Writing file data to chip success."
    Change was to unbridge GRD from USB-serial to ground from power supply. Or luck.

    EDIT02: And now flashing stops again. Don't know what the problem is.
  • #26 20627443
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12865

    Hmm, strange, just to be sure, can you also check with hid_download_py Python tool? Please see this video for a guide and console command:
    https://www.youtube.com/watch?v=PKkiqDNFIx8
    I am asking because there have been some rare reports regarding GUI flasher issues on certain environments.
    Helpful post? Buy me a coffee.
  • #27 20627454
    grericht
    Level 6  
    Posts: 13
    Rate: 1

    I also have a thermo-hygrometer with a cbu chip. I tested flashing this chip and got the same problem: "The beginning of buffer in UART contains ... data."

    I will test with Python maybe next week. Actually, I have no Linux.
  • #28 20627616
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12865
    It can work on Windows. I have used it on Windows.
    Helpful post? Buy me a coffee.
  • OpenBeken AP disconnects on Tuya thermo-hygrometers

    #29 20628035
    grericht
    Level 6  
    Posts: 13
    Rate: 1

    Ok. Will try this next.

    I now have reached 2 different Tuya thermo/hygrometers with Open Beken flashed.
    1 I have resoldered the cut traces and on the other I didn't up to now.
    When I power the devices there is the Open Beken net, but on both I only get a short connection and can't reach 192.168.4.1. Connection will be lost very shortly.
    Is this because of the energy-saving mode of these devices?
    Did I have to resolder both?
    How can I get the configuration on the devices?
  • MCU powers WiFi module via transistor switch

    #30 20628047
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12865

    Well, @grericht, I think you would benefit a lot from reading related topics.
    https://www.elektroda.com/rtvforum/topic3914412.html
    Btw, in this topic, isn't it your device?
    https://www.elektroda.pl/rtvforum/topic3975583.html
    I was working on it remotely, with @DeDaMrAz

    But again, yes, you are right, as I said, the MCU (in SOIC case) controls power of WiFi module via that tiny transistor on the board. You have to either connect power to CB3S directly for the time of the configuration or you can do a serious circuit modification, remove MCU permanently and connect AHT20 directly to WiFi module... and use our deep sleep feature.

    Now I would recommend you to consult both topics linked above and then we can try to help you more, maybe @DeDaMrAz can also say something as he has this device, I never had it so far, I only helped him to get it running.
    Helpful post? Buy me a coffee.

Topic summary

✨ Discussion of tearing down and flashing a TH01 generic temperature/humidity sensor based on BK7231N/CB3S with an AHT20 sensor and TuyaMCU. The main challenge was getting OpenBK7231N/OpenBeken working with the battery-powered TuyaMCU design: flashing often required cutting the MCU TX/RX traces or otherwise isolating the Wi‑Fi module, and the module could only be configured reliably when powered externally at 3.3 V because the MCU switches Wi‑Fi power off to save battery. Logs showed TuyaMCU dpIDs for temperature, humidity, and battery state; temperature was mapped as dpID 1 with value/10, humidity as dpID 2, and battery state as dpID 3 using a LowMidHigh/enum channel type. MQTT/Home Assistant setup was discussed, including channel mapping, discovery, templates, and the need to avoid double scaling when using the OBK temperature_div10 channel type. Later posts covered variants with different dpIDs, AHT30/CHT8315 sensors, flashing issues, log collection, and battery-life improvements such as quick connect, static IP, reduced boot timeout, and AHT2X_Cycle interval tuning.
AI summary based on the discussion. May contain errors.

FAQ

TL;DR: TH01 users get 3 core dpIDs; "you have to divide it by 10" for temperature. This FAQ helps OpenBeken users flash BK7231N/CB3S TH01 sensors, map TuyaMCU data, avoid 0 readings, and publish to MQTT/Home Assistant. [#20516557]

Why it matters: A TH01 can flash successfully yet still fail if TuyaMCU power control, UART isolation, dpIDs, or MQTT timing are wrong.

Option What the thread reports Practical impact
WiFi TH01 with TuyaMCU CB3S/CBU wakes for short reporting windows Harder flashing, shorter battery life
Zigbee TH sensor Mentioned as preferred for these sensors Easier battery use with Home Assistant
BLE THB2/BTHome Used with ESP32 Bluetooth proxy Good battery alternative to WiFi
Direct OBK deep sleep Only after removing/bypassing MCU design More invasive hardware work

Key insight: In the stock TH01 design, the MCU controls WiFi-module power. Configure TuyaMCU/tmSensor while externally powering CB3S, then test on batteries so the MCU sends real sensor frames.

Quick Facts

  • Original TH01 TuyaMCU logs show dpID 1 as raw 200, meaning 20.0 °C, and dpID 2 as 73% humidity. [#20516504]
  • A working basic OpenBeken mapping uses temperature_div10 on channel 1 and Humidity on channel 2. [#20516646]
  • Battery state is an enum: low, middle, high; later users mapped it as values 0, 1, and 2. [#20845859]
  • For difficult flashing, users cut RX/TX traces, supplied 3.3 V directly, and sometimes succeeded after changing ground wiring or retrying. [#20627237]
  • For faster battery wakes, users enabled WiFi quick connect, reduced boot-ok time from 5 s to 3 s, and used static IP. [#20768091]

How do I flash OpenBeken on a Tuya TH01 temperature and humidity sensor with a BK7231N CB3S module?

Flash it like other BK7231N devices, but isolate or control the TuyaMCU path first.
  1. Solder 3.3 V, GND, TX, RX, and optionally CEN.
  2. Use BK7231 GUI Flash Tool with the BK7231N firmware.
  3. After flashing, power CB3S directly at 3.3 V for configuration.
Some boards flash without cutting traces. Others need RX/TX cut, CB3S desoldering, or MCU disconnection. Use TX-to-RX and RX-to-TX wiring, and keep all grounds common. [#20626343]

What autoexec.bat configuration maps TH01 TuyaMCU dpIDs for temperature, humidity, and battery state in OpenBeken?

Use TuyaMCU, tmSensor, and link each dpID to an OpenBeken channel. For the common TH01 mapping, dpID 1 is temperature divided by 10, dpID 2 is humidity, and dpID 3 is battery state. TuyaMCU is a serial-device driver that exchanges Tuya datapoints with a separate MCU, using UART frames instead of direct GPIO sensor reads. For newer variants, dpID 27 can be temperature, dpID 46 humidity, and dpID 101 battery. Map dpID 101 to a channel below 64, such as channel 10. [#21442987]

Why does a battery-powered TH01 sensor show 0 temperature and 0 humidity when the WiFi module is powered externally?

It shows 0 because the MCU may not perform a real measurement cycle during external WiFi-only power. The TH01 MCU normally wakes the WiFi module, sends sensor frames, waits for reporting, then removes power. External 3.3 V keeps CB3S awake outside that sequence. Configure OpenBeken while externally powered. Then disconnect external power and run on batteries. The MCU should wake the module for about 30 seconds during reporting windows and send the actual values. [#20642216]

How can I find the correct TuyaMCU dpIDs for a TH01 sensor using TuyaMCUAnalyzer or a Tuya firmware dump?

Capture the original UART traffic or inspect a Tuya firmware/config dump. TuyaMCUAnalyzer can decode dpIDs from the factory protocol frames. Users identified common sets such as 1/2/3 and newer sets such as 27/46/101. A factory dump can also reveal datapoints when analyzer tools work. If tools crash, compare logs from original firmware and OpenBeken. LocalTuya Device Datapoints also helped after connecting the device to Tuya Cloud. [#21745509]

What is TuyaMCU and how does it control the WiFi module in battery-powered Tuya temperature sensors?

TuyaMCU is the separate low-power controller that manages measurements and WiFi power. TuyaMCU is a board-level microcontroller system that talks to the WiFi module over UART, controls wake/report/sleep timing, and saves battery by switching the module off. In TH01-style sensors, the SOIC MCU controls a transistor or power path. It powers CB3S only when it wants to report temperature, humidity, or battery data. [#21402357]

What is tmSensor in OpenBeken and why is it needed for TuyaMCU battery temperature sensors?

tmSensor enables OpenBeken’s battery TuyaMCU sensor workflow. tmSensor is an OpenBeken driver mode that coordinates TuyaMCU battery sensor reporting, expecting short wake windows and mapped datapoints instead of continuous sensor polling. Start it with startDriver tmSensor after startDriver TuyaMCU. Without it, the device may not follow the expected temperature-sensor reporting sequence or may wait in the wrong state. [#20642216]

Why might BK7231 GUI Flash Tool fail with “Getting bus failed” or UART buffer errors when flashing a TH01 sensor?

The flasher can fail when the MCU still drives the same UART lines. The thread shows “Getting bus failed” cases fixed by cutting RX/TX traces at the MCU. Other failures came from unstable 3.3 V power, grounding mistakes, baud-rate sensitivity, or GUI-tool environment issues. One user reached 100% after changing the USB-serial ground connection. Another was advised to try hid_download_py, which also works on Windows. [#20627443]

When do I need to cut RX/TX traces, desolder the CB3S module, or disconnect the MCU before flashing a Tuya TH01?

Do it when the MCU interferes with UART flashing. TuyaMCU devices often share TX1/RX1 between the WiFi module and the MCU. If flashing fails repeatedly, isolate that link. Valid options are cutting traces and restoring them, desoldering the BK7231 module, or temporarily desoldering the SOIC MCU. Some TH01 boards flash without this step, but the thread documents several boards that required RX/TX cuts. [#20626343]

How do I configure MQTT and Home Assistant discovery for an OpenBeken TH01 sensor?

Set MQTT host, credentials, base topic, and enable Home Assistant discovery after mapping channels. A manual Home Assistant YAML example used obk1F70E60F/1/get for temperature and obk1F70E60F/2/get for humidity. If the entity does not appear under MQTT devices, search Home Assistant entities directly. One user found the sensors existed even though they were not visible where expected. Redo discovery after changing channel types. [#20845795]

Why does enabling Flag 33 or using a Home Assistant value_template make TH01 temperature values appear divided twice?

It happens because both OpenBeken and Home Assistant apply the same divide-by-10 conversion. temperature_div10 or Flag 33 can publish 213 as 21.3 °C. A Home Assistant template multiplying by 0.1 again turns 21.3 into 2.13. Use one conversion path only. Remove the Home Assistant value_template if OpenBeken already publishes the scaled temperature. [#20517650]

How can I get TuyaMCU debug logs in the OpenBeken Web App for a TH01 sensor?

Enable full TuyaMCU logging before starting the driver. Put logfeature 12 1 and loglevel 6 before startDriver TuyaMCU in autoexec.bat. Then open the Web App logs while the MCU powers the module. If no TuyaMCU frames appear, check baud rate, UART port selection, flag 26, and whether the board actually has a TuyaMCU. Some variants required 115200 baud. [#21552004]

What is the difference between CB3S, CBU, BK7231N, and BK7231T modules in Tuya temperature and humidity sensors?

CB3S and CBU are Tuya WiFi module boards; BK7231N and BK7231T are Beken chip families used on such modules. The thread’s TH01 units mainly used BK7231N CB3S or CBU. Firmware choice must match the chip. Users flashed BK7231N binaries for CB3S/CBU units discussed here. Some sensors used CHT8310, CHT8315, AHT20, or AHT30, changing the driver or dpID approach. [#20873676]

WiFi vs Zigbee vs BLE temperature sensors: which is better for Home Assistant battery life and reliability?

Zigbee or BLE is usually better for battery sensors; WiFi works but needs careful tuning. One user preferred Zigbee after seeing poor battery life with frequent WiFi updates. Later posts suggested BLE THB2 with BTHome and an ESP32 Bluetooth proxy. WiFi TH01 sensors remain useful where only WiFi coverage exists. Expect more flashing effort and shorter battery life than Zigbee or BLE alternatives. [#20588120]

How can I improve battery life on OpenBeken TuyaMCU temperature sensors using quick connect, static IP, MQTT settings, and battery ACK delay?

Improve battery life by reducing connection time and MQTT traffic during each wake. Enable WiFi quick connect, use static IP, and reduce boot-ok time from 5 s to 3 s or even 1 s after testing. Set mqtt_broadcastItemsPerSec 9 to push data faster. Disable diagnostic broadcasts by unsetting flags 2 and 10. Newer builds also support tuyaMcu_setBatteryAckDelay to delay the ACK sent back to the MCU. [#21651099]

How can I publish OpenBeken TH01 MQTT data to ThingSpeak with custom topics like channels/myid/publish and selected fields?

The thread asks for ThingSpeak publishing, but gives no confirmed working OpenBeken command recipe. The requested payload was channels/myid/publish with fields like field1=$CH1&field2=$CH3. OpenBeken normally publishes channel topics such as base/1/get. For ThingSpeak, use a broker bridge, automation, or script that repackages OBK MQTT messages into ThingSpeak’s required topic and field format. The thread also asked whether connected broadcasts can be disabled. [#21339167]
AI summary based on the discussion. May contain errors.
ADVERTISEMENT