logo elektroda
logo elektroda
X
logo elektroda

[BK7231N] [CBU] [AHT30] Cutesliving TH01 Smart Life Temperature and Humidity Sensor

divadiow 3597 18
ADVERTISEMENT
  • #1 20879346
    divadiow
    Level 34  
    I present what appears to be another variant of the temperature and humidity sensor TH01 (TH01Y on PCB). This unit has a CBU (BK7231N) module soldered to the top of the PCB. It takes 2x AAA batteries. Packaging is labeled as a Smart Life product.

    (My original post)

    PCB silk-screen markings of interest:
    TH01Y-CBU_V1.0 2023-10-11

    I notice there are test pads marked "AHT20", but the sensor chip is actually an AHT30.

    Advertisement for Tuya temperature and humidity sensor on an online store.
    Smart Life temperature and humidity sensor packaging with barcode. Smart Life temperature and humidity sensor packaging. External view of the TH01 temperature and humidity sensor in a white casing. Temperature and humidity sensor case without batteries on a fabric background. PCB of temperature and humidity sensor with CBU module. Close-up of a sensor PCB with the CBU module. Close-up of a PCB with AHT30 component and markings TH01Y-CBU_V1.0.
    Screen showing no updates available for modules.

    The 16 pin unmarked chip appears to be some MCU.
    Here are some traces I found which I think I've got right. BAT-/+, KEY and P5_B pads not shown in pic, but easily readable on PCB

    Close-up of the TH01Y sensor PCB with CBU module.

    Diagram of CBU module (BK7231N) with pin labels.

    I don't seem to be able to get a dump/flash yet though, however I power the unit - either from the CBU pins or from the batt-/+ pads. I guess maybe the MCU comms are getting in the way and the TX and or RX need decoupling. I'll update this as I find more.

    edit: probably the same situation as this? https://www.elektroda.com/rtvforum/topic3972260.html

    I'll disconnect RX/TX
  • ADVERTISEMENT
  • #2 20879377
    p.kaczmarek2
    Moderator Smart Home
    This looks like a TuyaMCU device, so probably a variant of this:
    [CB3S/BK7231N] Temperature/Humidity Sensor with TuyaMCU - Diagram, Reverse Engineering
    You could follow the guide above to handle this device, but... maybe it would be easier to add AHT30 support directly to OBK, remove the MCU and route the wires?

    Do you happen to know how AHT30 protocol looks like?
    We have a SHT3X driver, wouldn't that work for it already?
    https://github.com/openshwprojects/OpenBK7231T_App/issues/574
    https://github.com/openshwprojects/OpenBK7231...f3af70efda56f9f0ee856d/src/driver/drv_sht3x.c
    Removing TuyaMCU would bring some advantes, for example, you'd have full control over the sleep time.
    Helpful post? Buy me a coffee.
  • #3 20879452
    divadiow
    Level 34  

    Hi. Thanks for replying!

    I had not considered removing the MCU totally and rerouting.

    Since my last update, I've disconnected the MCU_TX pin on the MCU chip and have managed to begin a firmware dump, but it stops about 11-12s after power-up. Maybe it's going to sleep or something. I'll disconnect RX and try again.

    Screenshot of a flash memory reading process with success and failure messages.

    What is the purpose of the MCU if the CBU module can be engineered to perform all functions? Why do other temp/hum devices not have an MCU?

    I'll try the SHT3x driver if I can get it to flash with OBK. I do not know what the AHT30 protocol looks like. I could only find AHT20 references.
  • ADVERTISEMENT
  • #4 20880001
    p.kaczmarek2
    Moderator Smart Home
    Apparently no one knows. Tuya is using both TuyaMCU and solo WiFi module in their sensors. For us, I'd always say that TuyaMCU only complicates stuff, but maybe, just maybe, the MCU is a bit more power saving than the WiFI-only version, but I would have to check. Still, it's always a lottery, I don't think it's possible to determine whether a sensor is TuyaMCU-based or not just juding from the advertisement and product description itself.
    Helpful post? Buy me a coffee.
  • #5 20968680
    nacxoffw
    Level 5  
    @pkaczmarek2 @divadiow

    Hi, i have two PCBs more recent like that (TH01Y of 2023-12-16)
    Image of a PCB with connected wires on a blue surface.
    and with the next autoexec.bat no data is received, always 0:


    startDriver TuyaMCU
    startDriver tmSensor
    
    // may be needed, depends on device, some also use 9600
    tuyaMCU_setBaudRate 115200
    
    // dpID 1 is tempererature div 10
    setChannelType 1 temperature_div10
    linkTuyaMCUOutputToChannel 1 val 1
    // dpID 2 is % humidity
    setChannelType 2 Humidity
    linkTuyaMCUOutputToChannel 2 val 2
    // dpID 3 is battery state - low(0), mid(1) and high(2)
    linkTuyaMCUOutputToChannel 3 enum 3
    setChannelType 3 ReadOnlyLowMidHigh
    setChannelLabel 3 Battery
    //
    // setup dpCache - temperature interval
    //
    // Show textfield for that
    setChannelType 5 TextField
    // setup display name
    setChannelLabel 5 Temperature Interval
    // Make value persistant (stored between reboots), 
    // start value -1 means "remember last"
    SetStartValue 5 -1
    // set default value if not set
    if $CH5==0 then setChannel 5 1
    // link dpID 17 to channel 5, the type is val, extra '1' means that its dpCache variable
    linkTuyaMCUOutputToChannel 17 val 5 1
    
    setChannelType 6 TextField
    setChannelLabel 6 Humidity Interval
    SetStartValue 6 -1
    if $CH6==0 then setChannel 6 1
    linkTuyaMCUOutputToChannel 18 val 6 1


    Maybe dpID changes? How to know this?
  • #6 20968742
    p.kaczmarek2
    Moderator Smart Home
    For a start, please show us the full Web App log so we can tell which dpIDs are sent and whether is there TuyaMCU communication at all.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #7 20968792
    nacxoffw
    Level 5  
    @pkaczmarek262
    Info:MAIN:Main_Init_Before_Delay
    Info:CFG:####### Boot Count 68 #######
    Warn:CFG:CFG_InitAndLoad: Correct config has been loaded with 6 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:ssid:CaritoAux key:Tequiero1390
    Info:MAIN:Using SSID [CaritoAux]
    Info:MAIN:Using Pass [Tequiero1390]
    Info:MQTT:MQTT_RegisterCallback called for bT BK7231N_HumedadPrinc/ subT BK7231N_HumedadPrinc/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT bekens/ subT bekens/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/BK7231N_HumedadPrinc/ subT cmnd/BK7231N_HumedadPrinc/+
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/bekens/ subT cmnd/bekens/+
    Info:MQTT:MQTT_RegisterCallback called for bT BK7231N_HumedadPrinc/ subT BK7231N_HumedadPrinc/+/get
    Error:CMD:Too many args, skipped all after 32nd.
    Info:MAIN:Started TuyaMCU.
    Info:CMD:CMD_StartScript: started autoexec.bat at the beginning
    Info:MAIN:Main_Init_After_Delay done
    Info:MAIN:Drv TuyaMCU is already loaded.
    Info:MAIN:Started tmSensor.
    Info:GEN:Channel 1 type changed to temperature_div10
    Info:GEN:Channel 2 type changed to Humidity
    Info:GEN:Channel 3 type changed to ReadOnlyLowMidHigh
    Info:GEN:Channel 5 type changed to TextField
    Info:EVENT:CMD_If: fourth argument always must be 'else', but it's '5'
    Info:GEN:Channel 6 type changed to TextField
    Info:EVENT:CMD_If: fourth argument always must be 'else', but it's '6'
    Info:MAIN:Time 1, idle 265638/s, free 72976, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 2, idle 186537/s, free 72976, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 3, idle 70244/s, free 72256, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 4, idle 0/s, free 72256, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Time 5, idle 0/s, free 72256, 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 openhabian
    mqtt_pass openhabianNacxo
    mqtt_clientID BK7231N_HumedadPrinc
    mqtt_host 192.168.1.100:1883
    Info:MAIN:Time 6, idle 101614/s, free 72776, MQTT 0(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MAIN:Boot complete time reached (5 seconds)
    Info:CFG:####### Set Boot Complete #######
    Info:MQTT:mqtt_connection_cb: Successfully connected
    Info:MQTT:mqtt_subscribed to BK7231N_HumedadPrinc/+/set
    Info:MQTT:mqtt_subscribed to bekens/+/set
    Info:MQTT:mqtt_subscribed to cmnd/BK7231N_HumedadPrinc/+
    Info:MQTT:mqtt_subscribed to cmnd/bekens/+
    Info:MQTT:mqtt_subscribed to BK7231N_HumedadPrinc/+/get
    Info:MQTT:Publishing val humedadprinc to BK7231N_HumedadPrinc/host retain=0
    Info:MAIN:Time 7, idle 173706/s, free 72832, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    Info:MQTT:Publishing val Build on Jan 25 2024 17:06:47 version 1.17.425 to BK7231N_HumedadPrinc/build retain=0
    Info:MAIN:Time 8, idle 198563/s, free 72832, MQTT 1(1), bWifi 1, secondsWithNoPing -1, socks 2/38 
    
  • #8 20968807
    p.kaczmarek2
    Moderator Smart Home
    There is no TuyaMCU communication at all. Do you power that WiFI module artificially? TuyaMCU communication will only occur if you allow TuyaMCU to control the power of WIFi chip
    Helpful post? Buy me a coffee.
  • #9 20968824
    nacxoffw
    Level 5  
    I tested powering from battery pinouts and from CB3S 3v/GND pinouts before and after rebuild Rx Tx board traces...
    Any tip?
  • #10 20968837
    p.kaczmarek2
    Moderator Smart Home
    What is that?
    
    Error:CMD:Too many args, skipped all after 32nd.
    

    This isn't supposed to happen.

    It looks like an issue that I saw few months ago, where a user had some strange web browser bug that caused autoexec.bat script copied from forum to corrupt itself (wrong line endings) and it broke OBK parser.

    Maybe you need to somehow fix (remove and manually enter) line endings of script and retry...

    Can you go to OBK web app panel, to LittleFS tab, and download zip/tarball of LFS and attach it here so I can check?
    Helpful post? Buy me a coffee.
  • #11 20968855
    nacxoffw
    Level 5  
    Of course! here you are @p.kaczmarek2 ! LittleFS__...-41-50.tar Download (10 kB)

    Edited: after same work, with a clean template this error gone
    Error:CMD:Too many args, skipped all after 32nd.


    Other error solved by commiting it:
    Info:EVENT:CMD_If: fourth argument always must be 'else', but it's '6'

    because this lines are wrong ¿?
    
    if $CH5==0 then setChannel 5 1
    if $CH6==0 then setChannel 6 1
    



    After that, MCU still not sending info in log (Logs.txt Download (7.6 kB))


    About this board... maybe... is a new model with CB3S instead of CBU... maybe need other Driver? In the U8 chipset say 8310...
    Another question, if i connect it throw battery connectors, TuyaMCU must be operating with Wifi chipset and send data? About timing... how long keep ON and how time took to sleep?

    Any sugestions?
  • ADVERTISEMENT
  • #12 21006796
    gloorung
    Level 6  

    Hi,

    I have the same unit and following the instructions, I was able to get this to work. The only thing I had to change in the autoexec.bat script provided in a previous post is the baud rate. After setting this to 9600, the device sends temperature, humidity, and battery level values as documented.
  • #13 21006801
    p.kaczmarek2
    Moderator Smart Home
    nacxoffw wrote:

    Other error solved by commiting it:
    Info:EVENT:CMD_If: fourth argument always must be 'else', but it's '6'

    because this lines are wrong ¿?
    
    if $CH5==0 then setChannel 5 1
    if $CH6==0 then setChannel 6 1
    

    This will happen if you use older version of firmware without better syntax parsing. Please update.
    Helpful post? Buy me a coffee.
  • #14 21070716
    JardaLCZ
    Level 5  
    Hello, thanks to all for the descriptions and tips.

    I have also two PCBs (TH01Y-CB3S_V1.6 2023-12-16), searched all forum topics but now I am in this state:
    Temperature and Humidity is displayed, but I need some level correction.
    There is warning to configure target channels for temp and humid. results, but I don't know where to do it. I tried to guess the pins but not successfully. See attached screenshot.


    MQTT is connected, but publish voltage and battery with 0 values.
    Humidity and temperature are published as:
    temperature not divided by 10
    ChaTH1/1/get 

    humidity
    ChaTH1/2/get


    My autoexec.bat:

    startDriver TuyaMCU
    startDriver tmSensor
    
    // may be needed, depends on device, some also use 9600
    tuyaMCU_setBaudRate 9600
    
    // dpID 1 is temperature div 10
    setChannelType 1 temperature_div10
    linkTuyaMCUOutputToChannel 1 val 1
    // dpID 2 is % humidity
    setChannelType 2 Humidity
    linkTuyaMCUOutputToChannel 2 val 2
    // dpID 3 is battery state - low(0), mid(1) and high(2)
    linkTuyaMCUOutputToChannel 3 enum 3
    setChannelType 3 ReadOnlyLowMidHigh
    setChannelLabel 3 Battery
    //
    // setup dpCache - temperature interval
    //
    // Show textfield for that
    setChannelType 5 TextField
    // setup display name
    setChannelLabel 5 Temperature Interval
    // Make value persistent (stored between reboots),
    // start value -1 means "remember last"
    SetStartValue 5 -1
    // set default value if not set
    if $CH5==0 then setChannel 5 1
    // link dpID 17 to channel 5, the type is val, extra '1' means that its dpCache variable
    linkTuyaMCUOutputToChannel 17 val 5 1
    
    setChannelType 6 TextField
    setChannelLabel 6 Humidity Interval
    SetStartValue 6 -1
    if $CH6==0 then setChannel 6 1
    linkTuyaMCUOutputToChannel 18 val 6 1


    Thanks for advice or links to final solution. If there is no final on one page, I will post my result when I will successfully similar to the "my" door sensor solution as here: https://www.elektroda.com/rtvforum/topic4023117.html

    EDIT/UPDATE:
    I understood, that battery indicator is readable and it has only 0,1,2 states
    ChaTH1/3/get 


    So now I want to customize:
    1. Wake up interval, for example the measuring one hour is enough to me.
    2. how to read temperature divided 10. I can change it in home assistant, but better is change it before MQTT publishing
    3. how to set up the correction of temp. and humidity.


    Screenshot of a configuration interface with channel settings. Screenshot of sensor interface showing temperature and humidity data with a warning about unconfigured target channels.
  • #15 21103261
    nyal
    Level 2  

    I also have some of these TH01Y-CBU Boards.
    This is what I have found out so far:
    If you try often enough (more than 10-100 times), you can program the firmware randomly without stopping after about 11-12 seconds.
    If you remove the MCU chip, programming works without any problem at the first time

    I have flashed 6 of these devices, but they stop working after a few hours. They don't publish to MQTT anymore.
    I want to revert them to the original firmware, but unfortunately, I can't find my original firmware file.

    Can someone upload or send this file to me?
  • #16 21104717
    divadiow
    Level 34  
    I've added factory firmware backup to first post, but MQTT shouldn't be dropping off. Anyway, won't it be in deep sleep mode most of the time and only do MQTT when it wakes...
  • #17 21104783
    p.kaczmarek2
    Moderator Smart Home
    BK7231 easy uart flasher automatically saves backups to backups directory.
    Helpful post? Buy me a coffee.
  • #18 21432080
    groove6j
    Level 8  
    I have the same CBU variant of TH01Y-CBU-V1.0 2023-11-15
    I have tested the solution with the autoexec.bat at 9600 baud and it works fine with tuyaMCU present.

    Now I'm figuring out how to wire the AHT20 directly to CBU and how I could communicate with it. I think it would be a nicer solution and propably more battery friendly if configured with the DeepSleep function. I suppose it is over I2C protocol.
  • #19 21434398
    p.kaczmarek2
    Moderator Smart Home
    AHT20 certainly works with OBK, I have AHT20 modules from aliexpress and I have them setup on my test boards with various OBK chips.

    You can also check AHT20 family tutorial:
    https://www.elektroda.com/rtvforum/topic4052685.html
    Helpful post? Buy me a coffee.

Topic summary

The discussion revolves around the Cutesliving TH01 Smart Life Temperature and Humidity Sensor, specifically the TH01Y variant featuring a BK7231N module. Users explore the device's functionality, including the AHT30 sensor chip, and the implications of using a TuyaMCU for communication. Several users report challenges with firmware flashing, MQTT connectivity, and the need for proper baud rate settings. Solutions include modifying the autoexec.bat script and considering the removal of the MCU for better control. Users also share experiences with different PCB versions and the importance of understanding the AHT30 protocol for effective integration.
Summary generated by the language model.
ADVERTISEMENT