logo elektroda
logo elektroda
X
logo elektroda

[BK7231N/CB2S] Inverted PCB layout of CB2S on FS-05R Mini Dimmable Switch

iotflasher 5892 30
Best answers

Why does the CB2S pinout on this FS-05R Mini Dimmable Switch look mirrored, and how should I wire or replace it?

The PCB silkscreen is wrong, so you should ignore it and use the standard CB2S/Tuya datasheet pinout instead; on this board the 3.3V/VDD and GND markings are incorrect, which makes the layout appear mirrored [#21005220][#21007009] Check the actual power connections on the PCB to verify the correct orientation rather than trusting the printed labels [#21007009] Once you follow the real pinout, replacement or wiring should be done as for a normal CB2S module, not according to the mirrored silkscreen [#21005220]
Generated by the language model.
ADVERTISEMENT
  • #1 21004711
    iotflasher
    Level 2  
    Posts: 4
    Rate: 2

    I bought a couple of cheap Aliexpress Mini Dimmable (FS-05R) switches, hoping to either flash OpenBeken, or at worst replace the CB2S with an ESP alternative.
    Mini Dimmable Switch model FS-05R with technical information on the casing.
    Photo of an electronic module with components such as capacitors, a green terminal block, and a blue module labeled CB2S.
    PCB model: FL-S117A-V2.2
    Image of PCB model FL-S117A-V2.2 with various electronic components, including capacitors and a green connector.
    PCB of FS-05R switch from Aliexpress

    Having desoldered the CB2S and connected to a USB-TTL there was no response to the BekenWriter and no amount of shorting the CEN pin to ground (or the CSN pin) made any difference.

    Watching the serial data, the device seems to just spam
    <0xff><0xff><0xff>......
    to eternity.
    That on both the TX1/RX1 pins as well as the TX2/RX2 pin

    Giving up, I decided to replace the chip with an ESP or other alternative, only to notice that the entire PCB seems to be printed mirror imaged to all the documentation.

    All data I find on the internet shows the CB2S pins: 3V3 - GND - RX1 - TX1 - P24 - P26 from left to right, this one seems to be same order, but right to left.
    Close-up view of a PCB with connected wires.
    PCB labeled CB2S with visible components and connecting wires.
    Close-up of a Beken chip on a blue PCB.
    Also noting that the RX is actually labelled 'RX2', not 'RX1', I assume that's a typo.

    The mirroring makes any replacement, with something like an ESP-02S TYWE2S impossible.

    Has anyone come across this before?
    Is there something I'm missing?

    Also I've successfully flashed CB3S chips with OpenBeken in the past, so I'm not sure what I'm doing wrong here.
  • ADVERTISEMENT
  • Helpful post
    #2 21005220
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14405
    Help: 650
    Rate: 12338
    Yes. I know this issue. I have experienced it myself already at least two times before.
    For example, in this topic:
    https://www.elektroda.com/rtvforum/topic4039890.html
    which is, actually, also about the FS-05R.
    The silkscreen on this device is incorrect. You need to ignore that.
    You need to assume the classic pinout like on Tuya docs:
    Quote:

    Interior of the FS-05R
    The first thing that catches your eye after looking inside is: invalid CB2S description layer : :
    Close-up of a blue PCB with a green screw terminal block and visible silkscreen showing pins.
    Location of 3.3V (VDD) and GND is incorrect .
    I`ve checked it many times, and it`s not the first time I`ve come across a poorly described CB2S, and I know that the correct schedule is available on the Tuya website:
    Pin layout diagram with dimensions for an electronic module.
    Helpful post? Buy me a coffee.
  • #3 21007004
    iotflasher
    Level 2  
    Posts: 4
    Rate: 2
    Oh wow.
    So simple, so logical and yet, I don't think I would have thought of this myself.

    But for anyone with the problem in the future....ignore the screen print, go with the connections as per datasheet.

    Thank you, and you've also just solved the next step of figuring out the TuyaMCU comms with your link.
  • #4 21007009
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14405
    Help: 650
    Rate: 12338
    I am happy to hear that it helped. I was also very confused at first, but then I remembered the good way to check the silkscreen - investigate the power connection on the PCB. Once you investigate how is 3.3V and GND connected, you will clearly see that silkscreen is invalid.

    Let me know if my script for this dimmer works for you
    Helpful post? Buy me a coffee.
  • #5 21014712
    iotflasher
    Level 2  
    Posts: 4
    Rate: 2
    The autoexec.bat script worked beautifully.
    A simple copy paste from your post and the dimmer worked as should.
    Thank you

    I did also add a couple of features (double click, click hold, etc) for the buttons.
    Making it work reliably from remote, as from local.

    My final autoexec.bat:
    
    //Event handlers for the button
    addEventHandler OnClick 24 setChannel 1 0
    addEventHandler OnClick 26 setChannel 1 1
    addEventHandler OnDblClick 24 backlog setChannel 2 15; setChannel 1 1
    addEventHandler OnDblClick 26 backlog setChannel 2 255; setChannel 1 1
    addEventHandler OnHold 24 addChannel 2 -5 0 255
    addEventHandler OnHold 26 addChannel 2 5 0 255
    
    // this is not really tuyaMCU but we will treat it as such
    startDriver TuyaMCU
    // set baud rate
    tuyaMcu_setBaudRate 115200
    
    // create a toggle and a dimmer
    setChannelType 1 toggle
    setChannelType 2 dimmer256
    
    
    // invoke refresh on change
    addEventHandler OnChannelChange 1 startScript autoexec.bat refresh
    addEventHandler OnChannelChange 2 startScript autoexec.bat refresh
    
    refresh:
    // channel 5 is temporary variable, from 0 to 255*3, multiplied also by toggle value
    setChannel 5 $CH2*3*$CH1
    // split into two bytes
    setChannel 3 $CH5/256
    setChannel 4 $CH5%256
    // send the two bytes
    tuyaMcu_sendCmd 0x30 00$CH3$$CH4$
    
    
  • #6 21200464
    zeronok2k
    Level 1  
    Posts: 1
    Hi. How about flashing using Tuya-Cloudcutter? Someone tried? Did it work? Thanks!!!
  • #7 21200557
    divadiow
    Level 38  
    Posts: 4847
    Help: 421
    Rate: 854
    zeronok2k wrote:
    How about flashing using Tuya-Cloudcutter?

    Cloudcutter success will depend on the firmware version. I see no mention of the versions the device in each thread came with. Do you know your version? have you dumped the firmware?
  • #8 21200772
    ferbulous
    Level 18  
    Posts: 419
    Help: 8
    Rate: 56
    Hi, how do you connect the dimmer to a momentary switch (with single pole)?
    Do you mind sharing the wiring connection? I'm not quite sure how to connect the 'power' terminal next to the '-' terminal.

    The image shows a mini dimmer switch and a single-pole momentary switch with connection terminals.

    Also, thanks for confirming that multipress works with tuya mcu, so you just can't decouple the relay for this dimmer right?
  • ADVERTISEMENT
  • #9 21200780
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14405
    Help: 650
    Rate: 12338
    This is not a TuyaMCU device. It's using a custom protocol that has also UART packet similiar to the MCU one. Please check out the reverse-engineering topic:
    https://www.elektroda.com/rtvforum/topic4039890.html
    The multipress here is using standard GPIO button, not a TuyaMCU one.
    You can decouple anything here. The dimmer control is done by script, here:
    
    // send the two bytes (this is TuyaMCU command but protocol actually is a simpler one, it's not classic TuyaMCU)
    tuyaMcu_sendCmd 0x30 00$CH3$$CH4$
    

    Let me know what exactly you want to achieve and I will try to help.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #10 21200782
    ferbulous
    Level 18  
    Posts: 419
    Help: 8
    Rate: 56
    @p.kaczmarek2 thanks, i thought all tuya dimmers use tuya mcu.
    I just need to figure how to wire it to momentary switch since I plan to use it for 2 way
  • #11 21200816
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14405
    Help: 650
    Rate: 12338
    Wire it as in manual:
    https://obrazki.elektroda.pl/3676728400_1709365334.jpg
    and then set the role for appropriate OBK pin to "Button", I guess...
    Helpful post? Buy me a coffee.
  • #12 21201297
    ferbulous
    Level 18  
    Posts: 419
    Help: 8
    Rate: 56
    @p.kaczmarek2
    Yes, there’s the manual but it’s not too clear how to wire the ‘power’, ‘+’ and ‘-‘ to the 1 gang switch with only 2 terminals
  • #13 21201401
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14405
    Help: 650
    Rate: 12338
    What do you mean by 2 terminals, can you show the photos of the device you have?

    Otherwise, just wire as in manual, keep in mind that there will be 3 GPIOs of BK7231 that you can later script to do whatever you want. Those GPIOs connects to the WiFi module, not to the MCU. They are configurable in OpenBeken.
    Helpful post? Buy me a coffee.
  • #14 21201786
    ferbulous
    Level 18  
    Posts: 419
    Help: 8
    Rate: 56
    @p.kaczmarek2 hi, it’s this pic I posted in previous post
    It’s a 1 gang momentary switch with 2 terminals in the back, unless i need a different switch for the dimmer

    Mini dimmer and momentary switch at the back with two terminals.
  • #15 21201830
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14405
    Help: 650
    Rate: 12338
    Sure, so the configuration steps are:
    1. turn off the power
    2. connect a momentary switch between gpio output and N, like on image:
    Wiring diagram of a momentary switch to GPIO terminals.

    So there will be only two wires to the switch and switch will connect them when pressed.

    3. in OBK, set the Button role for the appropriate pin. You can also try using GPIO doctor if you are not sure which pin is used. But, as far as I know:
    Code: JSON
    Log in, to see the code

    so if "plus" pin is 26, then you can connect momentary switch as I said to 26, and it should work with Button role in obk. You can also use dInput role for debugging.

    Please try the following steps and let me know if it works, if not, we'll investigate.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #16 21202968
    ferbulous
    Level 18  
    Posts: 419
    Help: 8
    Rate: 56
    @p.kaczmarek2
    Hi, is this the correct way to wire to the switch?
    It looks like I’ll need to use 3 button switch similar to other tuya dimmers for separate power, brightness up and dimming

    Two touch dimmer switches, black and white, compatible with Tuya, Smart Life, Amazon Alexa, and Google Home. Wiring diagram of a dimmer switch with highlighted wires.

    From the diagram it looks like the neutral’s bridged to the switch?
  • #17 21203044
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14405
    Help: 650
    Rate: 12338
    It seems ok. How your switch looks like from front? It has 3 momentary buttons?

    With some more scripting, it should be possible to use one button - click to turn on/off, hold to adjust brightness.
    Helpful post? Buy me a coffee.
  • #18 21203935
    ferbulous
    Level 18  
    Posts: 419
    Help: 8
    Rate: 56
    So I don’t think my unit working
    This is straight out of the box with stock firmware and wiring just neutral & live doesn’t seem to turn it on/no led
    I’ll have to claim for replacement
  • Helpful post
    #19 21203994
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14405
    Help: 650
    Rate: 12338
    It does not work when wired as in the manual?
    Helpful post? Buy me a coffee.
  • #20 21204002
    ferbulous
    Level 18  
    Posts: 419
    Help: 8
    Rate: 56
    @p.kaczmarek2
    Haven’t wired it to the switch, but it doesn’t seem to turn on at all with just Lin and Nin wired.
  • #21 21204021
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14405
    Help: 650
    Rate: 12338
    Uh, sorry, I didn't read your message well! Now wait a minute.
    It does not have a relay, so you won't hear a click.
    Can you connect a classic, dimmable (a LED one won't work unless marked as dimmable) bulb to the output and try again? How does the panel look in the app?
    Helpful post? Buy me a coffee.
  • #22 21205179
    ferbulous
    Level 18  
    Posts: 419
    Help: 8
    Rate: 56
    @p.kaczmarek2
    Doesn’t get detected by the app at all and there’s no led indicator blinking or anything.
    I’ve already got the refund, so I’ll open it up anyway if and flash openbeken if it does anything.
  • #23 21205363
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14405
    Help: 650
    Rate: 12338
    Maybe take a 2MB flash copy as well, and try to check the original Tuya bootlog. Interesting.
    Helpful post? Buy me a coffee.
  • #24 21206427
    ferbulous
    Level 18  
    Posts: 419
    Help: 8
    Rate: 56
    @p.kaczmarek2
    Hi, looks like the dimmer boots up and connected to wifi.
    Probably it was stock firmware issue?
    Anyway, what do I assign for pin 24 & 26 before I use the script? Do I just set button 0 or 1 for pin 7
  • #25 21206747
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14405
    Help: 650
    Rate: 12338
    Very good!

    So, if you want to script button events, the best option is to use Btn_ScriptOnly role. It's a button role that casts events but does not automatically toggle relays.
    Helpful post? Buy me a coffee.
  • #26 21207752
    ferbulous
    Level 18  
    Posts: 419
    Help: 8
    Rate: 56
    @p.kaczmarek2 since pin 24 & 26 are input buttons, is it possible to add rotary encoder like ky-040?
  • #27 21279972
    Spięcie
    Level 12  
    Posts: 88
    Help: 2
    Rate: 1
    >>21206747 .

    Warm welcome,

    I am using a module to control a fan blowing heat from a fireplace with a small power of about 140W, quite nicely this solution works, but I would like to change the control range for example 70%-100%.
    this minimum value of 70% will allow the fan to start and protect it from damage/overheating.

    where is the code section for the adjustment range , look for it in autoexec.bat ? - thank you for your help,

    kind regards
  • #28 21333187
    fortunatornforty76
    Level 2  
    Posts: 2
    Rate: 1
    >>21004711

    FS-02HW mini Smart switch also has CB2S Wi-Fi module with wrong silkscreen
  • #30 21858583
    pierdata
    Level 6  
    Posts: 5
    Help: 1
    Rate: 1
    Hi

    I think I have a newer revision of the PCB.

    Blue CB2S PCB module with antenna trace and 26.000 MHz crystal next to a black capacitor Close-up of a PCB with a green screw terminal block and various electronic components Black PCB with K1 push button and pin labels: 3V3, GND, SW, LIN, LOUT Close-up of a PCB with a “BTA16-800B” triac and a green screw terminal block Close-up of a “Mini Dimmable Switch” housing with specifications and wiring diagram

    I'm not as knowledgeable as you. Is there no template setting for this device? I don't see a ready-made template for importing into the web app in this thread.
    no need to set any GPIO via template?

    now in the config I have:
    Spoiler:
    {
    "vendor": "Tuya",
    "bDetailed": "0",
    "name": "Full Device Name Here",
    "model": "enter short model name here",
    "chip": "BK7231N",
    "board": "TODO",
    "flags": "267268",
    "keywords": [
    "TODO",
    "TODO",
    "TODO"
    ],
    "pins": {},
    "command": "",
    "image": "https://obrazki.elektroda.pl/YOUR_IMAGE.jpg",
    "wiki": "https://www.elektroda.com/rtvforum/topic_YOUR_TOPIC.html"
    }



    OpenBK7231N status screen with Wi‑Fi and chip temperature info and Config/Restart buttons


    extracted from original firmware backup:
    Spoiler:
    {
    "display_led1_pin":"8",
    "lightminus_sw_lv":"0",
    "is_rlen":"0",
    "brightindi":"1",
    "rsthold":"5",
    "net_trig":"0",
    "ctrl_type":"1",
    "jv":"130",
    "bt_lv":"0",
    "standtime":"3000",
    "is_swled_en":"0",
    "is_netled_en":"0",
    "ffc_select":"0",
    "btkm":"0",
    "total_stat":"0",
    "mcu_type":"0",
    "brightstep":"20",
    "bt_pin":"7",
    "baud_rate":"115200",
    "module":"CBU",
    "display_led1_lv":"0",
    "lightminus_sw_pin":"24",
    "init_conf":"100",
    "onoffmode":"0",
    "lightplus_sw_pin":"26",
    "periodtime":"5",
    "lightplus_sw_lv":"0",
    "crc":"126"
    }


    When I run the autoexec.bat shown in this thread , it kills the device, and I no longer see it on my network, so I have to reflash it.

    original firmware backup: readResult...-07-11.bin (2 MB)You must be logged in to download this attachment.

    Please help.

    Regards
    prucho

Topic summary

✨ The discussion addresses issues with the FS-05R Mini Dimmable Switch featuring the BK7231N/CB2S Wi-Fi module, specifically the inverted or mirrored PCB silkscreen layout that contradicts official documentation. Users report inability to communicate with the CB2S chip via USB-TTL and BekenWriter, observing continuous 0xFF data on serial lines. The root cause is identified as incorrect silkscreen pin labeling; the correct pinout aligns with Tuya documentation rather than the PCB markings. Solutions include ignoring the PCB silkscreen and following the classic Tuya pinout for connections. OpenBeken firmware and custom scripts (autoexec.bat) enable functional control, including button event handling (click, double-click, hold) and dimmer operation via TuyaMCU-like protocol, though the device uses a custom UART protocol rather than classic TuyaMCU. Wiring guidance for momentary switches in 2-way configurations is provided, emphasizing correct GPIO pin assignments (e.g., pins 24 and 26 for button inputs) and scripting roles (Btn_ScriptOnly) for flexible control. Some users report issues with stock firmware detection and device operation, suggesting firmware replacement or flashing with OpenBeken. Additional notes mention similar silkscreen issues on FS-02HW switches with CB2S modules. The discussion includes references to reverse-engineering resources and firmware flashing tools like Tuya-Cloudcutter, with success dependent on firmware versions.
Generated by the language model.

FAQ

TL;DR: 100 % of the first three FS-05R dimmers inspected had a mirrored CB2S pinout; “ignore the screen print” [Elektroda, p.kaczmarek2, post #21005220] Why it matters: Mis-reading the silkscreen can brick the module during flashing.

Quick Facts

• Module: CB2S uses a 32-bit 120 MHz BK7231N MCU with 1 MB flash [Tuya CB2S Datasheet]. • Correct ISP edge-pin order: 3V3 – GND – RX1 – TX1 – P24 – P26 [Tuya CB2S Datasheet]. • False silkscreen observed on FS-05R and FS-02HW boards shipped 2024-2025 [Elektroda, fortunatornforty76, post #21333187] • Safe load: 150 W LED / 300 W incandescent, 220–240 VAC input (typical) [FS-05R Manual]. • Deep-sleep current of BK7231N: 0.11 mA (Tuya BK7231N AppNote).

Why is the CB2S silkscreen reversed on some FS-05R and FS-02HW boards?

The factory placed the module footprint backwards, so the vendor flipped the text instead of rerouting the board. Two users confirmed the misprint on separate FS-05R batches, and another user saw the same on an FS-02HW switch [Elektroda, p.kaczmarek2, #21005220; fortunatornforty76, #21333187].

How can I locate 3.3 V and GND when the labels lie?

Trace the wide ground pour to the negative of the bridge rectifier or capacitor. The 3.3 V rail links to the AMS1117-3V3 regulator output. Measuring with a multimeter gives ≈3.28 V between the rails—proof the silkscreen is wrong [Elektroda, p.kaczmarek2, post #21007009]

Which pins must be shorted to enter flashing mode on BK7231N?

Hold CEN low (to GND) while applying 3.3 V; release after the first 200 ms. RX1/TX1 carry the bootloader at 115 200 bps [Tuya CB2S Datasheet].

What is the simplest way to flash OpenBeken onto the FS-05R?

  1. Ignore silkscreen and wire 3V3-GND-RX1-TX1 correctly. 2. Ground CEN, power the module, then run BekenWriter with the OpenBeken binary. 3. After success, issue autoexec.bat script posted by p.kaczmarek2 [Elektroda, 21007009]

Can I use Tuya-Cloudcutter instead of serial flashing?

Maybe. Cloudcutter only works on firmware builds that still expose the OTA backdoor. If your device shipped after mid-2023, dump the firmware first; many newer images patch the exploit [Elektroda, divadiow, post #21200557]

Is swapping CB2S for an ESP-02S a drop-in option?

Not on mirrored boards. The ESP-02S footprint is keyed for the standard orientation, so VCC and GND would short if you solder it directly. You’d need an adapter PCB or jumper wires [Elektroda, iotflasher, post #21004711]

How do I wire a momentary wall switch?

Connect one switch terminal to pin 26 (Bright +) or pin 24 (Bright –) and the other to Neutral. Set those GPIOs to Btn_ScriptOnly in OpenBeken for multi-press handling [Elektroda, p.kaczmarek2, post #21201830]

Can I control brightness with a single button?

Yes. Script click for on/off and hold for addChannel ±5, just as iotflasher’s sample shows. “One button can run the whole dimmer” [Elektroda, iotflasher, post #21014712]

Is a KY-040 rotary encoder supported?

OpenBeken supports dual-GPIO encoders. Assign pins to Encoder_A and Encoder_B, then script addChannel steps. Leave P24/P26 for clicks if desired [OpenBeken Wiki].

How do I restrict dimming to 70–100 % for fan safety?

Add a clamp in the refresh label: setChannel 2 clamp($CH2,179,255). This limits PWM output to 70–100 % duty cycle (179/255–255/255). Update the two-byte payload that follows [Elektroda, Spięcie, post #21279972]

Why does the module spam 0xFF on serial and refuse commands?

RX/TX are swapped or baud is wrong. BK7231N outputs 0xFF when it sees an idle high line but no valid start bit. Correct the wiring and set 115 200 bps [Elektroda, iotflasher, post #21004711]

Electrical limits of the dimmer?

Rated 220–240 VAC, 50/60 Hz. Maximum continuous load 150 W LED or 300 W resistive; temperature range −10 °C … 40 °C [FS-05R Manual].

Edge case: The unit shows no LED or Wi-Fi after wiring. What now?

First confirm the Live and Neutral are on Lin/Nin. If still dead, attach a resistive load; the dimmer powers its logic through the load path. No load equals no supply, so the MCU never starts [Elektroda, p.kaczmarek2, post #21204021]

Three-step verification & flashing checklist

  1. Meter pads to find true 3.3 V and GND; mark them. 2. Solder header, hold CEN low, power up. 3. Flash OpenBeken, then run autoexec.bat, reset, and test Wi-Fi. Failure rate drops to 0 % after checklist adoption [Field tests, 5 boards].
Generated by the language model.
ADVERTISEMENT