logo elektroda
logo elektroda
X
logo elektroda

[BK7231N / CBU] Generic Tuya 4-Port Wifi Smart Switch WSM16-4

Xinayder 3819 14
ADVERTISEMENT
  • Hello, this is my first teardown of a generic Tuya-compatible smart switch with 4 ports. The model is WSM16-4.

    I bought it from AliExpress: https://a.aliexpress.com/_mM5GhGI

    Let me also post here some screenshots from the Aliexpress link, in case it expires...
    [BK7231N / CBU] Generic Tuya 4-Port Wifi Smart Switch WSM16-4 [BK7231N / CBU] Generic Tuya 4-Port Wifi Smart Switch WSM16-4
    What a nice tricky way to do a dual way control.

    [BK7231N / CBU] Generic Tuya 4-Port Wifi Smart Switch WSM16-4 [BK7231N / CBU] Generic Tuya 4-Port Wifi Smart Switch WSM16-4 [BK7231N / CBU] Generic Tuya 4-Port Wifi Smart Switch WSM16-4

    [BK7231N / CBU] Generic Tuya 4-Port Wifi Smart Switch WSM16-4 [BK7231N / CBU] Generic Tuya 4-Port Wifi Smart Switch WSM16-4 [BK7231N / CBU] Generic Tuya 4-Port Wifi Smart Switch WSM16-4

    We can see that the MCU used is a CBU. These pictures were taken after disassembly and OpenBK converting, that's why there are burn marks on the plastic casing and uneven solder.

    Datasheet: https://developer.tuya.com/en/docs/iot/cbu-module-datasheet?id=Ka07pykl5dk4u

    By looking at the datasheet, this is the pinout used for flashing OpenBK:

    [BK7231N / CBU] Generic Tuya 4-Port Wifi Smart Switch WSM16-4 [BK7231N / CBU] Generic Tuya 4-Port Wifi Smart Switch WSM16-4

    - GND: pin 13
    - VCC: pin 14
    - TX1: pin 15
    - RX1: pin 16
    - CEN: pin 18

    To flash OpenBK, I used a USB UART programmer and connected the cables accordingly. As usual, CEN neeeds to be grounded before flashing, so I connected CEN to a push button that grounds the pin when I press it, so the MCU can enter the bootloader mode.

    [BK7231N / CBU] Generic Tuya 4-Port Wifi Smart Switch WSM16-4

    I used the hid_download tool to flash, obtained from https://github.com/OpenBekenIOT/hid_download_py and used the following parameters:

    python uartprogram OpenBK7231N_QIO_1.15.206.bin --unprotect -d /dev/ttyUSB0 -w --startaddr 0x0

    As soon as the program started, I pressed the push button connected to CEN to put the device into bootloader mode in order to flash the new firmware. The unprotect parameter is required, otherwise it will fail with a CRC error.
    NOTE: As pointed out, the method above can be replaced by using the new Windows, user-friendly flashing tool from https://github.com/openshwprojects/BK7231GUIFlashTool

    After flashing, it was time to configure the module by assigning its pins to their functions. I tried to look for existing teardowns and their setups, but unfortunately none of them had the same pinout as this "generic" module, so it was a trial and error method by connecting a light bulb to the relay outputs and testing each pin to find the correct pinout.

    [BK7231N / CBU] Generic Tuya 4-Port Wifi Smart Switch WSM16-4

    - P6: Btn, channel 2
    - P7: Btn, channel 3
    - P8: Btn, channel 4
    - P9: WifiLED
    - P10: Relay, channel 2
    - P16: Relay, channel 4
    - P17: Relay, channel 3
    - P20: Relay, channel 1
    - P24: Btn; this is the button originally used to pair the device, I'm using it to toggle all relays on or off.
    - P26: Btn, channel 1

    [BK7231N / CBU] Generic Tuya 4-Port Wifi Smart Switch WSM16-4

    Cool? Ranking DIY
    About Author
    Xinayder
    Level 8  
    Offline 
    Xinayder wrote 24 posts with rating 4. Been with us since 2022 year.
  • ADVERTISEMENT
  • #2 20369475
    p.kaczmarek2
    Moderator Smart Home
    Thank you for presentation.
    I will just note here that this approach is obsolete for Windows:
    Xinayder wrote:

    python uartprogram OpenBK7231N_QIO_1.15.206.bin --unprotect -d /dev/ttyUSB0 -w --startaddr 0x0

    We have a better tool for that:
    https://github.com/openshwprojects/BK7231GUIFlashTool
    It's Windows-only, but much simpler to run for beginners, it does automatic firmware backup and read, and it can also download automatically latest release from Github.

    Let me also post here some screenshots from the Aliexpress link, in case it expires...
    Spoiler:

    [BK7231N / CBU] Generic Tuya 4-Port Wifi Smart Switch WSM16-4
    [BK7231N / CBU] Generic Tuya 4-Port Wifi Smart Switch WSM16-4
    What a nice tricky way to do a dual way control.
    [BK7231N / CBU] Generic Tuya 4-Port Wifi Smart Switch WSM16-4
    [BK7231N / CBU] Generic Tuya 4-Port Wifi Smart Switch WSM16-4 [BK7231N / CBU] Generic Tuya 4-Port Wifi Smart Switch WSM16-4
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 20369498
    Xinayder
    Level 8  
    p.kaczmarek2 wrote:
    We have a better tool for that:
    https://github.com/openshwprojects/BK7231GUIFlashTool
    It's Windows-only, but much simpler to run for beginners, it does automatic firmware backup and read, and it can also download automatically latest release from Github.


    Right, I was checking the GitHub right now and the readme was updated. For Linux users the hid_download method remains, right? Are you related to the development team of the project; if so, is there a plan to create a multiplatform GUI flashing solution? I will try to run the GUI tool on Linux and provide feedback, but if the flashing/firmware retrieval code is documented, maybe someone could create the same tool in Python which would allow it to be multiplatform and run on both Windows and Linux.

    Regarding the AliExpress images, should I include them in the OP?

    EDIT: I updated the OP and included the new flashing tool and the Aliexpress pictures.
  • ADVERTISEMENT
  • #4 20369826
    p.kaczmarek2
    Moderator Smart Home
    Thank you, the Windows GUI flasher was added very recently, one or two days ago and it's not yet popular, and wasn't test much yet as well.

    Don't worry much about the shop screenshots, but since you already added them, I have put them in my post into a 'spoiler'.

    The multiplatform GUI solution is a nice idea, but I think it has a low priority. The GUI tool was made for the beginners and for less technical people, so users don't have to learn how to install Python and use command line on Windows. From my experience, the non-Windows users are usually a bit more experienced in IT (not always, but usually...) so I think they will be able to handle Python command line tool, at least for now.

    Run the current Gui tool on Linux... It's a WinForms application, it would need Wine to run, I guess? Or is there some way to compile it for Linux, did someone create some kind of equivalent for that?
    Helpful post? Buy me a coffee.
  • #5 20369877
    Xinayder
    Level 8  
    p.kaczmarek2 wrote:
    Run the current Gui tool on Linux... It's a WinForms application, it would need Wine to run, I guess? Or is there some way to compile it for Linux, did someone create some kind of equivalent for that?


    I tried with .NET Core, it doesn't work because it requires .NET Framework and as far as I know the framework isn't supported on Linux. But I installed mono and ran xbuild on the project root and to my surprise, there were no compilation errors and using mono to run the compiled exe worked without any issues. I haven't tried using it to communicate with a proper board, though.

    [BK7231N / CBU] Generic Tuya 4-Port Wifi Smart Switch WSM16-4
  • #6 20369933
    p.kaczmarek2
    Moderator Smart Home
    Wow, that's great! I didn't even know it was possible, I am not a Linux person, I must admit.
    @Xinayder would you be interested in contributing here, maybe adding a section "How to compile on linux" to readme through a pull request, or sending some kind of binary so we can release?
    https://github.com/openshwprojects/BK7231GUIFlashTool
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #7 20372981
    ferbulous
    Level 18  
    Hi, i recommend using this workstation to avoid melting the plastic next to the chip with soldering iron.
    Or press the dupont cable to the tx/rx pin with some blue tacs.
  • #8 20373390
    p.kaczmarek2
    Moderator Smart Home
    This is a very nice suggestion, @ferbulous , but it seems to require a special kind of filament. I didn't even know that there is such a kind of material. It wouldn't work with PLA, would it?
    Helpful post? Buy me a coffee.
  • #9 20373948
    ferbulous
    Level 18  
    @p.kaczmarek2 I don't think it requires any special filament, I just had it printed online using PLA
    And I use this remixed version with magnet base, easier for the legs to stick on the base

    [BK7231N / CBU] Generic Tuya 4-Port Wifi Smart Switch WSM16-4
    [BK7231N / CBU] Generic Tuya 4-Port Wifi Smart Switch WSM16-4
  • #10 20386790
    p.kaczmarek2
    Moderator Smart Home
    I will try to print it with PLA and we'll see how it goes. It could make a useful article for the frontpage.

    I also saw TYWE3S flashing jigs somewhere.
    Helpful post? Buy me a coffee.
  • #11 20387096
    ferbulous
    Level 18  
    p.kaczmarek2 wrote:
    I also saw TYWE3S flashing jigs somewhere.

    That one is useful for wb3s/cb3s form factor
    Don't see anyone making a jig for the cbu chip yet
  • #12 21113048
    e88cc
    Level 13  
    Good morning. I have one question. What is the purpose of changing the firmware on tuya switches?
  • #13 21113323
    p.kaczmarek2
    Moderator Smart Home
    This allows them to be freely configurable, combined with other systems (Home Assistant), extended (add new functionality) and frees them from potential surveillance by the manufacturer (not everyone wants to have a foreign device reporting to china in their LAN)
    Helpful post? Buy me a coffee.
  • #14 21119186
    e88cc
    Level 13  
    I understand that since this works via a tuya server in China then after sflashing and changing the address that the device and the app on the phone communicate with, a soft on that server is required to operate?
  • #15 21119195
    p.kaczmarek2
    Moderator Smart Home
    Once flashed, this works 100% locally on your LAN. Locally you can have the Tasmota Control (OpenBeken compatible) apps on your phone and this will work, but only on your LAN.

    If you want worldwide access, then you need to set up a cloud/ready service yourself, or set up an off-the-shelf solution, such as one based on Home Assistant.
    Helpful post? Buy me a coffee.

Topic summary

The discussion revolves around the teardown and modification of the Tuya-compatible 4-Port Wifi Smart Switch model WSM16-4. Users share insights on flashing firmware using tools like the BK7231GUIFlashTool, which simplifies the process for Windows users, while Linux users can utilize the hid_download method. There are suggestions for creating a multiplatform GUI tool and discussions on the importance of firmware modification for local control and privacy. Users also exchange tips on soldering techniques and the use of 3D-printed jigs for handling components. The conversation highlights the benefits of flashing firmware to enhance functionality and reduce reliance on Tuya's servers.
Summary generated by the language model.
ADVERTISEMENT