Detailed guide on how to flash the new Tuya Beken Chips with OpenBK7231T

Hi everyone,

I was walking past Aldi yesterday, noticed the Casalux Corner Floor Lamp and ended up buying one. I tried using tuya-Cloudcutter, and there’s a device listed as Casalux Corner Lamp under Aldi, but the exploit didn’t work for me. I’m not even sure if it went into slow blink mode, as that didn’t happen, and the tool indicated that the exploit failed.

I have a quick question: Am I right in assuming that tuya has patched their newer modules, making this exploit no longer effective?

I’ve included a few photos of the board. If I need to flash it using a serial adapter, can I use the test points on the PCB without having to desolder the chip?

By the way, the chip is a Lightning LN882HKI.



Any help would be appreciated. Thanks.

I am not sure this model of chip is coveted by libretiny platform. BK723x is covered by that that too specific version of firmwares and not all. Refer here.

Hi, that’s not beken
You can flash with openbeken with this instructions

Hi, please has anyone flashed this switch?
Wifi Switch Module DC7-32V RF Receiver

Here it says here that flash is possible, but it is no more possible to add RC transmitters.
Thank you.

Hey I’ve managed to flash the same “Deta SMART rewireable plug (6930HA Series2)” using tuya-cloudcutter. I used the same firmware: 1.1.8 - BK7231T / oem_bk7231s_rnd_switch

I’m curious how you got ESPHome onto the device or how you uploaded this config to it. I thought this wasn’t an ESP chip?

I’d ideally like to run something like esphomekitdevices (HAA) on it instead to save needing a Home Assistant middleman with the OpenBK7231T firmware.

Any pointers would be greatly appreciated.

I create a device in esphome Download file to pc and
then copy to tuya-convert binary install folder.
Update your device (I think its option 3).
Select device binary and install.

The later versions of esphome can compile these new chips

My config for that device:

# Basic Config
# https://www.bunnings.com.au/deta-smart-plug-base-with-grid-connect_p0098817
substitutions:
  device_name: "deta_smartplug_1"
  name: "Deta Smartplug 1"

esphome:
  name: ${device_name}
  comment: ${name}

bk72xx:
  board: wb2s
  framework:
    version: dev

wifi:
  networks:
    - ssid: !secret wifi_ssid
      password: !secret wifi_password
    - ssid: SSID Secondary
      password: Password
  ap:
    ssid: ${device_name}AP
    password: !secret ap_password 

captive_portal:

logger:
  #level: VERBOSE

api:
  encryption:
    key: "Key generated by esphome"
ota:
- platform: esphome
  password: !secret ota-password  

web_server:
  port: 80

time:
  - platform: homeassistant
    id: homeassistant_time

output:
  - platform: libretiny_pwm
    id: blue_led_output
    pin:
      number: P6
      inverted: True

light:
  - platform: monochromatic
    name: ${device_name} Blue LED
    output: blue_led_output
    id: blue_led
    internal: True

sensor:
  - platform: uptime
    name: ${device_name} Uptime

  - platform: wifi_signal
    name: ${device_name} Wifi Signal
    update_interval: 60s

text_sensor:
  - platform: version
    name: ${device_name} ESPhome Version
  - platform: wifi_info
    ip_address:
      name: ${device_name} IP

binary_sensor:
  - platform: gpio
    pin:
      number: P11
      inverted: True
    id: button
    name: ${device_name} Button
    on_press:
      - switch.toggle: relay_template
    internal: True

switch:
  - platform: gpio
    pin: P26
    id: relay

  # tie the led & relay operation together and report status based on relay state
  - platform: template
    name: ${device_name} Relay
    id: relay_template
    lambda: |-
      if (id(relay).state) {
        return true;
      } else {
        return false;
      }
    turn_on_action:
      - light.turn_on: blue_led
      - switch.turn_on: relay
    turn_off_action:
      - light.turn_off: blue_led
      - switch.turn_off: relay

Is your device creating its own Access Point? If so, just connect to that and upload the binary. As @pencilhead said, libretuya was merged with esphome so very easy to do. If it helps these are my notes from when they were separate projects. You should only have to do steps 2, 3, 4, & 8.

2\ Go +New Device, Continue, enter a name, select BKxx, and select board type.

3\ We now have a basic YAML file. It's highly recommended to always include the web_server
   and captive_portal components - even in your first "empty" upload. "use_address" will
   be used later. For initial config I enter the actual ssid & pword.

# Enable web server
web_server:
  port: 80

# Enable Home Assistant API
api:

ota:
  safe_mode: true

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: true
  power_save_mode: none
  manual_ip:
    static_ip: !secret ip_antbms1
    gateway: !secret ip_gateway
    subnet: !secret ip_subnet
    dns1: !secret ip_dns1
  #use_address: 192.168.1.28

  # Enable fallback hotspot in case wifi connection fails
  ap: {} # This spawns an AP with the device name and mac address, no password.
    #ssid: "Power-Switch1 AP"
    #password: "password"

captive_portal:

4\ Save the yaml and close. Using the 3 dots, select Install, Manual download, and select Modern Format.
   This will save the binaries on the RPi.

5\ Connect to the RPi using WinSCP. Navigate to the root and then opt folder. Do a search for *ug.bin and
   then Focus on the result to enter the folder. Drag the required *ug.bin file to the local desktop and rename
   to something meaningful. Navigate back to "/home/janos-pi/tuya-cloudcutter/custom-firmware" and drag the
   bin file into this folder.

6\ SSH into the RPi and navigate to "/home/janos-pi/tuya-cloudcutter".

7\ We first need to cut the device from Tuya cloud using tuya-cloudcutter.
   -execute sudo ./tuya-cloudcutter.sh -s ssid pword -w wlan0
    follow the prompts until completion. Device will now be local.
   -execute sudo ./tuya-cloudcutter.sh -w wlan0 -f esphome.bin (or whatever the bin filename is)
    follow the prompts until completion. Device will now have custom firmware loaded.

8\ If it fails for whatever reason and doesn't connect to local network then it should create its own
   Access Point. Use the phone to connect to this AP and load http://192.168.4.1/. From here your
   can reenter WiFi credentials and/or load new firmware.

9\ If it works then the device will connect to local network and be discovered by ESPHome.

Hi Caleb,
I mucked about and got the 6931HA working with this yaml…

esphome:
  name: "light-switch"
  friendly_name: Light Switch

bk72xx:
  board: generic-bk7231n-qfn32-tuya

# Enable logging
logger:
  level: DEBUG

web_server:

captive_portal:

mdns:

# Enable Home Assistant API
api:
  encryption:
    key: "*************************YourKey"

ota:
  - platform: esphome
    password: ""

wifi:
  networks:  
  - ssid: !secret wifi_ssid
    password: !secret wifi_password
  power_save_mode: none

text_sensor:
  - platform: libretiny
    version:
      name: LibreTiny Version

binary_sensor:
  - platform: gpio
    id: binary_switch_1
    pin:
      number: P26
      inverted: true
      mode: INPUT
    on_press:
      then:
        - switch.toggle: switch_1

switch:
  - platform: gpio
    id: switch_1
    name: Relay 1
    pin: P6

status_led:
  pin:
    number: P8
    inverted: false      

Hey fine people. I’ve had an S2 6294HA running with ESPHome for a year or so after using cloud cutter. I can no longer access it, i see it connect to my unifi router, but can’t ping etc. I can’t flash it therefore via OTA. Others with strange wifi issue say a bad flash, but it has been working. Maybe the memory got corrupted?

Any software ideas to resolve. I’m trying to enable safe mode, but not sure the ‘right way’ to reset it 10 times.

I was thinking of soldering on wires to use with the usb adapter, but I think I read i need to cut traces etc. which is likely beyond my capability.

Is it worth trying to remove the small PCB with the WB2S on? and flash it that way??If I do this, should I then just replace it with a real ESP???

Keen to get your thoughts.

I had a switch with cb3s that just stopped responding. Serial flashed it with esphome and openbeken and it’s just not booting at all. Ended up just swapping it with esp

Since when, ie did an event occur? (Update, power failure, etc?)

I have a 6294HA (external double power point?) that I ‘esphome’d’ back in Jan 23. I did not use cloud cutter back then, but did a USB serial flash. I just re-read my notes when I did it and yes I cut a trace (RX-R49), flashed minimal, and repaired. I was a novice solder man back then and it was not that complex.

We have had a few grid interruptions in the last week or so (unusually) when power goes out for 10-20 secs. I did have one of my light switches go ‘offline’ in unifi. The physical switch was still happily doing its on/off/timer functions ok, but wifi was just not playing ball. I had to switch that light circuit off, count to 10, and switch it back on. I presume you have done this for the 6294HA?

Is power off/on so many times in a short period one of the fail safe modes used to recover non responsive devices? Has it accidentally been triggered by your power outage recovery period, where the power on cycle comes in bursts as the various circuits across the power grid come online in a staggered fashion to stop them tripping again?
You may simply have to reload the device configuration from backup.

Hi, yes the double external socket.

I now have it on my desk temporarily wired with a plug so i can plug in to a wall socket and power cycle the whole unit.

apparently so! but i don;t know for sure if the config needed safe-mode enabled… I can;t flash it OTA.

You say reload device from backup - how do I do this? if an OTA flash then it’s not an option.

I’ll explore unsoldering the chip and wiring in an ESP… never done it but willing to give it a go. No idea on the wiring mapping but I’m sure I’ll figure it out with ChatGPTs help :slight_smile:

You could replace wb2s with a esp02s . Removal of chip would be fairly easy with some solder wick. I have done this on another similar module

Not sure you will gain much with esp02s.
Knowing what I learnt over the last 3 years since I used the ‘cut trace’ and flash option. I would probably avoid that method if I did it again and remove the chip.

Once removed I would try to reflash the wb2s and if ok reinstall back into the 6294HA.

Even if you source a replacement esp chip you still have to flash it before soldering it back to the 6294HA because that pesky trace will be linked to the RX pin.

For the flash,
I compiled a minimal yaml file with just ota and wifi code,
Hooked up a USB Serial with
GND - GND
3.3. - 3.3
RX-TX
TX-RX
RTS-CEN
Used ltchiptool to do a flash write

Picture while I was setting up the serial connection showing cut trace from 3 years ago