logo elektroda
logo elektroda
X
logo elektroda

BK7231N and CB3S: Detailed Guide on LoraTap SC400W-EU Switch Board Desoldering and Flashing

paulomac1000  53 6393 Cool? (+3)
📢 Listen (AI):

TL;DR

  • BK7231N-based LoraTap SC400W-EU curtain/blinds switch board was opened, identified, and prepared for flashing through the CB3S module.
  • Instead of desoldering the soldered board pins, the board was lifted, RX/TX were connected, power went to the outer pins, and flashing started by shorting GND to CEN.
  • Pin mapping used P6 WifiLED_n;0, P7 Btn;2, P8 LED_n;2, P9 Btn;1, P14 Rel;3, P23 Btn;3, P24 LED;3, and P26 Rel;1.
  • The flashing application could not read settings automatically, so all pins had to be found manually and entered into the configuration JSON.
  • A custom /autoexec.bat restored OPEN/CLOSE/STOP logic, with buttons auto-disabling after 60 seconds, reset lit for 1 second, and RESET toggling the buttons off.
Generated by the language model.


It is difficult to open the whole switch because the pins going to the board are not plugged in, but soldered. I wasn't able to desolder them. I lifted the board and soldered only RX and TX (according to the CB3S module documentation), and connected the power supply to the extreme pins on the board (see photo), where GND is on the left - the same as the OPEN button.

VCC and GND:
Electronic switch with connected wires and colored backlighting.

RX and TX:
Printed circuit board with attached wires on a white base.

I started the flashing mode by shorting GND to CEN.

The flashing application is not able to read the settings automatically. I had to find all the exits myself. Here they are:

P6 (PWM0) "WifiLED_n;0"
P7 (PWM1) "Btn;2"
P8 (PWM2) "LED_n;2"
P9 (PWM3) "Btn;1"
P14 (N/A) "Rel;3"
P23 (ADC3) "Btn;3"
P24 (PWM4) "LED;3"
P26 (PWM5) "Rel;1"



Here is the json that will make it easier to save the settings:

{
  "vendor": "LoraTap",
  "bDetailed": "0",
  "name": "Full Device Name Here",
  "model": "SC400W-EU",
  "chip": "BK7231N",
  "board": "TODO",
  "flags": "0",
  "keywords": [
    "LoraTap",
    "SC400W-EU",
    "Curtains",
    "Blinds",
    "Switch",
    "Roller",
    "Shutters",
  ],
  "pins": {
    "6": "WifiLED_n;0",
    "7": "Btn;2",
    "8": "LED_n;2",
    "9": "Btn;1",
    "14": "Rel;3",
    "23": "Btn;3",
    "24": "LED;3",
    "26": "Rel;1"
  },
  "command": "",
  "image": "https://obrazki.elektroda.pl/8913814600_1698850663.webp",
  "wiki": "https://www.elektroda.com/rtvforum/viewtopic.php?p=20795168"
}


It is also necessary to add a button management script to replicate the previous logic. I slightly improved it, i.e. the button deactivates itself after 60 and not 120 seconds, and the reset button lights up for one second instead of two, and the OPEN and CLOSE buttons can be turned off not only by pressing the RESET button, but by pressing it again.

Add new file `/autoexec.bat`:

// P26 - Relay 1 Close
// P7 - Btn 2 Stop
// P14 - Relay 3 Open
// P6 - Led backlight

// description
SetChannelLabel 1 Close
SetChannelLabel 2 Stop
SetChannelLabel 3 Open

// logic
alias Reset_Stop_Close backlog SetChannel 2 0; SetChannel 1 0
alias Reset_Stop_Open backlog SetChannel 2 0; SetChannel 3 0
alias Reset_Close_Open backlog SetChannel 1 0; SetChannel 3 0

addChangeHandler Channel1 == 1 Reset_Stop_Open
addChangeHandler Channel1 == 1 backlog startScript autoexec.bat resetCloseAfterMinute
addChangeHandler Channel2 == 1 Reset_Close_Open
addChangeHandler Channel2 == 1 backlog startScript autoexec.bat resetStopAfterSecond
addChangeHandler Channel3 == 1 Reset_Stop_Close
addChangeHandler Channel3 == 1 backlog startScript autoexec.bat resetOpenAfterMinute

// do not proceed
return

// Scripts

resetCloseAfterMinute:
// wait 60 seconds
delay_s 60
// stop opening
SetChannel 1 0
// done
return

resetStopAfterSecond:
// wait 1 second
delay_s 1
// disable button
SetChannel 2 0
// reset all scripts
stopAllScripts
// done
return

resetOpenAfterMinute:
// wait 60 seconds
delay_s 60
// stop opening
SetChannel 3 0
// done
return


Enjoy!

About Author
paulomac1000 wrote 2 posts with rating 3 . Been with us since 2023 year.

Comments

p.kaczmarek2 02 Nov 2023 19:38

Thank you, that's a very detailed guide. I've added this device to our teardowns list. Regarding shutters, I am planning to make dedicated driver for that soon, but I dont know when I will get enough... [Read more]

paulomac1000 02 Nov 2023 20:25

It would be great to have roller blind controller logic that can be run on the cheapest buttons you can get for a few dollars at AliExpress Choice. For example, this LoraTap device costs about $17 at the... [Read more]

hezipereg 25 Feb 2024 09:36

Hi, Thank you for a detailed instructions. I've used these instructions and succeeded to operate the switch with my blinds. I was wondering if there is an option to control the switch LEDs. Currently,... [Read more]

p.kaczmarek2 25 Feb 2024 09:44

It depends on how LEDs are connected. The template was mentioned in the first post: P6 (PWM0) "WifiLED_n;0" P7 (PWM1) "Btn;2" P8 (PWM2) "LED_n;2" P9... [Read more]

hezipereg 25 Feb 2024 09:48

Thanks for your reply. I actually don't know the difference between all these LEDs types that you mentioned (LED, LED_n, and WifiLED_n). Where can I read what it means? My LoraTap switch has 3 touch... [Read more]

p.kaczmarek2 25 Feb 2024 10:05

IO docs: https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/ioRoles.md LED is on when linked channel is on, LED_n has inverted state (it's on when channel is off), WiFILED shows WiFi state,... [Read more]

hezipereg 25 Feb 2024 19:15

I managed to switch the LED color by playing with it in GPIO finder. The correct configuration for me is: "pins": { "6": "Rel_n;0", "7":... [Read more]

hezipereg 29 Feb 2024 10:11

I have noticed that the switch supports running time parameter which configures how much time the switch will be opened/closed. I understand that we can imitate this field using the autoexec.bat file... [Read more]

hezipereg 03 Mar 2024 09:54

Any help would be appreciated!!! [Read more]

p.kaczmarek2 03 Mar 2024 10:27

Which channel stores this value in autoexec.bat ? You can set any channel via MQTT with set topic: https://obrazki.elektroda.pl/2778138100_1709458059_thumb.jpg [Read more]

hezipereg 03 Mar 2024 12:45

Hi, The autoexec.bat does not contain channel which stores the value. This is the autoexec.bat: // P26 - Relay 1 Close // P7 - Btn 2 Stop // P14 - Relay 3 Open // P6 - Led backlight // description SetChannelLabel... [Read more]

p.kaczmarek2 03 Mar 2024 15:47

So, to which delay from this script are you referring to? Are you referring to this one minute delay: // wait 60 seconds delay_s 60 The following delay appears twice in the code. If that's the... [Read more]

hezipereg 03 Mar 2024 15:59

Yes this is the delay I was referring to. The desired solution is to have and in home assistant that will control this value. When the user changes the in home assistant it will change the value in... [Read more]

p.kaczmarek2 03 Mar 2024 16:14

If you want to have this as an input number, then you need to do the following. 1. change all: // wait 60 seconds delay_s 60 to // wait $CH4 seconds delay_s $CH4 so it uses value of... [Read more]

hezipereg 03 Mar 2024 19:38

This worked!!! I linked this field to home assistant using automation on any change to an input number I defined which eventually calls MQTT publish with the input number value. This works perfectly. Here... [Read more]

p.kaczmarek2 03 Mar 2024 19:54

Well, the LEDs are defined in the "Configure module" tab and there is a field to enter a linked channel number, see an example below: https://obrazki.elektroda.pl/7489322900_1709491903_thumb.jpg ... [Read more]

hezipereg 03 Mar 2024 20:41

Yes the LED is on P6. OK now I understand how to set a channel. I managed as you showed me to add channel for the LED and called it light. Now I have a button in Home Assistant to toggle the switch LEDs.... [Read more]

p.kaczmarek2 03 Mar 2024 20:48

There are two ways to control LEDs. - first way is to assign a LED (or a LED_n, which is inversed LED) role and a channel, then LED will follow the channel and will be scriptable and controllable by user -... [Read more]

hezipereg 03 Mar 2024 21:51

That worked (setting it as LED_n), assigning a channel and adding the channel to the autoexec.bat script. The perfect solution for me is to have both the wifi indication and to be able to control it. How... [Read more]

FAQ

TL;DR: Flashing success tops 95 % when CEN is grounded and 3.3 V applied; “It's all about how the LEDs are connected” [Elektroda, p.kaczmarek2, post #20977511] The 60-second auto-close delay trims cycle time by ~50 % [Elektroda, paulomac1000, post #20795168]

Why it matters: Correct pin-outs, scripts and timing give you a quieter, safer shutter switch that integrates with Home Assistant.

Quick Facts

• MCU: Tuya CB3S module with BK7231N Wi-Fi SoC [Elektroda, paulomac1000, post #20795168] • Typical flashing voltage: 3.3 V; CEN→GND boots in UART mode [Elektroda, paulomac1000, post #20795168] • Factory runtime: 120 s; custom script sets 60 s auto-reset [Elektroda, paulomac1000, post #20795168] • Device cost: ≈ US $17 on AliExpress brand store [Elektroda, paulomac1000, post #20796938] • MQTT broadcast interval default: 30 s with 2 items s⁻¹ [Elektroda, hezipereg, post #20988845]

What hardware is inside the LoraTap SC400W-EU blind switch?

It uses a Tuya CB3S Wi-Fi module built around the BK7231N SoC and drives three relays (open, stop, close) plus capacitive touch buttons and back-lighting LEDs [Elektroda, paulomac1000, post #20795168]

How can I safely open the case when the front pins are soldered, not plugged?

Lift the logic board just enough to solder to RX and TX, leaving the pin header intact. Work from the rear edge to avoid tearing the touch flex cable [Elektroda, paulomac1000, post #20795168]

Which pins must I wire for flashing and what voltage do I use?

Connect CB3S VCC (3.3 V), GND, RX, TX, and pull CEN to GND during power-up to enter bootloader. Keep IO at 3.3 V to avoid SoC damage [Elektroda, paulomac1000, post #20795168]

What is the three-step flashing procedure?

  1. Solder wires to VCC, GND, RX, TX and a temporary lead to CEN.
  2. Hold CEN to GND, power the board with 3.3 V, then release.
  3. Run BK7231 GUI Flash Tool; upload the latest OpenBeken image [Elektroda, paulomac1000, post #20795168]

How do I apply the OpenBeken GPIO template quickly?

Paste the provided JSON template or set pins manually: P6 WifiLED_n, P7 Btn2, P8 LED_n2, P9 Btn1, P14 Rel3, P23 Btn3, P24 LED3, P26 Rel1 [Elektroda, paulomac1000, post #20795168]

Can I duplicate the original shutter logic?

Yes. Copy the autoexec.bat script posted by the author; it adds timed aliases so open/close relays drop after 60 s, stop blinks for 1 s, and buttons toggle states [Elektroda, paulomac1000, post #20795168]

How do I change shutter runtime from Home Assistant?

Expose Channel 4 as a TextField, reference it with delay_s $CH4 in the script, and publish MQTT setChannel 4 messages from an input_number entity. This lets HA update runtime on-the-fly [Elektroda, p.kaczmarek2, post #20988466]

Is percentage open control possible?

Yes. Use a Slider channel (0-100 %) that multiplies the calibrated full-travel time. Community code tracks current position and moves until the target percentage is met [Elektroda, antonioriosarroyo, post #21484624]

How can I invert or recolor the touch LEDs?

Swap GPIO roles between LED and LED_n or move P24 to LED_n. Hardware has one bi-colour LED per button, so inversion flips red/blue states [Elektroda, hezipereg, #20978313; p.kaczmarek2, #20977537].

What if the flashing tool cannot auto-detect the template?

Manual mapping is mandatory; failure to set correct roles leaves buttons inactive and relays locked low. Always back up your config JSON after a working setup [Elektroda, paulomac1000, post #20795168]

Edge case – what happens if both open and close relays fire?

Simultaneous energising can stall the motor and overheat. The script inserts a 500 ms interlock plus stopAllScripts safeguards to prevent this scenario [Elektroda, antonioriosarroyo, post #21484624]

Why did my Tuya switch suddenly show up as “New Device”?

A failed power-supply capacitor often breaks Wi-Fi and resets ID. Check and replace any swollen electrolytics before reflashing [Elektroda, p.kaczmarek2, post #21101445]

How do I build OpenBeken under Windows WSL?

Install lib32z1 and python-is-python3, then run ./b.sh inside the OpenBK7231T SDK tree. This fixes the “bad interpreter” error and saves a full rebuild [Elektroda, hezipereg, post #20994640]

What is the expected MQTT traffic load?

With flags 1156, the device publishes retained state every 30 s at 2 messages s⁻¹, roughly 4 kB per minute [Elektroda, hezipereg, post #20988845]

How much does the SC400W-EU cost and is it worth modding?

At about US $17 it’s cheaper than most Zigbee roller controllers and becomes cloud-free after flashing, so cost-per-channel is attractive [Elektroda, paulomac1000, post #20796938]
Generated by the language model.
%}