logo elektroda
logo elektroda
X
logo elektroda

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

anthonythomas 56100 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
  • Custom MQTT topic and ThingSpeak field mapping needed

    #91 21339167
    Magnetz
    Level 4  
    Posts: 3
    I have flashed TH01 but want to publish MQTT data to thingspeak.com

    I need to set client ID which I believe is taken from the "Client Topic (Base Topic):" field.

    I also need to set topic as "channels/myid/publish" with "field1=$CH1&field2=$CH3"

    how can I customise the MQTT topic and fields?

    can I disable the 'connected' mqtt message broadcast?

    https://uk.mathworks.com/help/thingspeak/use-desktop-mqtt-client-to-publish-to-a-channel.html

    edit: after leaving the device un-powered for 10 minutes it has forgotten my configuration and reverted to wifi AP mode. is that a bug?
  • ADVERTISEMENT
  • #92 21385175
    Magnetz
    Level 4  
    Posts: 3
    >>21162096
    255 seconds is the max interval?

    Mine seems to send a temperature value every @150 seconds if I set 'AHT2X_Cycle 255'
  • Suggesting UART sniffing to find TuyaMCU data points

    #93 21387341
    sns1
    Level 5  
    Posts: 12
    Hi,

    Can I ask, probably, noob questions even though I've read this thread?
    I have a similar tuya wifi sensor, but it has a different pcb. It has BK7321N for sure and I've flashed it with OpenBekken, configured according to config found here (channel 1, channel 2) and it does connect to wifi/HA/mqtt but posts no data. Web App Log does not show any TuyaMCU lines whatsoever... I have to note, that this particular device has never been paired or used - flashed straight out of the box - not sure if it matters...
    Where should I look for a solution? I have another one unopened for testing, but not sure where to proceed. Pair it, hook up to rx/tx and look for possible communications? I doubt that similar device would use dpI, for example, number 7 or 12 instead of 1 and 2... But there might be some error in my config/actions as I do not fully understand all the scheme of how it works...
  • #94 21387351
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12866
    Please post photos of your device. Maybe you have a version without TuyaMCU? Or maybe you have wrong baud setting?
    Helpful post? Buy me a coffee.
  • #95 21387365
    sns1
    Level 5  
    Posts: 12
    >>21387351
    Circuit board with electronic components on a wooden surface.
    Hem... I thought BK*** is a TuyaMCU....
  • Non-TuyaMCU sensor needs PinDeepSleep or DeepSleep

    #96 21387372
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12866
    This seems like a device without TuyaMCU. So TuyaMCU driver and tmSensor are not needed. TuyaMCU approach thus will not work. Luckily, we also have covered non-TuyaMCU sensors on our forum, you need need to find a related thread. You will most likely have to use PinDeepSleep or DeepSleep command in autoexec.bat.
    Maybe this thread may fit your device better: https://www.elektroda.com/rtvforum/topic3945688.html
    Helpful post? Buy me a coffee.
  • #97 21387405
    insmod
    Level 31  
    Posts: 1432
    Help: 168
    Rate: 455
    >>21385175 This is a TuyaMCU device, AHT20 is not connected to CBU, so driver is not needed for it and therefore will not work.
  • Different sensor pins and wrong temperature readings

    #98 21387895
    sns1
    Level 5  
    Posts: 12
    >>21387372
    >>21387372

    Thank you for the suggestions.

    It turns out that it is a BK7231N with CHT8315 sensor version. I've found threads with like variants (BLE version though).
    Now trying to make it work and got as far as wrong temp/hum returns. Will try to check traces for i2c and understand if current cht83xx driver should work with i2c or not or what possible variant will.

    Added after 1 [hours] 54 [minutes]:

    Found that mine board has different pins connected to a sensor, which are 23 and 24 (sda & scl(sck)) and getting wrong, but different measurements (-40 and 0 for temp/hum).
    Can't yet understand pin<->channel(s) relations, yet those a bit differently configured in native web and app web interfaces...
  • ADVERTISEMENT
  • Flashing CB3S requires disconnecting TuyaMCU TX/RX

    #99 21398650
    vinibali
    Level 8  
    Posts: 19
    Rate: 1
    Hi there!
    I also have a somewhat newer version of this board with a shield less CB3S, TuyaMCU and CHT8310. I need to somehow remove the TuyaMCU's connection for now, so this board is not recommended to buy!
    Let me share my experiences
    * flashing was unsuccessful if the MCU TX and RX pins were connected (removing only one connection was enough)
    * had to set the flashing speed to 460800 otherwise it failed around 75% of the process with hid_download's uartprogram on Linux
    * pulling up CEN is needed otherwise the chip resets itself around every 10-11 seconds I powered up only the CB3S board this time!
    ** disconnect TuyaMCU's pin 3 also solved the problem
    * wakeup from deep sleep doesn't work

    Close-up of a circuit board with a blue module and wiring on graph paper background.
  • #100 21399061
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12866
    If you are using deep sleep directly on Beken, and one of the wakeup directions is not working, then you need to configure DSEdge.
    https://www.elektroda.com/rtvforum/find.php?q=DSEdge

    I guess you had to pull up CEN because MCU pulls it down?
    Helpful post? Buy me a coffee.
  • #101 21399107
    vinibali
    Level 8  
    Posts: 19
    Rate: 1
    >>21399061 Yes, that was the first try. Later I just disconnected the MCU's pin #3. So now it's floating, shall I pull up or pull down with a resistor?
  • #102 21399112
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12866
    CEN can be left floating. I've never ever pulled it up and so far I had like hundreds of devices.
    Helpful post? Buy me a coffee.
  • Intermittent Wi-Fi after BK7231N flashing

    #103 21401774
    BobUrban
    Level 2  
    Posts: 2
    I was able to flash my device successfully with the MCU TX and RX connected.
    When it's powered now, it doesn't properly connect to Wifi, sometimes when I press the button it connects, but the openbk UI only is available for a few seconds.
    Is there anything I could try?

    Is there any recommended similar device to buy instead of this one?

    This is my device:
    PCB with CB3S module and various electronic components.

    This is the connections I used for flashing
    CB3S module with TXD1, RXD1, GND, and 3.3V pins connected.
  • TuyaMCU power control causes Wi-Fi dropouts

    #104 21402357
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12866
    BobUrban wrote:

    When it's powered now, it doesn't properly connect to Wifi, sometimes when I press the button it connects, but the openbk UI only is available for a few seconds.
    Is there anything I could try?

    This is TuyaMCU battery powered device. The SOIC chip on board controls the power connection of WiFi module and it turns on and off the module. That's why it goes offline.
    You can either:
    - configure it properly with tmSensor driver and required dpIDs, maybe autoexec.bat from post 6 in this thread can work, or you can check somewhere else on forum https://www.elektroda.com/rtvforum/find.php?q=tmSensor
    You will need to connect external 3.3V to WiFi module VDD for that...
    - remove the MCU and configure this device manually with CHT driver (if present - which sensor is there?) and use manual deep sleep on OBK directly https://www.elektroda.com/rtvforum/find.php?q=deepsleep
    In any case, don't give up and ask if you have any questions. Battery powered devices are very tricky to work with.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • Tuya MCU conf command still unhandled

    #105 21420822
    maxim2002
    Level 13  
    Posts: 46
    Help: 4
    Rate: 12
    They are getting more and more annoying with these temperature sensors.
    I've now been hit with one identical to the one BobUrban has.
    Circuit board with desoldered MCU module and connected wires. .
    Flash uploaded after soldering out the Tuya MCU with no problems.
    Config basic:
    Code: Text
    Log in, to see the code
    .
    In the logs only:
    Code: Text
    Log in, to see the code
    .

    Is there anything I can do to help? I don't have much experience with Tuya protocols, but soldering and connecting the UART I know how to ;)
  • TuyaMCU autoexec for temperature, humidity, and battery mapping

    #106 21441634
    doudouni100
    Level 4  
    Posts: 7
    >>21420822
    I have the same one.
    I got mine working with this autoexec :

    startDriver TuyaMCU
    startDriver tmSensor
    // dpID 27 is temperature div 10
    setChannelType 27 temperature_div10
    linkTuyaMCUOutputToChannel 27 val 27
    // dpID 46 is % humidity
    setChannelType 46 Humidity
    linkTuyaMCUOutputToChannel 46 val 46
    // dpID 101 is battery state - low(0), mid(1) and high(2)
    setChannelType 101 ReadOnly
    linkTuyaMCUOutputToChannel 101 enum 101
    setChannelLabel 101 Battery

    Only the battery level is not working but the dpID is correct.
    I got it using the TuyaMCUAnalyzer as I did the rest.

    Any ideas for the battery level?
  • #107 21441680
    divadiow
    Level 38  
    Posts: 5201
    Help: 446
    Rate: 914
    doudouni100 wrote:
    Any ideas for the battery level?

    try setChannelType 101 LowMidHigh instead of setChannelType 101 ReadOnly
  • #108 21441842
    doudouni100
    Level 4  
    Posts: 7
    >>21441680
    Thanks for the reply
    Tried it but nothing.
    Did a lot of testing and have come to the conclusion that there is a limit on OBK firmware of 64 channels.

    If I use any channel number under 64 it shows up on the page, but value=0
    Any number over 64 does not show at all.

    The authors have to enable more channels on the OBK firmware !
  • Battery mode still yields no sensor data

    #109 21442664
    angzero
    Level 4  
    Posts: 13
    so it seems that i'm in the same boat as many people here where each iteration of this device yields different behavior and needs a slightly different approach, so here is mine:
    also, @p.kaczmarek2 i can only imagine the headache you must have from this alone as i went through the whole thread reading the back and forth (hopefully i didn't miss anything)

    so this is my Tuya Temperature and humidity sensor with a CB3S, which i managed to flash the latest 1.18.42 without disordering or cutting off any traces

    Close-up of a Tuya temperature and humidity sensor circuit board with highlighted components.
    Circuit board of a Tuya temperature and humidity sensor with CB3S module.

    - MQTT connected, configured and showing in HA but values are 0 since its powered externally
    - when powering through the battery, no data or ability to see the device neither directly or on HA:
    as one of the posts mentioned, i activated Flag 37 and lowered the uptime from 5 to 3 seconds + static IP but no changes to this behavior

    here's my autoexe.bat:

    startDriver TuyaMCU
    startDriver tmSensor
    tuyaMCU_setBaudRate 115200
    //tuyaMcu_defWiFiState 4 (notsureifneeded)
    // dpID 27 is temperature div 10
    setChannelType 27 temperature_div10
    linkTuyaMCUOutputToChannel 27 val 27
    // dpID 46 is % humidity
    setChannelType 46 Humidity
    linkTuyaMCUOutputToChannel 46 val 46
    // dpID 3 is battery state - low(0), mid(1) and high(2)
    setChannelType 3 ReadOnlyLowMidHigh
    linkTuyaMCUOutputToChannel 3 enum 3
    setChannelLabel 3 Battery
    //tuyaMcu_sendProductInformation


    This is the first time I flash a device like this, usually i manage to get some configs from the original firmware during backup but not here, the configure module page in the web app has nothing configured and left as is

    My main issue right now is that i can't get anything out of the device when running on battery, not sure i'm missing anything or if i skipped a step i need, like cutting off the Tx and Rx from the TuyaMCU

    This is the main page when connected EXTERNALLY


    Screenshot of Tuya temperature and humidity sensor configuration


    hopefully that paints a full picture of the situation, if not, feel free to ask me anything and i'll do my best to respond and provide all the details i can. thanks everyone
  • #110 21442671
    divadiow
    Level 38  
    Posts: 5201
    Help: 446
    Rate: 914
    >>21441842

    @angzero's post may have answer

    setChannelType 101 ReadOnlyLowMidHigh
  • #111 21442677
    angzero
    Level 4  
    Posts: 13
    >>21442671

    note that this SHOULD work from what i read, but he still needs to lower the channel to 64 and under (to my understanding)
  • Temporary -Bat to GND jumper fixes Wi-Fi startup

    #112 21442987
    doudouni100
    Level 4  
    Posts: 7
    >>21442671

    Hi

    p.kaczmarek2 pointed out to me in another thread that I do not have to use channel 101 in the autoexec.
    I could link it, in the autoexec, to a channel number in the range OBK accepts (1-64).

    So for anyone that has the same
    Electronic module with a blue component on a circuit board with wires. sensor this is the autoexec:

    startDriver TuyaMCU
    startDriver tmSensor
    // dpID 27 is temperature div 10
    setChannelType 27 temperature_div10
    linkTuyaMCUOutputToChannel 27 val 27
    // dpID 46 is % humidity
    setChannelType 46 Humidity
    linkTuyaMCUOutputToChannel 46 val 46
    // dpID 101 is battery state - low(0), mid(1) and high(2)
    setChannelType 10 ReadOnly
    linkTuyaMCUOutputToChannel 101 enum 10
    setChannelLabel 10 Battery


    Added after 1 [hours] 2 [minutes]:

    BobUrban wrote:
    I was able to flash my device successfully with the MCU TX and RX connected.
    When it's powered now, it doesn't properly connect to Wifi, sometimes when I press the button it connects, but the openbk UI only is available for a few seconds.
    Is there anything I could try?

    Is there any recommended similar device to buy instead of this one?

    This is my device:
    PCB with CB3S module and various electronic components.

    This is the connections I used for flashing
    CB3S module with TXD1, RXD1, GND, and 3.3V pins connected.





    Hi
    Put a temporary jumper wire from -Bat of the sensor board to GND on the Wi-Fi module and use this autoexec:

    startDriver TuyaMCU
    startDriver tmSensor
    // dpID 27 is temperature div 10
    setChannelType 27 temperature_div10
    linkTuyaMCUOutputToChannel 27 val 27
    // dpID 46 is % humidity
    setChannelType 46 Humidity
    linkTuyaMCUOutputToChannel 46 val 46
    // dpID 101 is battery state - low(0), mid(1) and high(2)
    setChannelType 10 ReadOnly
    linkTuyaMCUOutputToChannel 101 enum 10
    setChannelLabel 10 Battery
  • #113 21450156
    angzero
    Level 4  
    Posts: 13
    Anyone have any ideas on how to help with this please? -> >>21442664
  • #114 21450164
    DeDaMrAz
    Level 23  
    Posts: 620
    Help: 34
    Rate: 130
    @angzero

    Just out of the blue as I was not reading anything else.

    Have you tried with tuyaMCU_setBaudRate 9600
  • Baud rate lowered, but sensor readings still missing

    #115 21450238
    angzero
    Level 4  
    Posts: 13
    >>21450164 Lowering the BaudeRate seemed to have helped with getting slightly more time with the wifi module being on and seeing the menu, but not sensor readings is being reported so far, neither in the webpage or in HA, interestingly i saw this message pop out newly:
    "Cfg size: 3584, change counter: 11, ota counter: 0, incomplete boots: 1 (might change to 0 if you wait to 30 sec)!"

    User interface with diagnostic information and configuration buttons.

    i'll try to see if i can get any log readings:

    Info:CFG:####### Boot Count 40 #######
    Warn:CFG:CFG_InitAndLoad: Correct config has been loaded with 11 changes count.
    Error:CMD:no file early.bat err -2
    Info:GEN:PIN_SetupPins pins have been set up.
    Info:MAIN:Main_Init_Before_Delay done
    Info:MAIN:Main_Init_Delay
    Info:MAIN:Main_Init_Delay done
    Info:MAIN:Main_Init_After_Delay
    Info:MAIN:Registered for wifi changes
    Info:MQTT:MQTT_RegisterCallback called for bT obk2DE0035D/ subT obk2DE0035D/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT bekens_n/ subT bekens_n/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/obk2DE0035D/ subT cmnd/obk2DE0035D/+
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/bekens_n/ subT cmnd/bekens_n/+
    Info:MQTT:MQTT_RegisterCallback called for bT obk2DE0035D/ subT obk2DE0035D/+/get
    Info:CMD:CMD_StartScript: started @startup at the beginning
    Info:CMD:CMD_StartScript: started autoexec.bat at the beginning
    Info:MAIN:Main_Init_After_Delay done
    Info:MAIN:Started TuyaMCU.
    Info:MAIN:Started tmSensor.
    Info:GEN:Channel 27 type changed to temperature_div10
    Info:GEN:Channel 46 type changed to Humidity
    Info:GEN:Channel 3 type changed to ReadOnlyLowMidHigh
    Info:MAIN:Time 1, idle 266405/s, free 73480, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 2, idle 195363/s, free 72984, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 3, idle 75067/s, free 73312, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 4, idle 0/s, free 73312, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Boot complete time reached (3 seconds)
    Info:CFG:####### Set Boot Complete #######
    Info:MAIN:Time 5, idle 0/s, free 73312, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTING - 1
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED - 4
    Info:MQTT:mqtt_userName DriveT1
    Info:MAIN:Time 6, idle 102081/s, free 73136, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:mqtt_connection_cb: Successfully connected
    Info:MQTT:mqtt_subscribed to obk2DE0035D/+/set
    Info:MQTT:mqtt_subscribed to bekens_n/+/set
    Info:MQTT:mqtt_subscribed to cmnd/obk2DE0035D/+
    Info:MQTT:mqtt_subscribed to cmnd/bekens_n/+
    Info:MQTT:mqtt_subscribed to obk2DE0035D/+/get
    Info:MQTT:Publishing val TemhumbB1 to obk2DE0035D/host retain=0
    Info:MAIN:Time 7, idle 184012/s, free 73384, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val OpenBK7231N 1.18.42 Feb 15 2025 19:44:25 to obk2DE0035D/build retain=0
    Info:MAIN:Time 8, idle 200118/s, free 73112, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val f8:17:2d:e0:03:5d to obk2DE0035D/mac retain=0
    Info:MAIN:Time 9, idle 187807/s, free 64536, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 3/38 
    Info:MQTT:Publishing val 28.52 to obk2DE0035D/temp retain=0
    Info:MAIN:Time 10, idle 194920/s, free 73384, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:GEN:dhcp=0 ip=192.168.2.42 gate=192.168.2.1 mask=255.255.255.0 mac=f8:17:2d:e0:03:5d
    Info:GEN:sta: 1, softap: 0, b/g/n
    Info:MAIN:Time 11, idle 187175/s, free 73144, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val 2 to obk2DE0035D/sockets retain=0
    Info:MAIN:Time 12, idle 185905/s, free 73384, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val -81 to obk2DE0035D/rssi retain=0
    Info:MAIN:Time 13, idle 191601/s, free 73384, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val 13 to obk2DE0035D/uptime retain=0
    Info:MAIN:Time 14, idle 189461/s, free 73152, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val 73384 to obk2DE0035D/freeheap retain=0
    Info:MAIN:Time 15, idle 194553/s, free 73144, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val 192.168.2.42 to obk2DE0035D/ip retain=0
    Info:MAIN:Time 16, idle 190704/s, free 73384, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Channel has changed! Publishing 0 to channel 3 
    Info:MQTT:Publishing val 0 to obk2DE0035D/3/get retain=0
    Info:MAIN:Time 17, idle 188579/s, free 73152, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic obk2DE0035D/3/get
    Info:MQTT:Channel has changed! Publishing 0 to channel 27 
    Info:MQTT:Publishing val 0 to obk2DE0035D/27/get retain=0
    Info:MAIN:Time 18, idle 185000/s, free 73384, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic obk2DE0035D/27/get
  • Temporary -Bat to GND jumper enables readings

    #116 21462840
    BobUrban
    Level 2  
    Posts: 2
    doudouni100 wrote:
    Hi
    Put a temporary jumper wire from -Bat of the sensor board to GND on the Wi-Fi module and use this autoexec:


    Hi @doudouni100

    Thanks for your input, this worked for me after trying around many times, I am seeing values finally.

    p.kaczmarek2 wrote:
    The SOIC chip on board controls the power connection of WiFi module and it turns on and off the module.


    Is there a way to configure how often this happens?
    Did someone manage to put the PCB back in to the case?
  • TuyaMCU query state and datapoint parsing logs

    #117 21551925
    BAGZZlash
    Level 4  
    Posts: 7
    anthonythomas wrote:
    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


    I have a somewhat embarassing noob question: How do I get to see those TuyaMCU:TUYAMCU logs? In my WebApp, I get logs that mostly look like this:

    Info:CMD:CMD_StartScript: started @startup at the beginning
    Info:CMD:CMD_StartScript: started autoexec.bat at the beginning
    Info:MAIN:Main_Init_After_Delay done
    Info:MAIN:Started TuyaMCU.
    Info:MAIN:Started tmSensor.
    Info:MAIN:Time 1, idle 218322/s, free 78984, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 2, idle 187723/s, free 78984, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 3, idle 189324/s, free 78984, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 4, idle 379946/s, free 78984, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Boot complete time reached (3 seconds)
    Info:CFG:####### Set Boot Complete #######
    Info:MAIN:Time 5, idle 184663/s, free 78984, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Registered for wifi changes
    Info:MAIN:Connecting to SSID [ZZ-Base]
    Info:MAIN:Time 6, idle 181163/s, free 73704, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 7, idle 187953/s, free 73704, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 8, idle 85103/s, free 74000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 9, idle 0/s, free 74000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 10, idle 0/s, free 74000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:GEN:dhcp=0 ip=0.0.0.0 gate=0.0.0.0 mask=0.0.0.0 mac=f8:17:2d:e0:0d:c6
    Info:GEN:sta: 0, softap: 0, b/g/n
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTING - 1
    Info:MAIN:Time 11, idle 92345/s, free 74240, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 12, idle 188451/s, free 74280, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED - 4
    Info:MAIN:Time 13, idle 187314/s, free 74192, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 14, idle 191996/s, free 65584, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 3/38 
    Info:MQTT:mqtt_host empty, not starting mqtt
    Info:MAIN:Time 15, idle 190977/s, free 74192, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 16, idle 190731/s, free 74192, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 17, idle 186581/s, free 74192, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 18, idle 189550/s, free 74192, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 19, idle 389067/s, free 74192, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 20, idle 189947/s, free 74192, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:GEN:dhcp=0 ip=192.168.1.178 gate=192.168.1.1 mask=255.255.255.0 mac=f8:17:2d:e0:0d:c6
    Info:GEN:sta: 1, softap: 0, b/g/n
    Info:GEN:sta:rssi=-64,ssid=ZZ-Base,bssid=1c:b0:44:b9:2c:65,channel=6,cipher_type:CCMP
    Info:MAIN:Time 21, idle 185142/s, free 74192, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 22, idle 191040/s, free 74192, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38


    which doesn't help me a lot. Do I need to activate anything to see those Tuya-Logs?
  • ADVERTISEMENT
  • #118 21551929
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12866
    Well, first of all, did you start TuyaMCU driver?

    edit: I can see you did, if so, then please enable log level all on the web app
    Helpful post? Buy me a coffee.
  • #119 21551999
    BAGZZlash
    Level 4  
    Posts: 7
    Thanks for the quick reply, I really appreciate the help.

    p.kaczmarek2 wrote:
    please enable log level all on the web app


    Already did, also I checked all checkboxes (I clicked the convenient "Select All Features" button). If it matters, so far, my autoexec.bat looks as simple as this:

    startDriver TuyaMCU
    startDriver tmSensor
  • #120 21552004
    insmod
    Level 31  
    Posts: 1432
    Help: 168
    Rate: 455
    Add commands 'logfeature 12 1' and 'loglevel 6' to autoexec before starting tuyamcu driver.

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