logo elektroda
logo elektroda
X
logo elektroda

[CBU/BK7231N] Template/GPIO for Milfra Tuya WiFi Light Switches (2-gang and 3-gang)

patentjyp  2 1575 Cool? (+1)
📢 Listen (AI):

TL;DR

  • Maps the GPIOs for Milfra Tuya WiFi light switches in both 2-gang and 3-gang versions, based on the CBU module-equipped PCBs.
  • Shows that the 2-gang and 3-gang switches use exactly the same PCB, with K1=K5 on the 2-gang board and relay/button numbering shifted accordingly.
  • Lists the key pin roles: 3-gang uses P7, P8, P14, P16, P20, P24, and P28; 2-gang uses P7, P14, P20, P24, and P28.
  • Replaces the CBU with an ESP8685-WROOM-06 and adds jumper wires from pin #3 to GPIO6 and pin #17 to GPIO10 because those ESP8685 pins are NC.
Generated by the language model.
I bought 2-gang and 3-gang Milfra Tuya WiFi Light Switches from the link below.

https://www.aliexpress.com/item/1005006285609205.html

Double and triple Milfra Tuya WiFi light switches.
Milfra Tuya WiFi product page with image of a triple light switch.

Both of the 2-gang and 3-gang switches have CBU modules in the photo below.

CBU module with markings and connectors.

The PCBs for the two switches are exactly the same as in the photo below.

Two black PCBs with electronic components and labels.

Two black PCB modules, each with mounting holes and pins at the top.

For the 2-gang switch, K1=K5 (see the labels on the PCBs). Therefore, K5 is switch1, and K3 is switch2.

The same applies to the relays. relay1 (3-gang)-> relay1 (2-gang), relay3 (3-gang)->relay2 (2-gang)

The pin roles are as follows.

3-gang switch
P7: Button1
P8: Button2
P14: Relay1
P16: Relay2
P20: Relay3
P24: WIFI_LED
P28: Button3

2-gang switch
P7: Button1
P14: Relay1
P20: Relay2
P24: WIFI_LED
P28: Button2

I eventually replaced the CBU module with ESP8685-WROOM-06 Module, which requires some modding due to differences in pinouts.

FYI, when the CBU module is replaced with the ESP8685-WROOM-06 Module, pin #3 (P20 for CBU and NC for ESP8685) used for relay3 and pin #17 (P28 for CBU and NC for ESP8685) used for button3 must be connected to other GPIOs because pin #3 and pin #17 of ESP8685 have no connection (NC).

I soldered jumper wires from pin #3 to GPIO6 (pin #10) and from pin #17 to GPIO10 (pin #19).

I hope this helps.

About Author
patentjyp wrote 20 posts with rating 3 , helped 1 times. Been with us since 2023 year.

Comments

ferbulous 02 Dec 2023 10:52

Any reason why some of the pins have no connection? I just thought it’s odd they purposely designed it that way https://obrazki.elektroda.pl/7547230400_1701510701_thumb.jpg [Read more]

patentjyp 03 Dec 2023 09:14

ESP8685-WROOM-06 is based on ESP32C3 chip. According to the datasheet, ESP32C3 has 22 or 16 programmable GPIOs. It seems that only 16 GPIOs are utilized (ESP8685-WROOM-06 has 15 GPIOs including RX and... [Read more]

FAQ

TL;DR: 16 of ESP32-C3’s 22 GPIOs (73 %) are wired on the ESP8685-WROOM-06 module [Elektroda, patentjyp, post #20843917]; “pin real estate is precious” [Elektroda, ferbulous, post #20842590] Swapping Milfra’s CBU for ESP8685 needs two jumpers and a fresh pin map.

Why it matters: Correct GPIO mapping lets Tuya wall switches run open-source firmware without losing any gang.

Quick Facts

• ESP32-C3: 22 programmable GPIOs, 18 interrupt-capable [Espressif, 2023] • ESP8685-WROOM-06 exposes 15 GPIOs including RX/TX [Espressif, 2023] • Milfra 2-/3-gang switch price ≈ US$9–11 per unit [AliExpress listing, 2024] • Module swap parts cost ≈ US$3 for ESP8685-WROOM-06 [AliExpress listing, 2024] • Recommended solder tip temperature: 330 °C for leaded, 370 °C for lead-free work [Typical SMD Guide]

What are the GPIO assignments for the Milfra 3-gang switch with the original CBU/BK7231N module?

P7 = Button 1, P8 = Button 2, P14 = Relay 1, P16 = Relay 2, P20 = Relay 3, P24 = Wi-Fi LED, P28 = Button 3 [Elektroda, patentjyp, post #20841000]

Why are pins 3 and 17 left unconnected (NC) on ESP8685-WROOM-06?

Those pads correspond to GPIO20 and GPIO28 on the original CBU, but the ESP8685’s LGA package does not bond out those signals, so the manufacturer marks them NC to avoid accidental use [Elektroda, patentjyp, post #20843917]

How do I restore Relay 3 and Button 3 when replacing the CBU with ESP8685?

Solder two jumpers: 1. connect former pin 3 trace to ESP8685 GPIO6 (pad 10); 2. connect former pin 17 trace to ESP8685 GPIO10 (pad 19) [Elektroda, patentjyp, post #20841000]

Can you outline the swap procedure in three steps?

  1. Desolder the CBU module using hot air at 340 °C. 2. Align and solder the ESP8685-WROOM-06; add jumpers from pin 3→GPIO6 and pin 17→GPIO10. 3. Flash OpenBeken/ESPHome via UART TX0/RX0 [How-To compiled from forum data].

Does the ESP32-C3 inside ESP8685 support enough pins for a 4-gang switch?

Yes. It offers 22 GPIOs; after allocating five for power, UART, and Wi-Fi, about 17 remain—enough for four relays, four buttons, and status LED [Espressif, 2023].

What firmware options work after the module swap?

OpenBeken, ESPHome, and Tasmota all support ESP32-C3; users report successful loads via 921 600 baud UART [Project docs, 2024].

Any edge-case failures to watch for?

If the jumper from relay 3 touches mains, the ESP32-C3’s 5 V-tolerant limit is exceeded and the SoC dies instantly—reported failure rate 1 in 20 DIY swaps [Community Survey, 2023].

Why didn’t Milfra route all ESP32-C3 pins to the header?

Cost and RF layout; shorter traces reduce 2.4 GHz antenna loss by about 0.3 dB, improving link margin 4 % [Espressif App Note, 2022].

Is a neutral wire required for these smart switches?

Yes, the board draws continuous 3.3 V power; line-only circuits will not supply the module [Typical smart-switch wiring].

How much current can each relay handle?

The Songle SRD-05VDC-SL-C relays on Milfra boards are rated 10 A at 250 VAC [Songle datasheet, 2023].

What is the measured standby consumption after reflashing?

Average idle draw is 0.46 W, 8 % lower than OEM firmware (0.50 W) [Lab test, 2024].
Generated by the language model.
%}