logo elektroda
logo elektroda
X
logo elektroda

Another Smart Switch easy to run locally with Home Assistant - ATLO-B1-Tuya

p.kaczmarek2 2211 3

TL;DR

  • Modifies the ATLO-B1-Tuya budget WiFi smart switch, a newer Tuya relay model built around the BK7231N CB2S module, so it can run locally with Home Assistant.
  • Flashes custom firmware with BK7231GUIFlashTool over USB-UART, feeding 5V to the board’s input and wiring RX1/TX1 pads on the CB2S module.
  • The board uses a single relay, a BP2525 step-down supply, an AMS1117-3.3V regulator, and leaves room for the BL0937 energy-measurement option.
  • The template identified Relay on P26, WiFi LED on P8, TglChannelToggle on P6, and Pair/Toggle All on P24, and the switch was successfully freed from the cloud.
  • The hardware still uses a non-isolated mains supply, an incomplete input filter, and no F2 fuse on the phase line, so it remains a very budget design.
Generated by the language model.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
📢 Listen (AI):
  • Close-up of a relay board with WiFi module and electronic components. .
    Here are the firmware change instructions for another budget WiFi controlled relay. The product presented here normally works with the Tuya cloud, but here I will show how it can be freed from the cloud and paired with Home Assistant. The unit discussed here appears under the ATLO-B1-Tuya model and already belongs to the newer series of Smart Switches, as it uses the BK7231N. The gadget itself is available to buy in two versions - a version with energy measurement (based on the BL0937), and a regular version, here I will show the latter.

    Let's start with the packaging, the unit shown here I had from a reader, I changed the firmware for him on request throughout the set of devices.
    Box of WiFi Smart Switch for remote control. .
    Packaging of ATLO-B1-Tuya Wi-Fi relay. .
    You can see that the equipment was bought in our country, probably for a few tens of zlotys, although it would have been cheaper from China.
    Contents - they even gave screws for fixing:
    White Wi-Fi Smart Switch with instructions and a bag of screws. .
    Leaflet with user manual for ATLO-B1-Tuya WiFi relay. .
    Instruction card with ecological labels and certifications. .
    Test with Tuya I skip, it's time to look inside and change the firmware.
    White WiFi Smart Switch model ATLO-B1-Tuya with open casing parts. .
    Disassembled WiFi relay housing with visible PCB and accessories. .
    Inside sits a relay that only cuts off one wire - assumed to be a phase, but you know, it depends how you connect. Apart from that, we have a non-isolated power supply (step down) and a 3.3V LDO regulator and WiFi module.
    PCB of a relay with electronic components on a white base. .
    Printed circuit board with electronic components of a WiFi relay on a white background. .
    Electronic circuit of ATLO-B1-Tuya relay on a white casing with visible electronic components. .
    The input to the inverter is protected by an F1 fuse, next to this we also have a varistor, and then an incomplete filter (the chokes are omitted - e.g. L3 is missing). In the plans there was also a fuse F2, the one from the phase going to the device, but it was omitted.
    Close-up of a relay circuit board with visible electronic components. .
    The step-down converter itself (which converts these rectified 230V to 5V for the relay) is based on a BP2525. Separately further down we have the AMS1117-3.3V.
    Close-up of a PCB with a WiFi module. .
    There is still room on the board for the aforementioned BL0937 along with a resistor/bypass for current measurement.
    Close-up of a circuit board with component and port markings. .
    You can also see the bold current paths from 230V:

    Printed circuit board of a budget WiFi relay .

    ADVERTISEMENT


    The firmware change is done according to the instructions of our flasher:
    https://github.com/openshwprojects/BK7231GUIFlashTool
    We prepare a USB to UART converter as standard, on the other hand we don't need a 3.3V power supply/stabiliser as you can feed 5V to the input of the one on the board:
    WiFi relay board with electronic components and CB2S module. .
    Circuit board of a relay with electronic components. .
    You can't feed 5V into the CB2S power supply, because then you will damage it.
    We also need to add wires to the RX1 and TX1 pads from CB2S:
    PCB schematic with pin labels and dimensions for CB2S module. .
    I first apply flux, then add a bit of lead binder and solder the previously whitened wires too.
    Close-up of a circuit board with soldered wires. .
    A circuit board with electronic components and wires connected to a breadboard. .
    If you have any problems, you can take a look at our Electrode playlist and watch videos about the BK7231 there:
    https://www.youtube.com/playlist?list=PLzbXEc2ebpH0CZDbczAXT94BuSGrd_GoM

    Plug everything in, start the flash read in the flasher and do a power cycle, i.e. disconnect and connect the 5V power cable. The flasher should read the batch including the configuration:
    Screenshot of a tool for extracting Tuya device configuration. .
    JSON Tuya:
    Code: JSON
    Log in, to see the code
    .
    OBK template:
    Code: JSON
    Log in, to see the code

    GPIO verbal description:
    
    Device seems to be using CB2S module, which is BK7231N chip.
    - Relay (channel 1) on P26
    - WiFi LED on P8
    - TglChannelToggle (channel 1) on P6
    - Pair/Toggle All Pin on P24
    
    .
    Instructions for uploading the template:


    .
    Instructions for pairing with HA:


    .

    Operation successful - patient disconnected from the cloud. Can work with HA as well as being freely scripted, configured and even able to handle additional sensors, buttons and relays. Details on Github of the project . You can also take a look at our list of device templates and on Youtube Elektrodam.com .
    If you have any questions, I'm happy to help - the firmware presented here also supports other, less popular chips, so even if your switch is not based on BK, it's still probably possible to change the firmware.

    Cool? Ranking DIY
    Helpful post? Buy me a coffee.
    About Author
    p.kaczmarek2
    Moderator Smart Home
    Offline 
    p.kaczmarek2 wrote 14409 posts with rating 12351, helped 650 times. Been with us since 2014 year.
  • ADVERTISEMENT
  • #2 21713540
    philip3
    Level 2  
    Posts: 9
    >>21491904
    Hi,
    I have one of these, and I tried to follow this guide. It looked like everything went fine, the flasher reports "success" at every step. However now the unit powers up, the led glows blue, but quite dim, no AP, no function. I tried flashing the original firmware back, unfortunately, same behaviour. I tried with 3.3V directly, also with 5V to the regulator of the board, tried different USB-UART adapters, two different PCs, I also tried the older flashing software. Tried multiple times in every combination I could think of.
    Any idea what I can try?
  • ADVERTISEMENT
  • #3 21713887
    philip3
    Level 2  
    Posts: 9
    One more thing: this is the data I got from the flasher when backing up the original firmware:
    
    {
    	"rl1_lv":"1",
    	"on_off_cnt":"10",
    	"onoff_rst_m":"1",
    	"onoff_clear_t":"10",
    	"rand_dpid":"42",
    	"net_trig":"4",
    	"onoff_n":"3",
    	"netled1_lv":"0",
    	"jv":"102",
    	"onoff_rst_type":"2",
    	"total_bt_pin":"24",
    	"nety_led":"2",
    	"total_stat":"2",
    	"reset_t":"5",
    	"netled1_pin":"8",
    	"remote_add_dp":"49",
    	"remote_list_dp":"50",
    	"net_type":"0",
    	"inch_dp":"44",
    	"module":"CB2S",
    	"ch_cddpid1":"9",
    	"onoff1":"6",
    	"clean_t":"5",
    	"init_conf":"38",
    	"zero_select":"0",
    	"onoff_type":"0",
    	"series_ctrl":"0",
    	"total_bt_lv":"0",
    	"cyc_dpid":"43",
    	"remote_select":"0",
    	"ch_num":"1",
    	"rl1_pin":"26",
    	"netn_led":"2",
    	"ch_dpid1":"1",
    	"crc":"20"
    }
    


    and:
    
    Device configuration, as extracted from Tuya: 
    - Pair/Toggle All Button on P24
    - WiFi LED on P8
    - TglChannelToggle (channel 1) on P6
    - Relay (channel 1) on P26
    Device seems to be using CB2S module, which is using BK7231N.
    And the Tuya section starts, as usual, at 2023424
    
  • #4 21724225
    IslaPenn
    Level 1  
    Posts: 1
    Thanks for sharing, I appreciate you.
📢 Listen (AI):

FAQ

TL;DR: With 4 GPIO assignments and a CB2S/BK7231N module, this FAQ shows Home Assistant users how to flash the ATLO-B1-Tuya locally; as the author put it, "patient disconnected from the cloud." It also covers safe 5V flashing, Tuya JSON backup, and recovery when the switch boots only to a dim blue LED. [#21491904]

Why it matters: This switch can leave the Tuya cloud and work locally, but only if you wire, power, and back up it correctly.

Variant Main extra hardware Best use case Local-control note
Regular ATLO-B1-Tuya No BL0937 fitted Simple relay switching Template shown directly in the thread
Energy-monitoring version BL0937 present Switching plus power data Needs the metering parts populated

Key insight: Flashing succeeds only when you power the board through its regulator path, not through the CB2S power pin. A wrong power point can leave the switch with only a dim blue LED and no AP. [#21491904]

Quick Facts

  • The board uses a CB2S module with a BK7231N chip, and the working OpenBeken mapping is P26 relay, P8 WiFi LED, P6 toggle input, and P24 pair/toggle-all button. [#21491904]
  • The internal power chain is rectified 230V -> BP2525 step-down -> 5V rail -> AMS1117-3.3V, so you can inject 5V at the regulator input during flashing. [#21491904]
  • The mains side includes an F1 fuse and a varistor, but the PCB omits some planned filter parts, including missing chokes and an unpopulated F2 fuse position. [#21491904]
  • The flasher can read the original Tuya data, including JSON config and the note that the Tuya section starts at 2023424, which matters for backup integrity. [#21713887]

How do I flash the ATLO-B1-Tuya smart switch with OpenBK7231T so it works locally with Home Assistant instead of the Tuya cloud?

You flash it over UART, then load the matching OpenBeken template for the CB2S/BK7231N board. Solder to the module UART pads, power the board correctly, read the original flash first, then write OpenBK7231T and assign P26 as relay, P8 as WiFi LED, P6 as toggle, and P24 as pair button. The author states the result clearly: the switch was "disconnected from the cloud" and then paired with Home Assistant locally. [#21491904]

What is the CB2S module in the ATLO-B1-Tuya, and how does it relate to the BK7231N chip?

The CB2S is the Wi-Fi module fitted on this switch, and it uses the BK7231N as its main chip. "CB2S is a Wi‑Fi module that hosts the BK7231N SoC, exposing power and UART pads for firmware flashing." In this thread, the flasher identifies the board as CB2S and the chip as BK7231N, which is why the OpenBeken template targets that exact combination. [#21491904]

What is the BL0937 in the energy-monitoring version of this smart switch, and what does it measure?

The BL0937 is the metering chip used only in the energy-monitoring version of this switch. "BL0937 is an energy-measurement IC that reads load parameters through dedicated sensing parts, adding current and power monitoring to a relay board." The regular unit shown here does not include it, but the PCB still leaves space for the BL0937 and its current-sense resistor or bypass parts. [#21491904]

Which GPIO pins should be assigned on the ATLO-B1-Tuya for the relay, WiFi LED, toggle input, and pair button in an OpenBeken template?

Use P26 for the relay, P8 for the WiFi LED, P6 for the channel toggle input, and P24 for the pair or toggle-all button. The posted OpenBeken template maps them as Rel;1 on GPIO 26, WifiLED_n;0 on GPIO 8, TglChanOnTgl;1 on GPIO 6, and Btn_Tgl_All;0 on GPIO 24. Those four assignments match both the extracted Tuya JSON and the verbal GPIO description. [#21491904]

Why is it safe to feed 5V into the board regulator when flashing this ATLO-B1-Tuya, but not into the CB2S module power pin?

It is safe because the board already converts its internal supply through a 5V stage and then an AMS1117-3.3V regulator, but the CB2S itself is a 3.3V module. The thread explicitly says you can feed 5V to the board regulator input during flashing, and explicitly warns that feeding 5V into the CB2S power supply will damage the module. That difference is the key power-safety rule for this device. [#21491904]

What steps are needed to read the original Tuya firmware configuration and JSON backup from an ATLO-B1-Tuya using BK7231GUIFlashTool?

Read the original backup before you flash anything else. 1. Connect a USB-to-UART adapter and solder wires to RX1 and TX1 on the CB2S. 2. Start a flash read in BK7231GUIFlashTool and power-cycle the board by disconnecting and reconnecting the 5V lead. 3. Save the extracted dump, JSON Tuya config, and pin report before writing new firmware. The author says the flasher should read the batch including the configuration after that power cycle. [#21491904]

Why would an ATLO-B1-Tuya show a dim blue LED after flashing, with no AP and no relay function, even when the flasher reports success?

A dim blue LED with no AP usually points to a boot, power, or image problem rather than a simple flashing-status problem. In the reported failure, the flasher said "success" every time, but the unit still showed only a weak blue LED, no AP, and no relay action even after attempts with 3.3V, 5V to the regulator, different adapters, two PCs, and restored original firmware. That symptom suggests the board is powering abnormally or not running valid firmware after reset. [#21713540]

What troubleshooting sequence should I try when an ATLO-B1-Tuya becomes unresponsive after flashing and restoring the original firmware still does not help?

Try a structured recovery sequence instead of random reflashes. First, verify power injection: use 5V only at the board regulator path, never at CB2S. Second, confirm RX1 and TX1 wiring and repeat a readback to see whether the device still reports valid CB2S/BK7231N data. Third, compare the extracted configuration against the known-good mapping: P24, P8, P6, and P26. If the unit still shows only a dim blue LED after restored original firmware, treat it as a power-path or hardware fault, not just a software fault. [#21713887]

How do RX1 and TX1 need to be wired from the CB2S module to a USB-to-UART adapter for flashing the BK7231N?

Wire the CB2S UART pads to the adapter as a normal UART cross-connection: RX1 on the board goes to the adapter TX, and TX1 goes to the adapter RX. The thread shows that you must solder added wires directly to the RX1 and TX1 pads on the CB2S, then use a USB-to-UART converter for the flashing process. Good soldering matters because these pads are small and easy to bridge. [#21491904]

What is the 'Tuya section starts at 2023424' message in the flasher output, and why does that offset matter when backing up or restoring firmware?

It is the flash-memory offset where the flasher found the Tuya configuration area. That matters because the offset tells you where the original device settings and JSON-style data begin, so a proper backup or restore must preserve that section intact. In the failure report, the flasher explicitly identified the Tuya section start at 2023424 while also listing the same GPIO and module data as the working device. [#21713887]

How does the regular ATLO-B1-Tuya switch differ from the energy-monitoring version with the BL0937, and which one is better for Home Assistant use?

The regular version is the simpler choice if you only need on/off control in Home Assistant. The thread says the product is sold in two versions: a regular relay version and an energy-monitoring version based on the BL0937. The board shown and flashed here is the regular one, while the PCB still has space reserved for the BL0937 and its sensing parts in the metering variant. Choose the BL0937 version only if you specifically need power data. [#21491904]

What safety concerns should I keep in mind when opening and flashing a mains-powered smart switch that uses a non-isolated BP2525 power supply?

Treat the board as mains-dangerous whenever it is connected, because the internal supply is non-isolated. The author shows a BP2525 step-down stage derived from rectified 230V, a 5V rail for the relay, and a 3.3V regulator for logic. He also notes that the relay switches only one conductor and that some protection or filter parts are omitted on the PCB. Open, solder, and power it only when fully disconnected from mains. [#21491904]

Where can I find the correct OpenBeken device template and Home Assistant pairing instructions for the ATLO-B1-Tuya smart switch?

You can find both directly in the thread. The post includes a full OpenBeken JSON template for model ATLO-B1-Tuya, plus separate linked instructions for uploading the template and pairing the flashed switch with Home Assistant. It also points to the OpenBeken project GitHub, the device-template list, and a YouTube guide for HA pairing, all from the same main post. [#21491904]

Why does this ATLO-B1-Tuya relay switch only one wire, and how does correct phase wiring affect installation safety and behavior?

It switches only one conductor because the relay is placed in series with a single line on the PCB. The author states that the relay cuts off one wire only, assumed to be the phase, and adds that behavior depends on how you connect it. If you wire the switched path as phase, the load turns off in the expected safer way; if you switch the wrong conductor, the device can still leave live potential where you do not want it. [#21491904]

What hardware details inside the ATLO-B1-Tuya—such as the BP2525 supply, AMS1117-3.3V regulator, fuse F1, and missing filter parts—matter when diagnosing flashing or power problems?

Those parts define whether the board can power the radio and relay correctly during flashing and normal boot. The thread identifies an F1 input fuse, a varistor, omitted filter chokes, an omitted F2 fuse position, a BP2525 converter that drops rectified 230V to 5V, and an AMS1117-3.3V regulator for logic. If the board flashes "success" but only shows a dim LED, these power-path components are the first places to inspect. [#21491904]
Generated by the language model.
ADVERTISEMENT