ESP32 – Power Plug with Energy Meter

For many years, the Dutch retailer Action has sold affordable smart‑home devices under the LSC Smart Connect brand. These products are extremely popular due to their low price point, but internally the hardware is often far more capable than expected. Earlier generations frequently used ESP8266 modules, which made reflashing and custom firmware relatively easy.

Newer hardware revisions, however, increasingly rely on alternative Wi‑Fi chips with closed firmware, limited documentation, and poor community support. This makes long‑term ownership, security auditing, and integration into open ecosystems much harder.

In this three‑part series, we explore three LSC smart plugs:

  1. The classic “old” plug (Previous Blog)
  2. A newer hardware revision without power monitoring (previous blog)
  3. The smart plug with integrated energy monitoring (this blog)

This article focuses on converting the LSC Smart Power Plug with Power Monitor into a fully open‑source, native Apple HomeKit smart plug — with no cloud dependencyOTA updates, and full energy metering support.

Power Plug

What This Project Covers

In this step‑by‑step guide, you will learn how to:

  • Safely open the LSC Smart Power Plug
  • Identify the internal hardware and PCB layout
  • Remove the original Wi‑Fi module
  • Install an ESP8685‑WROOM‑03 (ESP32‑C3)
  • Flash and configure the ESP32 Life Cycle Manager (LCM)
  • Generate a HomeKit QR code based on the device MAC address
  • Flash custom HomeKit firmware
  • Pair the device with Apple Home
  • (Optional) Enable overcurrent protection via menuconfig

The end goal? A fully custom, native HomeKit smart plug — without cloud dependency.

Why Modify This Smart Plug?

There are more smart devices than ever—but not all of them truly belong to you. Most budget IoT devices depend on:

  • Cloud servers
  • Vendor accounts
  • Proprietary apps
  • Remote infrastructure
  • Unknown data collection

This creates the privacy trap: You buy the device, but the manufacturer controls it. If you want to understand the deeper implications of cloud-based IoT products, read this article: Source: https://www.studiopieters.nl/why-you-should-or-shouldnt-buy-a-smart-plug-from-action

By replacing the firmware, you regain:

  • Full privacy
  • Local device control
  • Firmware ownership
  • Offline operation
  • No telemetry
  • Long-term support independence

Difficulty Level

Rating: 2 / 5 Soldering Irons – Beginner friendly

Beginner‑friendly, provided you are comfortable with:

  • Desoldering and soldering
  • Working with small SMD pads
  • Using a serial flasher
  • Command‑line tools (esptoolidf.py, Docker)

⚠️ HIGH VOLTAGE WARNING

⚡ DANGER: MAINS ELECTRICITY CAN KILL

This project involves a device that connects directly to 230V AC.

  • Always unplug the device before opening
  • Never work on a live circuit
  • Use insulated tools
  • Avoid touching exposed conductors

The author accepts no liability for damage, injury, or accidents.
If you are unsure — consult a licensed electrician.

Hardware – Product Information

From the packaging:

  • Brand: LSC Smart Connect
  • Product: Smart Power Plug with Power Monitor

Article number:

  • 3202087

Markings on the device:

3202087 Max 16A 3680W μ T35
220–240V~ 50/60Hz
AL M21167 Made in P.R.C.

Why We Replace the Original Chip

Multiple hardware revisions exist for this product.

VersionOriginal ModuleNotes
3202087CB2S / BK7231NClosed ecosystem

The BK7231 platform is difficult to flash and lacks a modern, open development ecosystem. Instead of trying to work around these limitations, we fully replace the module with an ESP8685‑WROOM‑03 (ESP32‑C3).

This provides:

  • Native Apple HomeKit support
  • OTA updates via LCM
  • Fully open‑source toolchain
  • Active ESP32 community support
  • Direct integration with the BL0937 energy‑metering IC

Opening the Plug

Tools Required

  • Plastic spudgers
  • Thin metal pry tool

Steps

  1. Insert a plastic spudger between the shell halves.
  2. Create a small gap.
  1. Slide in a metal spudger.
  2. Slowly pry toward a corner.
  3. Release each of the four clips.
  1. The shell opens cleanly.

Pin Mapping (Verified)

FunctionOriginal PinESP8685 GPIO
RelayP8GPIO6
ButtonP7GPIO7
Red LEDP6GPIO3
Blue LEDP10GPIO20
CF (BL0937)P26GPIO4
CF1 (BL0937)P24GPIO5
SEL (BL0937)P11GPIO21

GPIO assignments for BL0937 can be defined in firmware configuration.)

Removing the Original Module

Before installing the new ESP8685-WROOM-03, we first need to safely remove the original module from the PCB. This step is critical: damaging the pads will make the entire project much harder (or impossible). Fortunately, with the right tools, this is a clean and controlled operation.

Tools Required

For this process, I strongly recommend:

  • TS100/101 digital soldering iron (or equivalent temperature-controlled iron)
  • Desoldering wick / copper braid remover
  • Liquid flux (very important!)
  • Isopropyl alcohol and cotton swabs

Why the TS100/101? It heats quickly, maintains stable temperature, and is powerful enough for multi-pin modules without overheating the board.

Step 1 – Identify the Original Chip

Depending on your plug revision, you will see:

  • CB2S / BK7231N

Both are surface-mounted Wi-Fi modules with edge solder pads around the module. Before removal, take high-resolution photos of the PCB from multiple angles. These will be invaluable if anything goes wrong.

Step 2 – Add Flux Generously

Apply liquid flux along every solder pad edge of the module.

Flux:

  • Lowers melting temperature
  • Improves heat transfer
  • Prevents pad lifting
  • Makes solder flow correctly

Never attempt desoldering without it.

Step 3 – Remove the Module

Set the TS100 to 350–380°C.

  1. Place desoldering braid on one row of pads
  2. Press with the hot iron
  3. Let solder absorb into the wick
  4. Repeat across all sides
  5. Once all joints are clean, gently lift the module.

Do not pull if resistance remains. Missing even one joint can tear a pad.

Step 4 – Clean the Pads

After removal:

  1. Remove remaining solder with braid
  2. Clean flux using isopropyl alcohol
  3. Inspect for lifted pads under magnification

Your board should now show:

  • Clean alignment
  • Flat copper pads
  • No burned areas
  • No solder bridges

Preparing the ESP8685‑WROOM‑03

Now that the old module is removed we can prepare the replacement module.

Magnetic Programmer

Instead of soldering headers, I built a magnetic programmer jig, you need a 3D printer. If you do not have a 3D printer you can also solder some wires to the programming pads. source: https://www.studiopieters.nl/esp8685-wroom-03 or 3D printer magnetic programmer jig Source: https://www.studiopieters.nl/esp8685-wroom-03-programmer

Benefits:

  • No soldering
  • Stable contact
  • Works with esptool
  • Fast flashing
  • Low risk

Erase Flash & MAC Address

esptool.py erase_flash

Example output:

Chip is ESP32-D0WD-V3
Erasing flash...
Chip erase completed successfully
MAC: 68:25:dd:f0:40:94

⚠️ Save your MAC address — you need it when you generate the QR-Code.

Generate HomeKit QR Code

Do it yourself: https://www.studiopieters.nl/guide-to-esp32-homekit-qr-codes
Do it yourself: https://github.com/AchimPieters/esp32-homekit-qrcode

Example:

./gen_qrcode 7 693-41-208 M4T8 cc8da2ddafe0 new/qrcode.png

Meanings:

  • 7 = Outlet accessory
  • 693-41-208 = Setup code
  • M4T8 = Setup ID
  • cc8da2ddafe0 = MAC (no colons)

This will generate an images like this one. you can use only the QR-code if you want, or the whole image and print it as a sticker, and paste it on your plug.

Or download precompiled qr-code here

Install Life Cycle Manager (LCM)

LCM (Life Cycle Manager) allows OTA (Over The Air) installations and updates without needing to reopening the device ever again!

Do it yourself:https://github.com/AchimPieters/esp32-lifecycle-manager

Or download precompiled files here

Go to the folder where you have placed the files and Flash:

python -m esptool --chip esp32c3 -b 460800 \
--before default_reset --after hard_reset write_flash \
--flash_mode dio --flash_size 4MB --flash_freq 80m \
0x0 build/bootloader/bootloader.bin \
0x8000 build/partition_table/partition-table.bin \
0xe000 build/ota_data_initial.bin \
0x20000 build/esp32-lifecycle-manager.bin

Installing the New Chip and Soldering the ESP8685-WROOM-03

With the old module removed and the pads cleaned, it’s time to install the new brain of your smart plug: the ESP8685-WROOM-03. This is the most delicate part of the entire upgrade – but with patience and the right technique, it’s completely manageable even for beginners.

Step 1 – Align and Tack One Corner

  1. Position the ESP8685 on the footprint (one side 5 and other side 6 pads)
  2. Align all edges
  3. Melt one pre-tinned corner pad
  4. Let it cool

Now check alignment on all sides. If misaligned:

  • Reheat the tack joint
  • Adjust the module
  • Retack once perfect

Step 2 – Solder Opposite Corner

Once alignment looks correct:

  • Solder the opposite corner
  • Check alignment again

Once two corners are fixed, the module will not shift.

Step 3 – Drag Soldering the Pads

Apply generous flux along one row of pins.

Now:

  1. Load a small solder bead on your tip
  2. Drag slowly across pins
  3. Let surface tension pull solder into place
  4. Repeat on the other side

Do not worry if you create bridges — they are easily removed later.

Step 4 – Remove Solder Bridges

If pins are shorted together:

  1. Add flux
  2. Place desoldering braid
  3. Lightly press with the iron
  4. Let solder wick away
  5. Re-inspect

Your goal:

  • Clean joints
  • No blobs
  • No bridges
  • No lifted pads

Step 5 – Final Cleaning & Inspection

Clean the board using:

  • Isopropyl alcohol
  • Cotton swabs

Inspect carefully:

  • All pads connected
  • No pins floating
  • No cold joints
  • No heat damage
  • No debris

Spend time here. Visual inspection prevents 90% of failures.

Step 6 – Continuity Check (Recommended)

Using a multimeter:

  • Check no short circuits between neighboring pins
  • Confirm ground connections
  • Verify relay pin connects to ESP GPIO
  • Confirm power rail continuity

This step saves debugging later.

What You’ve Achieved

At this point:

  • The old chip is gone
  • A modern ESP is installed
  • Your firmware control begins
  • OTA updates are possible
  • Privacy is restored

This is the exact moment your device transitions from: consumer product → personal hardware

This part is somewhat difficult for a beginner, but doable. So if you want to write your own code read the Do it yourself links. If not you can simply use the code I already wrote and compiled, just go to Install via LCM.

Do it yourself: https://github.com/AchimPieters/esp32-homekit
Do it yourself: https://www.studiopieters.nl/esp32-homekit-development

Config:

homekit_server_config_t config = {
  .accessories = accessories,
  .password = "693-41-208",  
.setupId = "M4T8",
};

Build:

docker run -it -v ~/ESP32-Power-Plug:/project -w /project espressif/idf:v5.4
idf.py set-target esp32C3
idf.py build

Produces: main.bin

Firmware Behavior

The firmware exposes a HomeKit Outlet with extended energy characteristics:

1. Relay & Blue LED

  • Blue LED always follows relay state
  • Relay is the single source of truth

2. Red LED – Wi‑Fi / Provisioning Status

  • ON during boot
  • OFF when Wi‑Fi is connected
  • ON if Wi‑Fi configuration is missing or fails

3. Button Actions

  • Single press: toggle relay + notify HomeKit
  • Long press (10s): factory reset + reboot via LCM

4. Energy Metering (BL0937)

A dedicated task continuously samples the BL0937 and updates HomeKit characteristics:

  • Voltage
  • Current
  • Power
  • Energy (kWh)

5. Optional Overcurrent Protection

When enabled in menuconfig:

  • Relay trips if current exceeds threshold
  • Debounce prevents false positives
  • HomeKit state updates immediately
  • Optional cooldown before re‑enable

Sign Firmware

Open anew terminal window go to the directory ESP32-Power-Plug-with-Energy-Meter and run:

openssl sha384 -binary -out build/main.bin.sig build/main.bin
printf "%08x" "$(wc -c < build/main.bin)" | xxd -r -p >> build/main.bin.sig

Or just use my repository and read further below.

Install via LCM

  1. Connect to WiFi: LCM-XXXXX
  2. Portal opens automatically
  3. Enter home WiFi credentials
  4. Firmware source: AchimPieters/ESP32-Power-Plug-with-Energy-Meter
  5. Enable GPIO3 (Red LED in this case) and Led Level On
  6. Click Join

Installation begins, the LED starts blinking. When done the Device reboots.

Pair with Apple Home

Add HomeKit-power plug Devices to HomeKit

  1. Open the Home app.
  2. Scan the device’s QR-Code.
  3. Follow the device-specific instructions.
  4. Name your device and assign it to a room.

Apple Home vs Eve Home – Why Eve Matters

Apple’s Home app intentionally exposes only a minimal feature set. While this is fine for basic on/off control, it does notprovide:

  • Firmware update UI
  • Detailed power metrics
  • Energy history graphs
  • Advanced accessory diagnostics

This is where the Eve Home app becomes essential.

What Eve Home Adds

Using Eve (free, no account required), you gain access to:

  • Full visibility of custom HomeKit characteristics
  • Live voltage, current, power, and energy readings
  • Historical graphs (hour / day / week / month)
  • Firmware update interface (OTA via LCM)
  • Debug‑friendly accessory information

Firmware Updates via Eve

To update firmware:

  1. Install the Eve Home app
  2. Select the smart plug
  3. Open accessory details
  4. Choose Firmware Update
  5. Wait for OTA process to complete

Apple Home itself does not offer this functionality.

Pairing with Apple Home

  1. Open the Home app
  2. Scan the HomeKit QR code
  3. Follow the pairing steps
  4. Assign the plug to a room

Done.

Update Firmware

When You want to update your plug with a new release of the firmware you have to download the EVE App. This because the Home App, doesn’t has a building update function. In the Eve App select your device in this case your Power plug and hold it until you see “Turn On” and “Show in (the room you selected)”, select the room, here you only see the homkitplu and turn on or off? press between the homekitplug and the on/off option, and a new screen will magically appear here select FirmwareUpdate, this whole takes a few minutes, including the reconnection to HomeKit.

Final Result

You now have:

  • A smart plug you truly own
  • Native Apple HomeKit integration
  • OTA firmware updates
  • No cloud dependency
  • No vendor lock‑in
  • No telemetry or spyware
  • Fully open‑source firmware
  • Long‑term usability

This device has transitioned from a disposable consumer product into personal, maintainable hardware.

Links & Resources

More projects
https://www.studiopieters.nl

ESP32 Life Cycle Manager
https://github.com/AchimPieters/esp32-lifecycle-manager

HomeKit QR Generator
https://github.com/AchimPieters/esp32-homekit-qrcode

ESP32 HomeKit Framework
https://github.com/AchimPieters/esp32-homekit

error: Content is protected !!
Scroll to Top