logo elektroda
logo elektroda
X
logo elektroda

Teardown and Reflashing of Tuya Smart Socket EU20A with LN882HKI Chip Analysis

bogdanelhh 14853 75
Best answers

How do I flash a Tuya EU20A smart socket with an LN882HKI chip and configure its pins for Home Assistant use?

Yes — this plug can be flashed to OpenBeken for Home Assistant by using the LN882H UART0 pins on A2/A3 (not B8/B9), pulling A9 to GND at power-on, and powering the board from an external 3.3 V supply with a common ground [#21334246][#21334409][#21832386] One successful wiring report used 3V3, GND, A9 shorted to GND during flashing, TX, and RX, and confirmed that flashing worked even though the original factory firmware could not be dumped [#21334409] For the power metering chip, the BL0937 connections were identified as CF = B4/pin 25, CF1 = B5/pin 26, and SEL = B6/pin 27 [#21799323] Another EU20A/OpenBeken template in the thread maps LED_n to 6, Btn to 7, Rel to 19, and the BL0937 signals to 20/21/22, so you can use that as a starting point if it matches your board [#21614566] After flashing, set up Wi‑Fi and then configure the pins in Config → Configure Module or in the WebApp; once metering values appear, calibrate them from the Tools tab [#21453872]
Generated by the language model.
ADVERTISEMENT
  • #61 21796709
    GoldMember
    Level 12  
    Posts: 26
    Rate: 1
    divadiow wrote:
    GoldMember wrote:
    What is wrong?

    A9 pulled to ground at power-on?

    https://www.elektroda.com/rtvforum/topic4028087.html

    It wasn't. Connecting A9 to GND helped. Flashed successfully, but is not reading any values. I tried your settings from previous post, but not working.
  • ADVERTISEMENT
  • #62 21796755
    max4elektroda
    Level 24  
    Posts: 745
    Help: 47
    Rate: 183
    You will need the correct pin configuration for your plug to get the power meters readings.
    Can you trace the BL0937 pins to the pins of the LN882H?


    Pinout diagram and pin function descriptions for BL0937 IC
  • #63 21797420
    GoldMember
    Level 12  
    Posts: 26
    Rate: 1
    max4elektroda wrote:

    Can you trace the BL0937 pins to the pins of the LN882H?


    Do you mean physical connection between BL0937 and LN882H?
  • ADVERTISEMENT
  • #64 21797531
    max4elektroda
    Level 24  
    Posts: 745
    Help: 47
    Rate: 183
    GoldMember wrote:
    Do you mean physical connection between BL0937 and LN882H?

    Yes, you will need to know, which of the BL0937 pins SEL, SEL1 and CF is connected to which LN882H IO pin.
    You might be lucky that someone which exactly the same device than yours allready figured this out or need to do it by yourself.
    Depending on your device you might also "guess" them, if you have a separate LN882H module with only a handful of connections and can "easily" find the relay with IO doctor (you will hear the clicking sound) if you found the right one, then you might also just try all possible permutations. But since the BL0937 usually has the pins easily accessible, it should be possible to check the connections by eye (following the PCB connections) or with a multimeter.
  • ADVERTISEMENT
  • #65 21799115
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14416
    Help: 650
    Rate: 12371
    I think Counter role can be also used to find BL0937. Counter pin counts pulses in the channel and BL0937 works by sending pulses on CF and CF1 pins. So that only would leave SEL to be found.
    Helpful post? Buy me a coffee.
  • #66 21799303
    GoldMember
    Level 12  
    Posts: 26
    Rate: 1
    BL0937 pin - LN 882H pin
    6 --------------- 25
    7 --------------- 26
    8 --------------- 27
  • ADVERTISEMENT
  • #67 21799304
    divadiow
    Level 38  
    Posts: 4859
    Help: 424
    Rate: 860
    if you took backup of Tuya firmware does Easy Flasher not extract config?
  • #68 21799311
    insmod
    Level 31  
    Posts: 1353
    Help: 160
    Rate: 425
    >>21799304
    No LN device contains pin settings in tuya config.
  • #69 21799322
    divadiow
    Level 38  
    Posts: 4859
    Help: 424
    Rate: 860
    >>21799311

    darn, oh yes ;)

    example
    Code: JSON
    Log in, to see the code
  • #70 21799323
    max4elektroda
    Level 24  
    Posts: 745
    Help: 47
    Rate: 183
    GoldMember wrote:
    BL0937 pin - LN 882H pin
    6 --------------- 25
    7 --------------- 26
    8 --------------- 27

    According to this

    Pin layout diagram of the LN882HKx chip by Lightning Semiconductor (QFN32)

    It should be

    CF (Pin 6) = B4 (Pin 25)
    CF1 (Pin 7) = B5 (Pin 26)
    SEL (Pin 8) = B6 (Pin 27)

    Does it work with this assignment?
  • #71 21799463
    GoldMember
    Level 12  
    Posts: 26
    Rate: 1
    Yes, it works. Configuration has to be like that:

    Interface with dropdown menus and numeric fields for ports A6–B6
  • #72 21831876
    mariuszkowa
    Level 4  
    Posts: 6
    I have a similar Smart Socket with LN882HKI (it's CozyLife XLD01 10A; check the attached pictures).
    I would really appreciate it if anyone could help me find where I can attach RX, TX, 3.3 V, GND, CEN wires for flashing.
    I've also checked the bottom side of the PCB; nothing useful is there, unfortunately.

    Round XLD01 smart socket PCB with LN882HKI chip, capacitors, and power components
    Close-up of PCB with Lightning LN882HKI chip and a 40.000 MHz crystal oscillator
    Disassembled smart socket: green XLD01 PCB next to a white housing with a power button
    Disassembled smart socket: plug with printed specs and empty white housing on a red background
  • #73 21832324
    max4elektroda
    Level 24  
    Posts: 745
    Help: 47
    Rate: 183
    You will need A2 and A3 (Rx and Tx) and A9 needs to be connected to GND for flashing.

    Tried to add the info to your image:

    Close-up of a PCB with a “LIGHTNING” IC and red arrows labeling pins A2 Rx, A3 Tx, and A9→GND for flashing

    If these pins are not connected (maybe there are contacts on the other side of PCB ? but it doesn't look like this) you will need to solder or use some needles...
  • #74 21832378
    mariuszkowa
    Level 4  
    Posts: 6
    >>21832324
    Thank you so much @max4elektroda!
    Wondering if there's any place to attach 3.3 V and CEN for reset during flashing. I guess plugging the socket normally and quickly off/on power when needed may also work?
  • #75 21832386
    max4elektroda
    Level 24  
    Posts: 745
    Help: 47
    Rate: 183
    I hope it's clear that flashing should NEVER be done while the plug is connected to high voltage?

    LN882H doesn't need reconnecting or CEN, this is only needed with Beken, if I'm not mistaken.
    For this chip, only A9 needs to be connected to GND for flashing.

    I would use LDO (the voltage regulator) for supply of 3.3 V. Your power supply should be capable of delivering enough current to drive the chip, usually output of an USB Uart is not enough!
    On your first picture I see an AMS1117 3.3 on the upper left. Pin 1 (the left one, below the "3.3") is GND, Pin 2 (middle and the big one on the upper side) is +3.3V.
    You might also try "using" the LDO by using a 5V source on the input of the LDO. The 5V should be attached to pin 3, the one to the right while GND is the same (Pin 1).
    If you are unsure, ask again, much better than breaking something with a wrong connection...
  • #76 21832928
    mariuszkowa
    Level 4  
    Posts: 6
    >>21832386
    Thank you very much @max4elektroda! I have all the information I needed now. Once I get some free time, I'll give it a try and let you know about effects. Big thanks again!

Topic summary

✨ The discussion focuses on the teardown and reflashing process of the Tuya Smart Socket EU20A, which uses the LN882HKI chip and supports power monitoring via the Smart Life app with Google Assistant and Alexa integration. The original poster successfully soldered wires to the chip's UART pins (notably A9 to GND for download mode) and flashed the device using an external 3.3V power supply and a CH340 USB-to-serial adapter. Key UART pins identified include RX0/TX0 on A3/A2 (pins 11 and 10) and RX1/TX1 on B8/B9. The reflashing process involves entering download mode by pulling A9 to ground, with LED behavior indicating mode status. Users reported challenges with unstable web configuration interfaces and long firmware dump times (~40 minutes). A configuration template was shared, mapping pins for LED, button, relay, and BL0937 power metering chip signals. Calibration of the BL0937 chip is necessary for accurate power measurement, achievable via the device's web app tools. Backup of original firmware before flashing is recommended but often difficult due to instability. Alternative flashing methods and device variants with different chips (e.g., T34, BK7231N) were noted, with OpenBeken firmware supporting multiple chipsets. Practical advice includes using short cables, lowering serial baud rates (e.g., 115200 or 921000), and ensuring solid ground connections to improve flashing reliability. The community provided links to related resources, firmware repositories, and configuration guides to assist in reflashing and configuring the device for custom use cases such as solar panel energy monitoring.
Generated by the language model.

FAQ

TL;DR: For Home Assistant users, this EU20A teardown confirms a 2MB flash LN882HKI plug can be reflashed by UART, and “A9 pulled to ground at power-on” is the key step. Use external 3.3V, wire RX/TX to the correct serial pins, then load the BL0937 pin map for power readings. [#21334409]

Why it matters: This thread turns a hard-to-identify Tuya smart plug into a documented OpenBeken target, including wiring, boot mode, pin mapping, and the most common failure fixes.

Topic Tuya stock firmware OpenBeken on LN882H
Pairing/recovery method Long-press style pairing behavior discussed by users Safe mode after 5 fast power reboots within the first 5 seconds
Power monitoring Native in stock app Works after BL0937 pins are mapped and calibrated
Flashing entry Not applicable A9 must be tied to GND at power-on
OTA file expectation Normal vendor flow Users reported LN882H uses .bin, while WebApp expected .rbl

Key insight: Successful flashing is only half the job. On LN882H plugs, power monitoring appears only after you identify the BL0937 CF, CF1, and SEL lines and assign them to the right GPIOs.

Quick Facts

  • The opened EU20A sample used an LN882HKI in QFN-32 with 2MB flash and a stated operating range of -40°C to 105°C. [#21333751]
  • The working OpenBeken template posted for EU20A mapped pin 6 = LED_n, 7 = Btn, 19 = Rel, 20 = BL0937CF, 21 = BL0937CF1, and 22 = BL0937SEL. [#21335189]
  • A successful dump taken by the web method took about 40 minutes, and another user confirmed that duration was normal for this approach. [#21416338]
  • Users improved flashing reliability by shortening wires from about 60 cm + 20 cm and lowering UART speed to 921000 or even 115200 when errors appeared. [#21451913]
  • A related LN882H variant used BL0937 pin 6→LN882H pin 25, 7→26, and 8→27, which then worked as CF=B4, CF1=B5, SEL=B6. [#21799323]

1. How do I flash a Tuya Smart Socket EU20A with an LN882HKI chip using OpenBeken and UART wiring?

Flash it over UART with external 3.3V and the LN882H in download mode. 1. Solder GND, 3.3V, RX, TX, and A9. 2. Tie A9 to GND, then power the board so it enters download mode. 3. Flash OpenBeken, reboot normally, then configure the module pins for relay, LED, button, and BL0937. One working wiring report used red=3.3V, gray=A9, green=TX, white=RX, plus a common ground. The user explicitly said external 3.3V with common ground was used. [#21334409]

2. Which LN882H pins should I use for RX, TX, 3.3V, GND, and boot mode on the EU20A smart plug?

Use A3 as RX0, A2 as TX0, GND and 3.3V from the board supply points, and A9 as the boot strap. A correction in the thread states A3/A2 are the serial pins, while B8/B9 are RX1/TX1 and will mislead flashing attempts. For power, users either soldered directly to 3.3V and GND pads or used the AMS1117 regulator points. Boot mode requires A9 connected to GND during power-on. [#21334246]

3. Why does pulling A9 to GND at power-on put the LN882H into download mode, and what LED behavior should I expect?

Pulling A9 to GND at power-on selects the LN882H download mode instead of normal firmware boot. Users confirmed that if the plug still boots Tuya firmware, the LED flashes normally and you are not in download mode. A dim blue LED that stays on was described as correct behavior for download mode on one setup. If the LED blinks as usual, recheck ground continuity and fully remove power between retries. [#21451913]

4. What is the BL0937 chip in these Tuya smart plugs, and how does it handle power monitoring?

“BL0937” is an energy-metering IC that outputs pulse signals for electrical measurements, with separate CF, CF1, and SEL lines. In this plug family, OpenBeken reads those lines after you assign them to the correct GPIOs. The thread shows BL0937 is the dedicated power-monitoring chip on the EU20A board, and users only got voltage, current, and power data after tracing or importing the correct pin map. [#21333751]

5. Where do I import or enter the OpenBeken pin template for the EU20A: Configure Module or the Web Application?

You can do it in either place. The thread says a posted template can be imported through the WebApp, and the same pin roles can also be entered manually in Config → Configure Module on the device. If you do not know the pins, the WebApp also offers Pin Doctor for discovery. For this EU20A family, users shared a ready template, which is faster than mapping each pin from scratch. [#21453872]

6. How should I calibrate BL0937 power readings in OpenBeken after flashing an LN882H-based smart plug?

Calibrate it after the BL0937 pins already produce live values. The thread says you should first assign CF, CF1, and SEL correctly; once the device shows readings, even rough ones, use the Tools tab in the WebApp to calibrate the power metering. That sequence matters because calibration is pointless if the pulse pins are wrong or inactive. Users specifically described calibration as the step after functional pin setup, not before. [#21453872]

7. What causes Easy Flasher on LN882H to show repeated "Unknown command 'version'" errors, and how do I fix it?

That error usually means the chip never entered LN882H download mode. In the January 2, 2026 report, Easy Flasher kept repeating “Unknown command 'version'” until the user realized A9 was not tied to GND at power-on. After connecting A9 to GND correctly, flashing succeeded. If you see that exact loop, fix boot strapping first before changing firmware files or templates. [#21796709]

8. Why might an LN882H smart plug flash successfully but show no voltage, current, or power readings until the BL0937 pins are traced?

Because OpenBeken can boot and switch the relay before power metering is configured. The thread shows several cases where flashing worked, Wi‑Fi worked, and the plug web UI loaded, but voltage and power stayed empty until the BL0937 CF, CF1, and SEL lines were traced to the LN882H GPIOs. One later variant only worked after mapping BL0937 pins 6, 7, and 8 to LN882H pins 25, 26, and 27. [#21799323]

9. When flashing an LN882H socket with a CH340 adapter, what serial speed, wire length, and power supply setup work best?

Use short wires, reduce baud rate if needed, and avoid relying on weak USB-UART power alone. One user failed with long leads of about 60 cm + 20 cm, then succeeded after shortening them and dropping speed to 921000. Another recommendation was to try 115200 if higher rates were unstable. Multiple posts also stress using a solid external 3.3V supply with common ground, because some adapters cannot power the board reliably. [#21453808]

10. What is OpenBeken safe mode, and how is it different from Tuya's AP pairing mode on a smart plug?

OpenBeken safe mode is a recovery boot path, not Tuya-style pairing mode. Tuya users often expect AP mode from a long button press, but OpenBeken on this plug does not use that behavior. Instead, the thread says safe mode is triggered by 5 fast power reboots, each within the first 5 seconds of startup. Safe mode is for recovering access when the device is otherwise unreachable, while Tuya AP mode is the stock pairing flow. [#21646083]

11. How do I force an OpenBeken-flashed smart plug back into AP or safe mode if the physical button does not do it?

Use the web GUI if the device is reachable, or use repeated full power cuts if it is not. 1. If the plug is online, enable AP from the GUI. 2. If it is offline, cut mains power to the whole device and restore it quickly 5 times. 3. Do each reboot within the first 5 seconds so OpenBeken counts them as failed boots. The relay button does not count, because it does not reboot the Wi‑Fi module. [#21646083]

12. Why do some LN882H plugs lose Wi-Fi or fail to reconnect after an OTA update, and what troubleshooting steps are worth trying?

The thread reports intermittent LN882H Wi‑Fi reconnect issues after OTA, but no single root cause was confirmed. One user updated from 1.18.131 to 1.18.133 and then needed many unplug/replug cycles before Wi‑Fi returned. Practical steps from the discussion are: reflash by serial, reconfigure from scratch, verify the button still works locally, and test whether the issue persists across versions. That narrows whether the failure came from OTA state, configuration corruption, or an existing instability. [#21602868]

13. What is the PowerSave command on LN882H, and why does the thread say it should be placed in autoexec instead of Startup Command Text?

“PowerSave” is a startup power-management command that changes the LN882H sleep behavior, with level 1 used for light sleep when BL0937 metering is present. The thread says LN882H does not apply this command correctly from Startup Command Text, so users should place PowerSave 1 in autoexec instead. It also notes that values above 1 trigger deeper sleep, while PowerSave 0 disables the feature. [#21599335]

14. OpenBeken vs ESPHome on an LN882H smart plug with BL0937: which approach is more practical for power monitoring and Home Assistant?

OpenBeken is the more practical choice in this thread because it is already proven on the EU20A hardware. Multiple users flashed LN882H successfully, posted working pin templates, and showed BL0937 readings in the OpenBeken interface. By contrast, the ESPHome attempt raised a real interrupt concern for BL0937 on bank B pins, and the user only fixed it later by modifying LibreTiny. If you want the fastest path to Home Assistant, OpenBeken has the shorter path here. [#21614566]

15. What safety precautions should I follow when soldering to A9, A2, A3, or the AMS1117 regulator on a mains-powered smart plug?

Never flash or probe this plug while it is connected to mains. The clearest warning in the thread says flashing should NEVER be done with the plug on high voltage. Use isolated low-voltage power only, and be careful around A9 and nearby capacitors because a mistaken short can overcurrent USB power, overheat the chip, or kill the board. For AMS1117 access, the thread identifies pin 1 as GND, pin 2 as +3.3V, and pin 3 as 5V input on one related LN882H board. [#21832386]
Generated by the language model.
ADVERTISEMENT