logo elektroda
logo elektroda
X
logo elektroda

[BK7321N] How to change the firmware on the LTC LXU407 smart plug with BK7321N chip?

uszatekmis 1632 11

TL;DR

  • Modifies an LTC LXU407 smart plug with BK7231N/BK7321N and BL0942 to remove Tuya cloud dependence and flash custom firmware.
  • Opens the compact case via a triangular screw under the sticker, then flashes the board with pogo-pin P50-B1 contacts instead of soldering.
  • Uses pin 6 for LED_n/WifiLED_n, pin 9 for Btn 1, and pin 26 for Rel 1, with startup script `backlog PowerSave 1; startDriver B0942`.
  • Tuya-cloudcutter could not flash it because of soft 1.1.8, and voltage readings are usually overestimated so calibration is advisable.
Generated by the language model.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
📢 Listen (AI):
  • Good morning.
    As I've been using a dozen or so smart sockets of one type for over two years, I've finally matured into trying to make them cloud free.
    I use them for Home Assistant with LocalTuya integration (which in itself no longer requires the cloud), but I wanted to change the firmware completely.
    The socket is quite compact (that's what I was looking for), with tuya-cloudcutter it is unfortunately impossible to sflash it (soft 1.1.8).
    But to the edge. It looks like this:

    Smart WiFi socket next to its original packaging on a table. .

    Once I found the right way to open the case it went quite straightforward.
    Under the sticker is a screw with an unusual head (triangular keyway).

    View of the bottom part of a smart socket with the sticker removed, revealing a triangular screw head. .

    After unscrewing it and gently removing the top, the interior with the stick-on antenna begins to be visible.

    The image shows the interior of an opened smart plug, revealing the electronic circuit board. .

    You can already find the Beken chip, but I couldn't imagine flashing by touching the chip feet directly (but I was prepared to do so).
    However, after gently peeling off the antenna

    Interior of a dismantled smart socket showing electronics and a detached antenna.
    and placing the socket upside down with the pins and DELICIOUSLY treating them with a hammer, everything comes out nicely.

    Image of the interior of a dismantled smart socket with visible electronic components. .

    It remains to be seen what this has on board - BK7231N and BL0942.

    Close-up of a circuit board featuring a Beken BK7231N chip and other electronic components. .

    The best hides on the opposite side of the board where the chip is.

    Inside of a disassembled smart plug showing a circuit board.

    This is where simple flashing remains. It is possible to solder, but I, due to the large number of devices to be reworked, went for spring-loaded pins (pogo-pin) type P50-B1, available on a large Polish shopping portal.

    Interior of a smart socket with connected pogo pins. .

    Pin configuration:
    pin 6 - LED_n 1 / WifiLED_n
    pin 9 - Btn 1
    pin 26 - Rel 1

    Startup script:
    backlog PowerSave 1; startDriver B0942

    I still use

    alias mode_wifi setPinRole 6 WifiLED_n
    alias mode_relay backlog setPinRole 6 LED_n; SetPinChannel 6 1;
    mode_wifi
    addChangeHandler WiFiState == 4 mode_wifi
    addChangeHandler WiFiState != 4 mode_relay

    I noticed that the voltage indication is not very accurate (usually overestimated), so calibration is rather advisable.

    Cool? Ranking DIY
    About Author
    uszatekmis
    Level 11  
    Offline 
    uszatekmis wrote 22 posts with rating 2. Live in city Rzeszów. Been with us since 2007 year.
  • ADVERTISEMENT
  • #2 21474910
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14400
    Help: 650
    Rate: 12330
    Do you perhaps have backups of the socket charge? We are collecting them for analysis.

    Calibration is always a must, this can be done via WebApp:
    Calibration panel for devices in Tasmota software. .

    And yes I see you have a new version of this:
    [ESP8266+BL0937] Old Neo Power Plug 16A, 2018, Tasmota, difficult to access pads .
    It resembles this socket, but I couldn't get the plate out of it:
    Socket plug with energy measurement NAS-WR01W and NAS-WR07W [BK7231/BL0937/BL0942] .
    And now I don't know if I missed something then, or if my model was glued and yours wasn't....

    Here someone else was showing a similar copy:
    (BK7231N, BL0942) Opening and changing Nedis WIFIP110FWT firmware (BK7231N, BL0942) .
    So much so that he in turn used a carpenter's squeeze....

    So probably some series are tighter and others weaker glued. I had the same thing with the LSPA9. Some were glued up to the amen and others could be opened with a bare hand.
    Helpful post? Buy me a coffee.
  • #3 21474942
    uszatekmis
    Level 11  
    Posts: 22
    Rate: 2
    Board Language: polish
    >>21474910 .
    Hi.

    Yes, of course I have a copy of the batch, in fact I still have about 12 such slots not converted. I will send on pw (?).
    As for calibration, of course - I know how to do it, I've already done it with other switches (already described so I didn't want to repeat myself) - it's mega easy and very well described. I'm waiting for some larger batch after reworking to do it in bulk.

    I have gone through the topics with the clamps (when looking for a way to disassemble) but using the ChatGPT only directed me to a possible screw under the sticker. The first socket when trying to disassemble survived a little more than the next :-) Incidentally it is made of very robust plastic, you can bend it really hard and nothing. In my case nothing was glued and the whole thing on one, unusual (triangle) screw.
    Searching by name/chip/photos unfortunately yielded nothing.

    I am looking at your post about the NAS-WR07W and it seems to me that the method with a hammer would also work here - in my case there are identical pin mounts in the plastic - it would be done without cutting the case. It's a matter of gently knocking the bases of the pins (those metal stars) out of the plastic they are embedded in. SlawekSS also writes about this in post #4.
  • ADVERTISEMENT
  • #4 21476696
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14400
    Help: 650
    Rate: 12330
    If searching by name/chip/manufacturer does not work, or more specifically if something is missing from our list:
    https://openbekeniot.github.io/webapp/devicesList.html
    Then please report to me, or even better, give corrections yourself, the source list is available here:
    https://github.com/OpenBekenIOT/webapp/blob/gh-pages/devices.json

    I would also like to add your topic to it, could you paste the full OBK template here in JSON format, preferably with the links to the topic (this one) from the forum already filled in and a link to the photo?


    As for the Tuya memory dumps, we're interested in unpaired ones, as we don't want to accidentally leak someone's SSID. We are collecting them here: https://github.com/openshwprojects/FlashDumps
    Helpful post? Buy me a coffee.
  • #5 21477124
    uszatekmis
    Level 11  
    Posts: 22
    Rate: 2
    Board Language: polish
    p.kaczmarek2 wrote:
    If searching by name/chip/manufacturer does not work, or more specifically if something is missing from our list:
    https://openbekeniot.github.io/webapp/devicesList.html
    Then please report to me, or even better, give corrections yourself, the source list is available here:
    https://github.com/OpenBekenIOT/webapp/blob/gh-pages/devices.json

    I would also like to add your topic to it, could you paste here the full OBK template in JSON format, preferably with already filled in links to the topic (this one) from the forum and a link to the photo?
    .
    I am already correcting myself - template attached.

    p.kaczmarek2 wrote:
    What about Tuya memory dumps, we're interested in unpaired ones, as we don't want to accidentally leak someone's SSID. We collect them here: https://github.com/openshwprojects/FlashDumps
    .
    Here I also accept criticism :-) I made a new dump on the test AP - it does not contain sensitive data.
    Attachments:
    • template-lxu407.txt (550 Bytes) You must be logged in to download this attachment.
  • #6 21478189
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14400
    Help: 650
    Rate: 12330
    Thanks for sharing the batch (for publication with the test SSID), it is now here:
    https://github.com/openshwprojects/FlashDumps/commit/b9c617c581f88e5ad4f883716009c67a473addd1

    Config Tuya:
    Code: JSON
    Log in, to see the code
    .
    Your template:
    Code: JSON
    Log in, to see the code
    .
    Added:
    https://github.com/OpenBekenIOT/webapp/commit/184f36db7b4be86394fffdfe130a45937c6b4c10
    You should immediately be able to search for this device here:
    https://openbekeniot.github.io/webapp/devicesList.html


    By the way, where did you buy them? I saw the LXU series on our Polish auction portal.
    Screenshot of the device list in the OpenBeken web application. .
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #7 21478277
    uszatekmis
    Level 11  
    Posts: 22
    Rate: 2
    Board Language: polish
    >>21478189 .
    I bought all of them on our Polish auction portal. I think they were even from the same seller. Over an extended interval (roughly over the course of 1.5 years)
  • ADVERTISEMENT
  • #8 21478412
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14400
    Help: 650
    Rate: 12330
    I have yet to test such products from them:
    RF remote controlled relay socket - LXU200 - short test, interior... .
    Simple timer LXU09 - instructions, interior, cell from inside (holding)

    But better to return to the subject of the socket - and so I would ask, have you seen this feature?
    Charts in OpenBeken - configurable measurement history hosted on an IoT device .
    At my place it is fired up on such sockets.
    Helpful post? Buy me a coffee.
  • #9 21478988
    uszatekmis
    Level 11  
    Posts: 22
    Rate: 2
    Board Language: polish
    p.kaczmarek2 wrote:
    .
    But it's better to return to the subject of the nest - and so I'll ask, have you seen this feature?
    Charts in OpenBeken - configurable measurement history hosted on an IoT device .
    At my place it is fired up on such sockets.


    I have read that there is something like this. But in my case, due to the large number of different types of sensors (in total it will add up to more than 50 of various types - temperature, humidity, power, voltage, brightness, opening etc etc) I went into aggregating the results on the Home Asisstant side. And if I want partial results, that's not a problem either.
  • #10 21479006
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14400
    Help: 650
    Rate: 12330
    And you will have these 50 devices connected via WiFi?

    After changing the firmware, you can also always connect an additional sensor to any device on free pins. It is only worth ensuring that the method of connection makes sense (measuring the temperature outside and not inside the case, for example).
    Helpful post? Buy me a coffee.
  • #11 21479012
    uszatekmis
    Level 11  
    Posts: 22
    Rate: 2
    Board Language: polish
    p.kaczmarek2 wrote:
    And these 50 devices you will have connected via WiFi?
    .

    I will not "be" but "have" connected.
    Not all at once of course, as some are battery operated devices most of their lives "sleeping" but waking up at events.
    I have quite an extensive home network infrastructure, several switches, several APs, several wireless networks, UPS. Somehow it's taken on a life of its own over two years. And I still integrate new things and have new ideas. Such a hobby ;-) .

    Added after 9 minutes:

    But I also have a question about the socket being the subject.
    I want to add functionality to temporarily switch off the LEDs (so they don't light up at night).
    Currently I also use switching the role of the LED depending on the state of the mains connection. Maybe I will paste a piece of code.

    backlog startDriver BL0942; startDriver NTP; PowerSave 1;
    alias mode_none backlog setPinRole 6 LED_n; setPinChannel 6 0;
    alias mode_wifi setPinRole 6 WifiLED_n
    alias mode_relay backlog setPinRole 6 LED_n; setPinChannel 6 1;
    
    ntp_setServer TUTAJ_ADRES_SERWERA_NTP_W_LAN
    ntp_timeZoneOfs 1
    mode_wifi
    
    addChangeHandler WiFiState == 4 mode_relay 
    addChangeHandler WiFiState != 4 mode_wifi
    addClockEvent 22:00:00 0xFF 234 mode_none
    addClockEvent 06:00:00 0xFF 123 mode_relay
    
    .

    In theory this should work - at 22:00 switch the LED off and at 6:00 set it to Channel 1 (i.e. Rel status). Channel 0 is always 0.
    It should - but it doesn't work. If I force Channel 0 to change manually, then the LED state changes.
    Do I then need to add SetChannel 0 0 in mode_none ?

    Added after some time: .

    I have dealt with. Actually you have to add this SetChannel but also to make the diode light up according to the relay status when returning to relay mode you also have to take care of that.

    
    alias mode_none backlog setPinRole 6 LED_n; setPinChannel 6 0; SetChannel 0 0
    alias mode_wifi setPinRole 6 WifiLED_n
    alias mode_relay backlog setPinRole 6 LED_n; setChannel 0 !$Channel1; setPinChannel 6 1
    
  • #12 21480625
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14400
    Help: 650
    Rate: 12330
    I didn't have time to write back, but overall you're right, there is a tiny bug - setPinChannel doesn't set the channel value. I'll try to add a test and fix the handling of this situation.

    I only see one bug:
    
    setChannel 0 !$Channel1;
    
    .
    As it is:
    
    setChannel 0 !$CH1;
    
    .


    And soon it will be possible to script in Berry too.
    Helpful post? Buy me a coffee.
📢 Listen (AI):

Topic summary

✨ The discussion focuses on changing the firmware of the LTC LXU407 smart plug, which uses the BK7231N chip, to enable cloud-free operation with Home Assistant via LocalTuya integration. The device is compact and features a unique triangular screw for opening the case, revealing a Beken chip inside. Attempts to flash the firmware with tuya-cloudcutter (soft 1.1.8) were unsuccessful. Contributors share experiences with similar devices, noting variations in assembly such as glued versus screwed cases. Firmware dumps without sensitive data were shared and added to open repositories for analysis and development. The device configuration includes power monitoring and uses the BL0942 energy measurement chip. Discussions also cover calibration procedures via a WebApp, scripting for LED control to disable indicators at night, and potential firmware bugs related to pin channel settings. The conversation references related devices and firmware projects, including OpenBeken and FlashDumps repositories, and highlights the possibility of adding sensors and using IoT-hosted measurement history charts. The user maintains a large home network with multiple sensor types integrated into Home Assistant.
Generated by the language model.

FAQ

TL;DR: For Home Assistant users converting the LTC LXU407 to fully local control, the thread shows 3 confirmed GPIO roles and one practical rule: "calibration is always a must." Open the plug via the hidden triangular screw, flash through rear test pads with pogo pins, then use OpenBeken with the BL0942 driver and post-flash calibration for accurate power data. [#21478189]

Why it matters: This FAQ gives a repeatable, low-damage path from Tuya firmware to OpenBeken on a compact BK7231N smart plug.

Option Cloud status What the thread confirms Best fit
LocalTuya Cloud not required after setup The plug already worked in Home Assistant this way Keep stock firmware, local control
OpenBeken Fully reflashed Relay, LED, button, BL0942, scripts, and calibration were discussed Full local firmware control

Key insight: The LTC LXU407 is unusually serviceable for a compact plug because the main obstacle is a hidden triangular screw, not permanent glue. Once opened, the rear pads make repeat flashing practical with pogo pins.

Quick Facts

  • The confirmed OpenBeken mapping for the LTC LXU407 is GPIO 6 = LED_n/WifiLED_n, GPIO 9 = Btn, GPIO 26 = Rel, with startDriver BL0942 and PowerSave 1 used at startup. [#21474564]
  • The case uses 1 hidden screw under the sticker, and its head is a triangular keyway, which explains why the plug can look glued shut before teardown. [#21474564]
  • The owner had about 12 similar sockets left to convert, which is why a non-solder flashing method mattered in real use. [#21474942]
  • Night LED control was scheduled with 22:00:00 to disable the LED and 06:00:00 to restore relay-status indication, using OpenBeken clock events. [#21479012]
  • The same user planned for more than 50 mixed sensors and devices in Home Assistant, so central aggregation was preferred over storing all history inside each plug. [#21478988]

How do I open the LTC LXU407 smart plug without destroying the case, and where is the hidden screw located?

Open it by removing the sticker first, because the hidden screw sits underneath it and uses a triangular head. Then unscrew it, lift the top carefully, peel back the stick-on antenna, and push the PCB out from the pin side. The successful method here was: 1. remove the sticker and screw, 2. lift the top gently, 3. tap the pin bases out of the plastic to free the board. [#21474564]

What is the correct pin configuration for flashing the LTC LXU407 smart plug with a BK7231N chip and BL0942 energy metering?

The confirmed functional mapping is GPIO 6 for the LED, GPIO 9 for the button, and GPIO 26 for the relay. The thread lists them as 6 = LED_n/WifiLED_n, 9 = Btn 1, and 26 = Rel 1, and the same roles appear again in the JSON template added to the device database. [#21478189]

Which OpenBeken startup command and pin roles should I use for the LTC LXU407 to get the relay, button, LED, and BL0942 working?

Use backlog startDriver BL0942; PowerSave 1; and assign GPIO 6 to LED_n, GPIO 9 to Btn, and GPIO 26 to Rel. For Wi-Fi indication, the thread also uses an alias that temporarily switches GPIO 6 to WifiLED_n, then returns it to relay-state LED behavior after connection. [#21474564]

Why does the voltage reading on the LTC LXU407 with BL0942 appear too high after flashing, and how should I calibrate it?

The voltage reads high because the raw post-flash measurement is not calibrated for this hardware. The thread states that voltage was usually overestimated and that calibration is required, with WebApp calibration described as easy and recommended after conversion, especially when doing several plugs in one batch. [#21474910]

What is a pogo pin P50-B1, and why is it useful for flashing BK7231N devices without soldering?

"Pogo pin P50-B1 is a spring-loaded contact pin that makes temporary electrical contact, avoiding permanent solder joints during repeated flashing." It was chosen here because the owner had many plugs to rework, and pressing pogo pins onto the rear pads was faster than soldering wires onto every BK7231N board. [#21474564]

What is BL0942, and how does it differ from BL0937 in smart plugs with power monitoring?

"BL0942 is an energy-measurement chip that provides power-related readings in a smart plug, and this LXU407 uses it with the OpenBeken BL0942 driver." In this thread, BL0937 appears only as the metering chip used in older or similar plug models, while the LXU407 itself is consistently identified as BK7231N plus BL0942. [#21478412]

How does OpenBeken compare with LocalTuya for making Tuya smart plugs cloud-free in Home Assistant?

LocalTuya already gave local Home Assistant control here, but OpenBeken replaced the firmware completely. The owner used LocalTuya without needing the cloud, yet still wanted a full firmware change for a more complete cloud-free setup with direct scripting, device templates, and onboard features like charts. [#21474564]

What is the easiest way to back up the original Tuya firmware from a BK7231N smart plug before reflashing it?

Make a flash dump before pairing, then submit only an unpaired backup. The thread confirms that unpaired dumps are preferred so no SSID leaks, and one safe dump from this plug was later published after being redone on a test access point. The practical sequence was: 1. dump first, 2. verify it is unpaired, 3. flash new firmware after backup. [#21478189]

Why does setPinChannel not immediately change the LED state in OpenBeken, and when do I need to use SetChannel as well?

setPinChannel changes the pin-to-channel link, but it does not immediately set the channel value. The thread identifies this as a small bug, so the LED may not change until the channel itself updates. Use SetChannel as well when you need an immediate LED state, such as forcing channel 0 to 0 for LED-off mode. [#21480625]

How can I configure an OpenBeken script to turn the smart plug LED off at night and restore relay-status indication in the morning?

Create one alias that maps GPIO 6 to LED_n on channel 0 and forces SetChannel 0 0, then another alias that restores relay mode and updates channel 0 from relay state. The working schedule used addClockEvent 22:00:00 0xFF 234 mode_none and addClockEvent 06:00:00 0xFF 123 mode_relay, with mode_relay corrected to use !$CH1. [#21480625]

What causes some Tuya smart plugs like the LTC LXU407 or NAS-WR07W to be easy to open while others seem heavily glued?

Build variation causes it, not one universal enclosure design. The discussion says some series are tightly glued while others open easily, and even similar devices from the same family can differ. In this LXU407 case, the plug was not glued at all and was held mainly by one unusual screw plus the plastic pin mounts. [#21474910]

Where should I submit an unpaired Tuya flash dump and an OpenBeken JSON template so the LTC LXU407 can be added to the device database?

Submit the unpaired Tuya dump to the FlashDumps collection and add the OpenBeken JSON template to the webapp device list source. The thread explicitly points to the flash-dump repository for safe, unpaired backups and to the devices.json source list used by the searchable OpenBeken device database. [#21476696]

What should I watch out for when using a hammer, clamp, or other mechanical method to remove the PCB from a compact smart plug safely?

Use controlled force on the metal pin bases, not random force on the case walls or PCB edges. The successful teardown here involved gently tapping the bases of the mains pins out of the plastic, while the first plug survived worse than later attempts. That means technique matters, especially on compact housings with strong plastic and tight internal fits. [#21474942]

How can I use OpenBeken charts on a power-monitoring socket, and when is it better to store measurements in Home Assistant instead?

Use OpenBeken charts when you want measurement history hosted directly on the socket, but store data in Home Assistant when you manage many device types centrally. The thread says charts run on similar sockets, yet the owner chose Home Assistant aggregation because the installation would exceed 50 devices across power, temperature, humidity, brightness, and opening sensors. [#21478988]

What extra sensors can be connected to free pins on BK7231N devices after flashing OpenBeken, and how should I choose a sensible mounting method?

You can connect additional sensors to free pins after flashing, but mount them where the reading remains physically meaningful. The thread gives temperature as the clearest example: measure outside the case, not inside it. That rule matters because enclosure heat, mains parts, and cramped placement can distort any sensor you add to a BK7231N device. [#21479006]
Generated by the language model.
ADVERTISEMENT