logo elektroda
logo elektroda
X
logo elektroda

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

anthonythomas 56106 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
  • RX/TX cut enables flashing, but sensor data stays zero

    #61 20921442
    Wen2024
    Level 7  
    Posts: 19
    Rate: 1

    >>20910745
    p.kaczmarek2 you are right. After cutting of the RX and TX traces at the Tuya MCU, I was able to flash with the Windows flasher.Close-up of a PCB with a yellow marking around an integrated circuit.
    Now I have the same problem as grericht and maxen0815 Post #31 to #39. We don't get any useful data on any channel... all are set to 0!!!
    I think that our TH01 sensor is nearly similar to DeDaMrAz but it is different. The PCB is different: we don't have the hole in the middle and the Tuya MCU is 90 degrees offset.

    My only two logs are:
    "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!"

    He has a lot of logs:
    "Info:TuyaMCU:TUYAMCU received: 55 AA 00 01 00 24 7B 22 70 22 3A 22 62 79 75 73 76 75 6D 65 6D 65 35 69 69 63 61 64 22 2C 22 76 22 3A 22 31 2E 30 2E 30 22 7D 20
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 1 (QueryProductInformation) with 43 bytes
    Info:TuyaMCU:TuyaMCU_ParseQueryProductInformation: received {"p":"byusvumeme5iicad","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 10 00 01 00 10
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 16 (Unknown) with 8 bytes
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: unhandled type 16

    Info:TuyaMCU:TUYAMCU received: 55 AA 00 05 00 08 01 02 00 04 00 00 00 E3 F6
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 5 (WiFiSelect) with 15 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: 227
    Info:GEN:CHANNEL_Set channel 1 has changed to 227 (flags 0)
    Info:MQTT:Channel has changed! Publishing 227 to channel 1
    Info:MQTT:Publishing val 227 to temp_test/1/get retain=0

    Info:TuyaMCU:TUYAMCU received: 55 AA 00 05 00 08 02 02 00 04 00 00 00 29 3D
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic temp_test/1/get
    Info:TuyaMCU:TuyaMCU_ProcessIncoming[ver=0]: processing command 5 (WiFiSelect) with 15 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: 41
    Info:GEN:CHANNEL_Set channel 2 has changed to 41 (flags 0)
    Info:MQTT:Channel has changed! Publishing 41 to channel 2
    Info:MQTT:Publishing val 41 to temp_test/2/get retain=0
    and more ..."
    Any idea? (I think we had to adapt the driver...)
  • ADVERTISEMENT
  • #62 20922691
    Wen2024
    Level 7  
    Posts: 19
    Rate: 1

    Screenshot of Tuya TH01 communication analysis using TuyaMCUAnalyzer.
    Today I captured original Tuya TH01 communication with TuyaMCUAnalyzer. See pic and attached txt file. Very good tool!!!!
    Attachments:
    • TuyaOrgCommunication.txt (8.22 KB) You must be logged in to download this attachment.
  • Missing Home Assistant configuration in TH01 setup

    #63 20923103
    gabybriet
    Level 3  
    Posts: 4

    Screenshot of Home Assistant configuration with a message about MQTT discovery being queued. Screenshot of MQTT configuration in Home Assistant showing no devices or entities connected to core-mosquitto. Screenshot of the configuration interface for Test Sonde T&H3 sensor with temperature, humidity data, and MQTT status.

    Hello, I have a problem connecting to Home Assistant.
    MQTT is connected but there is nothing on HA.
    In "Home Assistant configuration" there is nothing written, is this normal?
    Thank you for your help, I couldn't find anything even if I started from the beginning.
  • #64 20923263
    Wen2024
    Level 7  
    Posts: 19
    Rate: 1

    Hello gabybriet, do you have the same TH01 PCB and can you get temperature, humidity, and battery data? Can you provide a photo of the PCB?
    Mine doesn't work.
    Thank you, Wen2024
  • External power and MQTT required for discovery

    #65 20923288
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12866
    @Wen2024 , just to be clear, do you test it by letting it to power itself up on its own? You should not power the WiFi module externally!

    i am asking because I saw that kind of behaviour in the past when I was tampering with the sensor on my own.

    Second question: Do you have MQTT configured? This will wait for your MQTT to connect, so... so you need to have MQTT.

    @gabybriet the YAML code field can be empty, it will still work if you press the Discovery button
    Helpful post? Buy me a coffee.
  • OpenBeken TH01 communication captured with TuyaMCUAnalyzer

    #67 20923325
    Wen2024
    Level 7  
    Posts: 19
    Rate: 1

    Hello p.kaczmarek2,
    I supply the modules during the tests via the original battery + and - pins.
    I have not configured MQTT because I want to send the data to my server. This works very well with simulated values...

    Screenshot showing communication between the WiFi module and OpenBeken TH01.
    This is captured OpenBeken TH01 communication with TuyaMCUAnalyzer. Flashed with Version: 1.17.408. No MQTT
    This autoexec.bat:
    startDriver tuyaMCU
    startDriver tmSensor
    linkTuyaMCUOutputToChannel 1 val 1
    setChannelType 1 temperature_div10
    linkTuyaMCUOutputToChannel 2 val 2
    setChannelType 2 Humidity
    linkTuyaMCUOutputToChannel 3 val 3
    setChannelType 3 ReadOnly

    Added after 4 [minutes]:

    Thank you for photos gabybriet. This is the same PCB as mine.
  • #68 20923343
    gabybriet
    Level 3  
    Posts: 4

    Broker options window with fields for MQTT configuration. MQTT connection configuration form with fields to fill in. @p.kaczmarek2 I press the Discovery button, a window opens but nothing happens on HA.
    Maybe a bad configuration?
    I am a beginner.
  • MQTT not required for Tuya app operation

    #69 20923402
    Wen2024
    Level 7  
    Posts: 19
    Rate: 1

    Hello p.kaczmarek2,
    This is problem?: "Info:MQTT:mqtt_host empty, not starting mqtt"

    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED - 4
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED - 4
    Info:MQTT:mqtt_host empty, not starting mqtt
    Info:MAIN:Time 19, idle 174794/s, free 73920, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38
    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:MAIN:Time 20, idle 187903/s, free 73960, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:GEN:dhcp=0 ip=192.168.178.44 gate=192.168.178.1 mask=255.255.255.0 mac=1c:90:ff:65:35:24
    Info:GEN:sta: 1, softap: 0, b/g/n
    Info:GEN:sta:rssi=-48,ssid=MW_Home,bssid=c8:0e:14:b0:a7:33,channel=1,cipher_type:CCMP
    Info:MAIN:Time 21, idle 183697/s, free 73960, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:MAIN:Time 22, idle 187522/s, free 73960, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38

    Is there a solution without MQTT?
    With the original Tuya smart app, you don't need MQTT either. Is it not possible to generate the sequence in the same way as with the Tuya sequence?
    Best regards,
    Wen2024
  • ADVERTISEMENT
  • MQTT broker required for TuyaMCU driver

    #70 20928454
    Wen2024
    Level 7  
    Posts: 19
    Rate: 1

    Hello, I have installed a local Mosquitto MQTT broker on a Windows machine and it runs. I am able to send data to my HTTPS server:

    Temperature monitoring graph showing temperature, humidity, and battery status with labels and time data.
    For testing, this is OK, but I need this functionality without the additional MQTT broker. If the TuyaMCU driver is started, communication always takes place with the MQTT broker. That can't be switched off, can it? Any help is welcome. Thank you!

    Added after 17 [minutes]:

    Hello divadiow (post 51),
    I have flashed such a module and it behaves analogously to the other modules in this article:

    Close-up of an electronic module with several wires attached to a PCB on a white background.
    Best regards, Wen2024
  • Boards connect briefly but report 0 values in Home Assistant

    #71 20930089
    nacxoffw
    Level 5  
    Posts: 13
    Rate: 1

    Hi, I have a similar board but without shared RX/TX pinouts and with easy solder points. After all the process (flash, config wifi, names, autoexe, and MQTT), it's alive in Home Assistant but shows 0 values!!

    Can you help me? Electronic module with components and connector Computer screen displaying OpenBK7231N and Home Assistant software, showing temperature and humidity settings.

    Added after 1 [hour]:

    Another question :)

    Besides, I have two of these boards.
    Both lose the connection on every try after a few seconds. I do the CEN short very quickly. One time, the read process finished but the checks fail. Any tip?

    Thanks!
    Close-up of a green circuit board with connected wires. Computer screen showing Reading failed message in the BK7231 flashing program.
  • OpenBeken TuyaMCU waits for MQTT connection

    #72 20930271
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12866
    Wen2024 wrote:

    Is there a solution without MQTT?
    With the original Tuya smart app, you don't need MQTT either. Is it not possible to generate the sequence in the same way as with the Tuya sequence?

    Well, you don't need MQTT for Tuya smart app, but you need a cloud connection. So, OpenBeken, instead of connecting to cloud, waits for your MQTT to connect:
    Screenshot of Visual Studio editor displaying source code of the OpenBeken application.
    We even have an enumerator for that - this specific state is called TM0_STATE_AWAITING_MQTT, that's where your device hangs.
    This is required by TuyaMCU because we need to know when we are ready to report data to MQTT.

    In order to work without MQTT, we would need to slightly alter our TuyaMCU driver. It's possible, but it's debatable how should we do it. Maybe some kind of flag or a time out...
    Helpful post? Buy me a coffee.
  • Suggesting a no-MQTT flag for battery sensors

    #73 20931207
    Wen2024
    Level 7  
    Posts: 19
    Rate: 1

    Hello nacxoffw,
    first question: Go to Launch Web Application. Then go to Logs. Power on the device on the battery terminals. See logs. This will give you clues to the error.
    second question: I assume that you have disconnected the Tx/Rx pins to the MCU (see post 61). Try it several times. Sometimes it works immediately, sometimes not. I have also reduced the baud rate but that didn't help either. I can't say why it suddenly worked again with the 912600 baud rate. I am also a beginner in this stuff.

    Hello p.kaczmarek2,
    I would prefer the flag. The module start wouldn't lose any time due to the timeout and it is probably more error resistant at slow WIFI. Could the flag solution work like this:

    autoexec.bat:

    // FLAG_NO_MQTT == true
    SetFlag 999 1

    startDriver tuyaMCU
    startDriver tmSensor
    ....

    drv_tuyaMCU.c:

    ...
    else {
    addLogAdv(LOG_INFO, LOG_FEATURE_TUYAMCU, "TuyaMCU_ProcessIncoming: TUYA_CMD_MCU_CONF, TODO!");
    }
    if (g_sensorMode) {
    if (g_tuyaBatteryPoweredState == TM0_STATE_AWAITING_WIFI) {
    g_tuyaBatteryPoweredState = TM0_STATE_AWAITING_MQTT;
    if (FLAG_NO_MQTT == true) {
    g_tuyaBatteryPoweredState = TM0_STATE_AWAITING_STATES;
    g_tuyaNextRequestDelay = 0;
    }
    }
    else if (g_tuyaBatteryPoweredState == TM0_STATE_AWAITING_MQTT) {
    g_tuyaBatteryPoweredState = TM0_STATE_AWAITING_STATES;
    g_tuyaNextRequestDelay = 0;
    }
    }
    break;
    ...

    Best regards,
    Wen2024
  • ADVERTISEMENT
  • #74 20931252
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12866
    So maybe instead of a flag, I can just... just check for disabled MQTT? For an empty MQTT host field in the config?
    Helpful post? Buy me a coffee.
  • Tuya MCU conf packets received but unhandled

    #75 20931316
    Wen2024
    Level 7  
    Posts: 19
    Rate: 1

    No, it's the situation from post 69:
    See logs:

    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED - 4
    Info:MAIN:Time 24, idle 185191/s, free 72568, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 2/38
    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:MQTT:mqtt_host empty, not starting mqtt
    Info:MAIN:Time 26, idle 191902/s, free 64000, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 3/38
    Info:MAIN:Time 27, idle 189351/s, free 72608, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:MAIN:Time 29, idle 188510/s, free 49000, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 30, idle 184653/s, free 49200, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 4/38

    ...

    Info:MQTT:mqtt_host empty, not starting mqtt
    Info:MAIN:Time 74, idle 187486/s, free 72608, MQTT 0(4), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:MAIN:Time 75, idle 192245/s, free 72608, MQTT 0(4), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:MAIN:Time 77, idle 189504/s, free 72608, MQTT 0(4), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:MAIN:Time 78, idle 188563/s, free 72608, MQTT 0(4), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:MAIN:Time 81, idle 186964/s, free 64000, MQTT 0(4), bWifi 1, secondsWithNoPing -1, socks 3/38
    Info:MAIN:Time 82, idle 189501/s, free 72608, MQTT 0(4), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:MAIN:Time 84, idle 190339/s, free 72608, MQTT 0(4), bWifi 1, secondsWithNoPing 1, socks 2/38
    Info:MAIN:Time 87, idle 192773/s, free 72608, MQTT 0(4), bWifi 1, secondsWithNoPing 4, socks 2/38
    Info:MAIN:Time 88, idle 191812/s, free 72608, MQTT 0(4), bWifi 1, secondsWithNoPing 5, socks 2/38
    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:MAIN:Time 25, idle 186494/s, free 72512, MQTT 0(0), bWifi 1, secondsWithNoPing -1, socks 3/38
    Info:MAIN:Time 33, idle 189593/s, free 64120, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 3/38
    Info:MAIN:Time 46, idle 191906/s, free 64120, MQTT 0(2), bWifi 1, secondsWithNoPing -1, socks 3/38
    Info:MAIN:Time 51, idle 180164/s, free 72728, MQTT 0(2), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:MAIN:Time 55, idle 187307/s, free 72728, MQTT 0(2), bWifi 1, secondsWithNoPing -1, socks 2/38
    Info:MAIN:Time 80, idle 192419/s, free 72512, MQTT 0(4), bWifi 1, secondsWithNoPing -1, socks 3/38
    Info:GEN:dhcp=0 ip=192.168.178.45 gate=192.168.178.1 mask=255.255.255.0 mac=18:de:50:bf:7e:75
    Info:GEN:sta: 1, softap: 0, b/g/n
    Info:GEN:sta:rssi=-53,ssid=MW_Home,bssid=c8:0e:14:b0:a7:33,channel=1,cipher_type:CCMP
  • #76 20931335
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12866
    Why do you think that a flag is better than a check for empty MQTT hostname?

    It would work exactly the same, but it would be more intuitive.

    The code would just check if MQTT hostname is set, and if not, it will proceed, it will work just like the flag solution you proposed.
    Helpful post? Buy me a coffee.
  • #77 20931344
    Wen2024
    Level 7  
    Posts: 19
    Rate: 1

    Yes, you're right. It's easier to understand.

    Added after 2 [minutes]:

    That was a misunderstanding. I tried out what happens when the field is empty and sent you the logs.
  • Set tuyaMcu_defWiFiState 0x04 or leave MQTT hostname empty

    #78 20931402
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12866
    I've checked the code again, and you know what? We could just have set the default Wifi state to 0x04 and it would have worked anyway.
    Code snippet in an editor with highlighted lines and comments.
    Still, here is a new version, it's more intuitive anyway:
    Snippet of code in a text editor showing logic for setting Wi-Fi and MQTT states.
    Here is the commit:
    https://github.com/openshwprojects/OpenBK7231...mmit/e226c8c0806f8d6b8fa64e118ef0b245c0be758a

    So, to sum up, if you want to use tmSensor device without MQTT, you need to do one of two things:
    Option 1: add to script:
    
    tuyaMcu_defWiFiState 0x04
    

    Option 2: make sure that your device has MQTT hostname field empty

    Without any of this, the device will wait until MQTT connects...
    Helpful post? Buy me a coffee.
  • #79 20931413
    nacxoffw
    Level 5  
    Posts: 13
    Rate: 1

    >>20931207
    Only one question, actually if I put only 3v with batteries the wifi does not work (suppose that it only appears every x minutes). If I put 3v in the wifi chipset then I can access these logs... Is this the normal work, correct?
  • #80 20931520
    Wen2024
    Level 7  
    Posts: 19
    Rate: 1

    Hello p.kaczmarek2, thank you for your help!!! I tried to flash my module with OpenBK7231N_QIO_1.17.427.bin but I always get writing errors. For today, I have to give up but as soon as I get a module flashed, I will get back to you. Thank you very much!!!
  • #81 20931853
    gabybriet
    Level 3  
    Posts: 4
    >>20923343
    I found the problem
    I used special character "&" for name
  • ADVERTISEMENT
  • #82 20933000
    nacxoffw
    Level 5  
    Posts: 13
    Rate: 1
    >>20931207

    Hi @Wen2024 thanks a lot, after search i will move the problems to this forum https://www.elektroda.com/rtvforum/topic4027957.html#20913628 that is talking about this module.


    On the other hand, for the others two devices YES, the CMU pinouts are cutted. But after ten tryies always the flash fails. What can i do?
  • #83 20933025
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14750
    Help: 659
    Rate: 12866
    gabybriet wrote:

    I used special character "&" for name

    Which name? It seems we need to disable special characters for names...
    Helpful post? Buy me a coffee.
  • TH01 runs without MQTT hostname configured

    #84 20935196
    Wen2024
    Level 7  
    Posts: 19
    Rate: 1

    Hello p.kaczmarek2 (post #78),
    I have flashed my TH01 modules with your modified version 1.17.427. I left the MQTT hostname field empty
    and here is the result:

    Graph monitoring temperature, humidity, and battery status with TH01 device.

    The TH01 device runs without MQTT connection!!!
    Next, I need to work on the big variation in the data acquisition interval. In the first test they are between 1:58 and 6:56 minutes.
    Thank's a lot for your work,
    @Wen2024

    Added after 10 [minutes]:

    Hello nacxoffw (post #82),
    Do you have a stable 3.3V power supply? Have you connected the + and - from the power supply to the Uart and Wifi Module (both to both)?
    Regards,
    @Wen2024
  • Suspected pinout issue causing zero sensor data

    #85 20958744
    nacxoffw
    Level 5  
    Posts: 13
    Rate: 1
    Hi, after a lot of work flash is done @Wen2024!
    Now it's working BUT data is always zero...
    Screenshot of the OpenBK7231N_Humedad interface showing temperature 0.00°C and humidity 0.0%. Screenshot of a device configuration interface showing IP address and pin settings.
    Electronic board with CB3S module

    Maybe pinout? But... I don't read anywhere to set it.

    I have find this thread https://www.elektroda.com/rtvforum/topic4024423.html#20968680 but without more info...
  • #86 20971334
    Wen2024
    Level 7  
    Posts: 19
    Rate: 1

    Hello nacxoffw,
    are your MQTT (Config/Configure MQTT) entries correct? A good idea is to look at auntlydia's post #40. It's a good guide to solve your problem. Have you looked at the logs (Launch Web Application / Logs)?
    Best regards,
    Wen2024
  • How to access BK7231N serial logs for Wi-Fi failures

    #87 21094681
    carlig833
    Level 7  
    Posts: 23
    Help: 1
    Rate: 5

    Hello there,
    I have the same device as @nacxoffw and I am experiencing frequent issues with device connectivity with my router.
    I can connect to the device access point and configure the SSID and password of my router, but frequently the device does not connect to the router.

    My question is how can I inspect the logs of the device to troubleshoot the cause of the issue?
    I wonder if either one of the two options below is viable:

    1. collect and decode the logs in real-time using RX/TX connection to the device.
    2. configure "persistent logs" so that I can collect them when the device is failing to connect to my router, then revert to access point mode and download the logs

    Do you have any link that covers 1 or 2?
  • Configuring OBK reporting interval for battery life

    #88 21162076
    carlig833
    Level 7  
    Posts: 23
    Help: 1
    Rate: 5
    I have this [BK7231N] [CB3S] [AHT20] sensor and I wonder if the temperature/humidity reporting interval can be configured in OBK or not.

    These devices usually report a new measure based on the measured quantity (temperature or humidity) being different compared with the previous reading more or less than a configured offset. Or they report a new measure, regardless of difference from previous reported value when a given time interval is elapsed. Is there anything that can be configured in OBK to influence (I would say reduce) the frequency of temp/humidity readings so that the battery will last longer?
  • AHT2X_Cycle command sets reporting interval

    #89 21162096
    DeDaMrAz
    Level 23  
    Posts: 620
    Help: 34
    Rate: 130
    carlig833 wrote:
    I have this [BK7231N] [CB3S] [AHT20] sensor and I wonder if the temperature/humidity reporting interval can be configured in OBK or not.

    These devices usually report a new measure based on the measured quantity (temperature or humidity) being different compared with the previous reading more or less than a configured offset. Or they report a new measure, regardless of difference from previous reported value when a given time interval is elapsed. Is there anything that can be configured in OBK to influence (I would say reduce) the frequency of temp/humidity readings so that the battery will last longer?


    What you are looking for can be found in the docs section in GitHub, search for AHT - https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md

    AHT2X_Cycle [IntervalSeconds]
  • #90 21319810
    GastonL
    Level 4  
    Posts: 7
    >>20905557
    I have the same question. Is there a way to prevent so many zeros after the decimal?

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