logo elektroda
logo elektroda
X
logo elektroda

BK7231T Treatlife DS03 Fan/Light Dimmer Switch: OTA Flash & Setup Guide (TuyaMCU dpIDs)

bleeblak8 3978 21
ADVERTISEMENT
  • #1 20417907
    bleeblak8
    Level 4  
    I picked this up on Amazon for a decent price. Was able to flash OTA with Tuya Cloud Cutter, but there are pads to flash it the standard way. Below are some pictures and the AutoExec.bat commands. Everything appears to work great.

    FCC ID - 2AFNL-TYWE3S - This doesn't appear to be the actual device's FCCID. BK7231T Treatlife DS03 Fan/Light Dimmer Switch: OTA Flash & Setup Guide (TuyaMCU dpIDs) BK7231T Treatlife DS03 Fan/Light Dimmer Switch: OTA Flash & Setup Guide (TuyaMCU dpIDs) BK7231T Treatlife DS03 Fan/Light Dimmer Switch: OTA Flash & Setup Guide (TuyaMCU dpIDs) BK7231T Treatlife DS03 Fan/Light Dimmer Switch: OTA Flash & Setup Guide (TuyaMCU dpIDs) BK7231T Treatlife DS03 Fan/Light Dimmer Switch: OTA Flash & Setup Guide (TuyaMCU dpIDs) BK7231T Treatlife DS03 Fan/Light Dimmer Switch: OTA Flash & Setup Guide (TuyaMCU dpIDs)
     startDriver TuyaMCU tuyaMcu_setBaudRate 115200 setChannelType 1 toggle setChannelType 2 toggle setChannelType 4 dimmer setChannelType 3 OffLowMidHigh tuyaMcu_setDimmerRange 100 1000 linkTuyaMCUOutputToChannel 1 1 1 linkTuyaMCUOutputToChannel 9 1 2 linkTuyaMCUOutputToChannel 3 4 3 linkTuyaMCUOutputToChannel 10 2 4 
  • ADVERTISEMENT
  • #2 20417990
    p.kaczmarek2
    Moderator Smart Home
    WB3S-ZR? That's interesting. On which board is the MCU? On the same as WiFi module or on another one?

    That FCC ID seems interesting. Hmm. TYWE3S is an ESP module. So they changed module inside but left FCC ID the same?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #4 20476782
    azsoccerpop
    Level 2  
    Here is my autoexec and MQTT Yaml for the TreatLife DS03. I am no developer, but I took bits and pieces from all over to make a working Treatlife Fan / Dimmer DS03 in Home Assistant. I used cloudcutter to upload the latest BK7231T firmware and then updated to version 1.15.568 for the newest Channel Type allowing for the 4 speeds on the fan control.

    autoexec.bat
    
    // start MCU driver
    startDriver TuyaMCU
    tuyaMcu_setBaudRate 115200
    
    // fan on/off channel
    setChannelType 1 toggle
    // map dpid1 to channel1, var type 1 (boolean)
    linkTuyaMCUOutputToChannel 1 1 1
    
    // let's say that channel 2 is dpid9 - light on/off
    setChannelType 2 toggle
    // map dpid9 to channel2, var type 1 (boolean)
    linkTuyaMCUOutputToChannel 9 1 2
    
    //fan speed channel
    setChannelType 3 OffLowMidHighHighest
    // map dpid3 to channel3, var type 4 (enum)
    linkTuyaMCUOutputToChannel 3 4 3
    
    //Light Dimmer Channel
    setChannelType 4 dimmer
    tuyaMcu_setDimmerRange 100 1000
    linkTuyaMCUOutputToChannel 10 2 4
    


    Home Assistant - configuration.yaml
    
    fan:
        - name: "Family Room Ceiling Fan"
          unique_id: "obk1F0AD8FD"
          icon: mdi:ceiling-fan
          availability:
            - topic: "ceiling_fan1/connected"
          payload_on: 1
          payload_off: 0
          state_topic: "ceiling_fan1/1/get"
          command_topic: "ceiling_fan1/1/set"
          percentage_state_topic: "ceiling_fan1/3/get"
          percentage_command_topic: "ceiling_fan1/3/set"
          percentage_value_template: '{{ (value | int   1) * 25 }}'
          percentage_command_template: "{{ ((value | int - 1) / 25) | int }}"
          preset_modes:
            - "low"
            - "medium"
            - "high"
            - "maximum"
          preset_mode_command_topic: "ceiling_fan1/3/set"
          preset_mode_state_topic: "ceiling_fan1/3/get"
          preset_mode_command_template: '{{ value | replace("low", "0") | replace("medium", "1") | replace("high", "2") | replace("maximum", "3") }}'
          preset_mode_value_template: '{{ value | replace("0", "low") | replace("1", "medium") | replace("2", "high") | replace("3", "maximum") }}'
          qos: 1
          retain: true
      light:
        - name: "Family Room Ceiling Light"
          unique_id: "obk1F0AD8FD_light"
          command_topic: "ceiling_fan1/2/set"
          state_topic: "ceiling_fan1/2/get"
          brightness_command_topic: "ceiling_fan1/4/set"
          brightness_state_topic: "ceiling_fan1/4/get"
          brightness_scale: 100
          brightness_value_template: "{{value_json.Dimmer}}"
          payload_on: 1
          payload_off: 0
          retain: true
                
    
  • ADVERTISEMENT
  • #5 20477004
    p.kaczmarek2
    Moderator Smart Home
    Thank you for sharing this, especially the Home Assistant YAML code. I will link to that post from our docs.
    https://github.com/openshwprojects/OpenBK7231T_App/tree/main/docs
    Helpful post? Buy me a coffee.
  • #6 20478754
    bleeblak8
    Level 4  
    Thanks for that updated and much nicer looking autoexe. I also wanted to note that I just purchased another DS03 and it came with an ESP chip. Guessing it's old stock, but wanted to throw that out there to double check what chip you have in your device. I was trying to flash for the updated method and then realized that chip was an ESP.
  • #7 20478858
    p.kaczmarek2
    Moderator Smart Home
    What was the date/code on the PCB or/and on the packaging? Was there a Bluetooth logo on the package?
    Helpful post? Buy me a coffee.
  • #8 20480097
    no2chem
    Level 4  
    I just got one of these. Will mess around with it sometime to see if I can get my custom TuyaMCU Nuvoton firmware running on it too -https://github.com/no2chem/open-tuyamcu - seems like a similar architecture.
  • ADVERTISEMENT
  • #9 20480130
    p.kaczmarek2
    Moderator Smart Home
    Very nice project, I can also see you have OBK autoexec.bat in the root directory:
    
    startDriver TuyaMCU
    tuyaMcu_setBaudRate 115200
    setChannelType 0 OpenClosed
    SetChannelLabel 0 MainButton
    setChannelType 1 OpenClosed
    SetChannelLabel 0 PlusButton
    setChannelType 2 OpenClosed
    SetChannelLabel 0 MinusButton
    setChannelType 3 ReadOnly
    SetChannelLabel 3 Temperature
    setChannelType 10 Toggle
    SetChannelLabel 10 LED0
    setChannelType 11 Toggle
    SetChannelLabel 11 LED1
    setChannelType 12 Toggle
    SetChannelLabel 12 LED2
    setChannelType 13 Toggle
    SetChannelLabel 13 LED3
    setChannelType 14 Toggle
    SetChannelLabel 14 LED4
    setChannelType 15 Toggle
    SetChannelLabel 15 LED5
    setChannelType 16 Toggle
    SetChannelLabel 16 LED6
    setChannelType 17 Toggle
    SetChannelLabel 17 MainWhite
    setChannelType 18 Toggle
    SetChannelLabel 18 MainRed
    setChannelType 20 TextField
    SetChannelLabel 20 LEDFlags
    setChannelType 21 TextField
    SetChannelLabel 21 TriacDelay
    setChannelType 22 TextField
    SetChannelLabel 22 TriacOnTime
    setChannelType 23 Toggle
    SetChannelLabel 23 TriacForceOn
    setChannelType 32 Toggle
    SetChannelLabel 32 Relay
    linkTuyaMCUOutputToChannel 0 1 0
    linkTuyaMCUOutputToChannel 1 1 1
    linkTuyaMCUOutputToChannel 2 1 2
    linkTuyaMCUOutputToChannel 50 2 3
    linkTuyaMCUOutputToChannel 10 1 10
    linkTuyaMCUOutputToChannel 11 1 11
    linkTuyaMCUOutputToChannel 12 1 12
    linkTuyaMCUOutputToChannel 13 1 13
    linkTuyaMCUOutputToChannel 14 1 14
    linkTuyaMCUOutputToChannel 15 1 15
    linkTuyaMCUOutputToChannel 16 1 16
    linkTuyaMCUOutputToChannel 17 1 17
    linkTuyaMCUOutputToChannel 18 1 18
    linkTuyaMCUOutputToChannel 20 2 20
    linkTuyaMCUOutputToChannel 32 1 32
    linkTuyaMCUOutputToChannel 40 2 21
    linkTuyaMCUOutputToChannel 41 2 22
    linkTuyaMCUOutputToChannel 42 1 23
    

    Is it used for testing? You can consider moving it to some kind of "examples" directory and creating one directory per device, so people know which device you are referring to.
    We already also have some autoexecs in our docs:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/autoexecExamples.md
    And source files are here:
    https://github.com/openshwprojects/OpenBK7231T_App/tree/main/docs/autoexecs

    I would really like to read more about your project, how to setup, what kind of SDK was used, etc...
    Helpful post? Buy me a coffee.
  • #10 20483745
    bleeblak8
    Level 4  
    >>20478858

    The box, the shell, and the PCB date code are exactly the same.
    BK7231T Treatlife DS03 Fan/Light Dimmer Switch: OTA Flash & Setup Guide (TuyaMCU dpIDs) BK7231T Treatlife DS03 Fan/Light Dimmer Switch: OTA Flash & Setup Guide (TuyaMCU dpIDs)
  • #11 20483913
    p.kaczmarek2
    Moderator Smart Home
    They are the same indeed! Very interesting. By the way, the device is not submitted to our online database:
    https://openbekeniot.github.io/webapp/devicesList.html
    Helpful post? Buy me a coffee.
  • #12 20486880
    bleeblak8
    Level 4  
    I'll work on getting this added to the tear down guide.
    Thanks for letting me know this wasn't part of that guide.

    bleeblak8
  • Helpful post
    #13 20510273
    arantius
    Level 1  
    Thanks for this post. I've made this autoexec.bat based on the above:

    // Set up NTP to Google's Public NTP.
    ntp_setServer 216.239.35.0
    ntp_timeZoneOfs -04:00
    startDriver NTP
    
    // Enable communication with Tuya module.
    startDriver TuyaMCU
    tuyaMcu_defWiFiState 4
    tuyaMcu_setBaudRate 115200
    
    // Configure light and dimmer on channels 1/2.
    setChannelType 1 toggle
    linkTuyaMCUOutputToChannel 9 1 1  // dpId = 9, type = 1 (bool), channel = 1
    setChannelLabel 1 Light
    setChannelType 2 dimmer
    tuyaMcu_setDimmerRange 100 1000
    linkTuyaMCUOutputToChannel 10 2 2  // dpId = 10, type = 2 (value), channel = 2
    
    // Configure fan and its level on channels 3/4.
    setChannelType 3 toggle
    linkTuyaMCUOutputToChannel 1 1 3   // dpId = 1, type = 1 (bool), channel = 3
    setChannelLabel 3 Fan
    setChannelType 4 LowMidHighHighest
    linkTuyaMCUOutputToChannel 3 4 4   // dpId = 3, type = 4 (enum), channel = 4


    I don't know if NTP is useful, but saw logs about setting the Tuya time, always to zero. I also set the "default WiFi state" because I'm just barely setting this up, no MQTT yet. And in this state, the Tuya MCU will repeatedly reset things, which includes turning the light off. I think I want this default anyway -- I don't want my light resetting and turning off if e.g. WiFi is lost briefly.
  • #14 20600586
    whiskeysprinkler
    Level 2  
    arantius wrote:
    Thanks for this post. I've made this autoexec.bat based on the above:

    // Set up NTP to Google's Public NTP.
    ntp_setServer 216.239.35.0
    ntp_timeZoneOfs -04:00
    startDriver NTP
    
    // Enable communication with Tuya module.
    startDriver TuyaMCU
    tuyaMcu_defWiFiState 4
    tuyaMcu_setBaudRate 115200
    
    // Configure light and dimmer on channels 1/2.
    setChannelType 1 toggle
    linkTuyaMCUOutputToChannel 9 1 1  // dpId = 9, type = 1 (bool), channel = 1
    setChannelLabel 1 Light
    setChannelType 2 dimmer
    tuyaMcu_setDimmerRange 100 1000
    linkTuyaMCUOutputToChannel 10 2 2  // dpId = 10, type = 2 (value), channel = 2
    
    // Configure fan and its level on channels 3/4.
    setChannelType 3 toggle
    linkTuyaMCUOutputToChannel 1 1 3   // dpId = 1, type = 1 (bool), channel = 3
    setChannelLabel 3 Fan
    setChannelType 4 LowMidHighHighest
    linkTuyaMCUOutputToChannel 3 4 4   // dpId = 3, type = 4 (enum), channel = 4



    i got the non dimmer/light version... ill try out the stuff above and see if it works.

    tbh i've installed a lot of treatlife ss01 and ss01s switches lately. i guess i should post something for that. the posts previously for the ss01 (not s) didnt really get to the "meat" of setting it up

    Added after 44 [seconds]:

    ps how do i get a list of drivers?!

    Added after 3 [minutes]:

    and i suck. i gotta change the ntp to the gateway; i blocked outbound traffic to iot devices
  • #15 20600748
    p.kaczmarek2
    Moderator Smart Home
    Helpful post? Buy me a coffee.
  • #16 20639578
    IsThisRight
    Level 2  
    >>20417907
    Hi bleeblak8, quick question, did you have any difficulty pulling the DS03 apart? For some reason I can't seem to pull it apart without the fear of snapping the board, as the boards seem to be attached at the spot I've circled. I'm hoping you have some advice, or maybe they're being made a little differently now and are more difficult to pull apart.

    Context: I can pull it apart just enough to see the model is CB3S so I'm trying to planning on replacing it with a ESP-12 per the following instructions so I can install Tasmota
    https://blakadder.com/replace-tuya-esp12/

    BK7231T Treatlife DS03 Fan/Light Dimmer Switch: OTA Flash & Setup Guide (TuyaMCU dpIDs)
  • #17 20639753
    p.kaczmarek2
    Moderator Smart Home
    I think it should be possible to flash the BK7231N CB3S wirelessly for this device and run it with OBK, that would save you some risk and money that would otherwise go for ESP module.
    Helpful post? Buy me a coffee.
  • #18 20648919
    IsThisRight
    Level 2  
    p.kaczmarek2 wrote:
    I think it should be possible to flash the BK7231N CB3S wirelessly for this device and run it with OBK, that would save you some risk and money that would otherwise go for ESP module.


    Hi @p.kaczmarek2, thanks for your reply. I went ahead and gave that a shot, but unfortunately although it appeared to work, it appears that I may be in a worse position now where I still can't separate the boards to get to the chip to replace it (my original question) and I now no longer seem to be able to put my device DS03 (model CB3S) in AP mode.

    See below DETAILS but after following the instructions I got the following message but unfortunately it doesn't show up among my other approx. 20 tasmota/ESPHome devices with an IP address in my router's DHCP Server Leases
    "Firmware file has been sent and MQTT reported a progress of nearly complete
    Flashing should be complete. It takes about 15 seconds for the device to reboot and verify the flash was valid
    Please wait about 30 seconds then look for signs of activity from the firmware you supplied (either watch for AP mode or check if it joined your network)"


    GOALS
    - At this point, maybe the firmware is in place as the message states, can anyone provide help in getting it joined to my network? I could retry but I can't seem to put it in AP mode anymore
    - If not, can someone help explain how I can separate the boards that seem to be fused together where I circled in my original post so I can access the chip to replace it?

    DETAILS
    I fired up a Raspberry Pi 3b+, installed docker, network-manager, and followed the steps in the tuya-cloudcutter INSTRUCTIONS.md where I did the following
    - sudo ./tuya-cloudcutter.sh -r -w <SSID> -s <SSID Pass>
    - After about 12 minutes I chose the following:
    - Option #2: "Flash 3rd party firmware"
    - "By manufacturer/device name"
    - "TreatLife"
    - "DS03 Fan and Light Smart Switch BK7231N v2.1.6"
    - "OpenBeken-v1.17.130_bk7231n.ug.bin"
    - Put the device into AP mode by holding the light switch button to get a fast blinking red light (about 5 seconds), then again held the light switch button again to get a slow blinking red light (about 5 seconds)

    - It then said the following:
    Device 'wlan0' successfully activated with <SomeGUID>
    Connected to access point
    Waiting 1 sec to allow device to set itself up...
    Running initial exploit toolchain...
    Exploit run, saved device config too!
    output-/work/configured-devices/ZoRQqaZZCa6j.deviceconfig
    TreatLife-SL-C05A", trying to connect...
    Error Connection activation failed: (53) The Wi-Fi network could not be found.
    Wiping NetworkManager configs

    - I then put the switch into AP mode again (see above) and it said:
    Using WLAN adapter: wlan0
    Configuration file: /dev/stdin
    wlan0: interface state UNINITIALIZED->ENABLED
    wlan0: AP-ENABLED
    Processing endpoint
    /v2/url_config
    tuya.device.active
    tuya.device.dynamic.config.get
    tuya.device..becon.key.fetch
    tuya.device.property.save
    tuya.device.uuid.pskkey.get
    tuya.device.upgrade.get
    tuya.device.upgrade.status.update
    /files/OpenBeken-v1.17.130_bk7231n.ug.bin
    Firmware update progress: <x>
    Firmware file has been sent and MQTT reported a progress of nearly complete
    Flashing should be complete. It takes about 15 seconds for the device to reboot and verify the flash was valid
    Please wait about 30 seconds then look for signs of activity from the firmware you supplied (either watch for AP mode or check if it joined your network)
    Device MAC address: <xx:xx:xx:xx:xx:xx>
  • #19 20652533
    p.kaczmarek2
    Moderator Smart Home

    I am sorry to hear that the Cloudcutter has failed with your device. I don't know much about wireless flashing, as I have never used it, I always flash by wires.

    So maybe let's try to take out the PCB and solder the wires. What is exactly the problem here? Maybe we just need to experiment with one of your devices and see how to safely disassemble it.

    Can you tell me, was there a daughter board on top of that connector?
    BK7231T Treatlife DS03 Fan/Light Dimmer Switch: OTA Flash & Setup Guide (TuyaMCU dpIDs)
    or are you saying there is another board under it? If there is another board under it, it should be possible to pull that first board out.

    Maybe use two flat screwdrivers as levers, from two opposite sides, and gently pull it up...

    Or do you think it's soldered?
    Helpful post? Buy me a coffee.
  • #20 20653603
    IsThisRight
    Level 2  

    It's kind of hard to explain, so here's a video showing what I mean. As you can see in the video, while trying to separate it, the boards are being pulled and stretched and are bending because they're stuck together somehow. As far as I can tell, the points of restriction are those pins that I focus the video on.

    https://photos.app.goo.gl/rGF1WwqJ5o1oyziE8

    Notes
    - The image I posted (that you're referring to) where I circled that area in red was just taken from @bleeblak8's original post in this thread just as a reference to the area where I believe is restricting me from pulling it apart to get access to the boards.
    - I was able to pull it apart just enough to peek inside to see that the model is CB3S
  • #21 20653670
    p.kaczmarek2
    Moderator Smart Home

    That doesn't look right. We may be missing something obvious.

    I think you need to remove the sticker first:
    BK7231T Treatlife DS03 Fan/Light Dimmer Switch: OTA Flash & Setup Guide (TuyaMCU dpIDs)
    Then check if it is possible to remove the back cover. Maybe also unscrew the screw holding here:
    BK7231T Treatlife DS03 Fan/Light Dimmer Switch: OTA Flash & Setup Guide (TuyaMCU dpIDs)
    Helpful post? Buy me a coffee.
  • #22 20654765
    IsThisRight
    Level 2  

    I removed the sticker to confirm that there's nothing (no screws) under the sticker, and what you're referring to as the screw holding is not actually a screw holding (with a screw to be removed), it's just a piece of plastic whose purpose appears just to be to keep an even separation, there's another one on the other side exactly like it that I can easily see to pretty much confirm it - it's easier to see on that side since I can pull it apart much further. I'm able to pull it apart on all other sides much further and can look inside from all other angles and can confirm that what I show in the video is where it's stuck together.

    It might be hard to tell in the video, but I should emphasize that I did apply a pretty decent amount of force to try to separate it - it's really attached pretty solidly there...

Topic summary

The discussion revolves around the BK7231T Treatlife DS03 Fan/Light Dimmer Switch, focusing on the process of flashing the device OTA using Tuya Cloud Cutter and the standard flashing method. Users share their experiences with the device's microcontroller (MCU), which is identified as a Nuvoton M031LC2AE, and the ESP module (TYWE3S) that may have been replaced in newer models. Various configurations for the autoexec.bat file are provided to enable functionality in Home Assistant, including fan control, light dimming, and MQTT integration. Users also discuss challenges in disassembling the device for hardware modifications and the potential for using alternative firmware like Tasmota. The conversation highlights the importance of identifying the correct chip and firmware version for optimal performance.
Summary generated by the language model.
ADVERTISEMENT