logo elektroda
logo elektroda
X
logo elektroda

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

patentjyp 1626 2

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.
ADVERTISEMENT
📢 Listen (AI):
  • 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.

    Cool? Ranking DIY
    About Author
    patentjyp
    Level 5  
    Offline 
    patentjyp wrote 20 posts with rating 3, helped 1 times. Been with us since 2023 year.
  • ADVERTISEMENT
  • #2 20842590
    ferbulous
    Level 18  
    Posts: 419
    Help: 8
    Rate: 56
    Any reason why some of the pins have no connection?
    I just thought it’s odd they purposely designed it that way

    Connector diagram with pin labels, some marked as NC (no connection).
  • #3 20843917
    patentjyp
    Level 5  
    Posts: 20
    Help: 1
    Rate: 3

    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 TX).
📢 Listen (AI):

FAQ

TL;DR: For Milfra Tuya WiFi light switches, the proven map covers 2 gang and 3 gang boards, and “the PCBs for the two switches are exactly the same.” This FAQ helps modders assign CBU/BK7231N GPIOs correctly and reroute the 3-gang-only lines when replacing CBU with an ESP8685-WROOM-06. [#20841000]

Why it matters: A correct pin map prevents dead buttons, missing relay control, and failed ESP8685 swaps on these Milfra wall switches.

Option Switch inputs Relay outputs Extra note
CBU in 2-gang P7, P28 P14, P20 P24 = WiFi LED
CBU in 3-gang P7, P8, P28 P14, P16, P20 P24 = WiFi LED
ESP8685-WROOM-06 swap Reroute former P28 Reroute former P20 Pin #3 and #17 are NC

Key insight: The 2-gang and 3-gang Milfra switches use the same PCB family, but the 3-gang version needs two extra active lines. On an ESP8685-WROOM-06 swap, those lines cannot stay on pin #3 and pin #17 because both are NC. [#20841000]

Quick Facts

  • The documented 3-gang CBU mapping is P7 button1, P8 button2, P14 relay1, P16 relay2, P20 relay3, P24 WiFi LED, and P28 button3. [#20841000]
  • The documented 2-gang CBU mapping is shorter: P7 button1, P14 relay1, P20 relay2, P24 WiFi LED, and P28 button2. [#20841000]
  • The board-level labels differ by populated channel: on the 2-gang PCB, K1 = K5, so K5 acts as switch1 and K3 acts as switch2. [#20841000]
  • The ESP8685-WROOM-06 mod uses two jumper wires: pin #3 to GPIO6 on pin #10, and pin #17 to GPIO10 on pin #19. [#20841000]
  • ESP8685-WROOM-06 is described in the thread as using 15 GPIOs including RX and TX, while ESP32-C3 is noted as having 22 or 16 programmable GPIOs. [#20843917]

How do I map the GPIO pins for the 2-gang Milfra Tuya WiFi light switch with a CBU module?

Use this 2-gang map: P7 = Button1, P14 = Relay1, P20 = Relay2, P24 = WiFi LED, and P28 = Button2. This mapping matches the posted board notes for the Milfra Tuya 2-gang switch. It also aligns with the statement that the 2-gang and 3-gang boards share the same PCB family. [#20841000]

What is the correct GPIO template for the 3-gang Milfra Tuya WiFi light switch using the CBU/BK7231N module?

Use this 3-gang template: P7 = Button1, P8 = Button2, P14 = Relay1, P16 = Relay2, P20 = Relay3, P24 = WiFi LED, and P28 = Button3. "CBU module" is a Tuya radio module that provides Wi‑Fi control for the switch, uses BK7231N-based hardware here, and exposes the GPIO lines needed for buttons, relays, and the status LED. [#20841000]

How are the button and relay pins assigned differently between the 2-gang and 3-gang Milfra Tuya switch PCBs?

The 3-gang version adds one button line and one relay line. In practice, 3-gang uses P8 for Button2 and P16 for Relay2, then keeps P20 for Relay3 and P28 for Button3. The 2-gang version omits those extra active positions and uses P20 as Relay2 and P28 as Button2. [#20841000]

What is a CBU module in Tuya WiFi switches, and how does it relate to BK7231N-based hardware?

A CBU module is the original Tuya WiFi module fitted on these Milfra switches, and the thread treats it as the BK7231N-based platform used for the GPIO template. On this board, that module drives named pins such as P7, P14, P20, P24, and P28 for inputs, relays, and the WiFi LED. [#20841000]

How do I replace the CBU module in a Milfra Tuya light switch with an ESP8685-WROOM-06?

Replace the module only after remapping the two 3-gang-only signals away from ESP8685 NC pins. 1. Remove the original CBU module. 2. Fit the ESP8685-WROOM-06 with the required pinout adaptation. 3. Reroute former CBU pin P20 and P28 functions to working ESP GPIOs before testing. The thread states this swap requires modding because the pinouts differ. [#20841000]

Which jumper wire modifications are needed when swapping a CBU module for an ESP8685-WROOM-06 in the 3-gang Milfra switch?

Add two jumper wires. Connect pin #3, which carried CBU P20 for relay3, to GPIO6 on pin #10. Then connect pin #17, which carried CBU P28 for button3, to GPIO10 on pin #19. Those two moves restore the missing third relay and third button after the module swap. [#20841000]

Why do some pins on the ESP8685-WROOM-06 have no connection, and why would the module be designed that way?

Some pins are NC because the module does not expose every possible ESP32-C3 GPIO to the package edge. The thread explains that ESP32-C3 has 22 or 16 programmable GPIOs, while the ESP8685-WROOM-06 uses only 15 GPIOs including RX and TX. That leaves certain package pins intentionally unconnected. [#20843917]

What is the ESP8685-WROOM-06 module, and how does it differ from the original CBU module in Tuya wall switches?

ESP8685-WROOM-06 is the replacement module used in the mod, and it differs from CBU mainly by pinout and exposed I/O count. "ESP8685-WROOM-06" is an ESP32-C3-based module that provides Wi‑Fi control, but in this switch mod it leaves some package pins NC, so a straight one-for-one CBU replacement does not work. [#20843917]

CBU vs ESP8685-WROOM-06 for Milfra Tuya light switches: which module is better for reflashing and custom firmware?

The thread does not rank one module as better for reflashing or custom firmware. It only shows that CBU already matches the Milfra board, while ESP8685-WROOM-06 needs physical rework because pin #3 and pin #17 are NC. If you want the least hardware change, the original CBU footprint is the easier fit on this PCB. [#20841000]

What should I do with relay3 and button3 when the original CBU pins map to NC pins on the ESP8685-WROOM-06?

Reroute both signals to working GPIOs on the ESP8685-WROOM-06. Move relay3 from former CBU P20 on pin #3 to GPIO6 on pin #10. Move button3 from former CBU P28 on pin #17 to GPIO10 on pin #19. If you skip this step, the third relay and third button will not function. [#20841000]

How can I verify that the 2-gang and 3-gang Milfra Tuya switches use the same PCB before applying a GPIO template?

Compare the PCB layout and labels first. The thread states that the PCBs for the two switches are exactly the same, then confirms the 2-gang mapping by relating K1 to K5 and matching relay positions across both versions. If your board differs visually or by labels, do not apply the posted template unchanged. [#20841000]

Which GPIOs on the ESP8685-WROOM-06 are safe alternatives for rerouting P20 and P28 in this switch mod?

The proven alternatives in this mod are GPIO6 and GPIO10. Specifically, reroute P20 to GPIO6 on pin #10 and reroute P28 to GPIO10 on pin #19. The thread reports those exact substitutions on a working ESP8685-WROOM-06 conversion, so they are the documented choices for this board. [#20841000]

What problems can happen after replacing a CBU module with an ESP8685-WROOM-06 in a Tuya wall switch, and how do I troubleshoot them?

The main failure is losing relay3 or button3 because ESP8685 pin #3 and pin #17 are NC. Troubleshoot in three checks: 1. Confirm your switch is the same PCB family. 2. Verify pin #3 was rerouted to GPIO6 on pin #10. 3. Verify pin #17 was rerouted to GPIO10 on pin #19. Missing either jumper leaves the third channel inactive. [#20841000]

How do the K1, K3, and K5 PCB labels correspond to switch inputs on the Milfra 2-gang and 3-gang boards?

On the 2-gang board, K1 equals K5 by the PCB labeling described in the thread. That makes K5 act as switch1 and K3 act as switch2. This label relationship helps translate the shared PCB markings into the reduced 2-gang input layout without changing the base board design. [#20841000]

What safety precautions should I follow when soldering jumper wires and modifying mains-powered Milfra Tuya light switches?

The thread does not provide a full safety checklist, so keep the work limited to the documented pin changes and verify every pin number before soldering. At minimum, confirm that pin #3 and pin #17 on the ESP8685-WROOM-06 are NC, then route only to the stated replacements: pin #10 and pin #19. Unverified rewiring can break button3 or relay3 immediately. [#20841000]
Generated by the language model.
ADVERTISEMENT