The Belling BL0942 appears inside some Wi-Fi smart plugs, metering relays and DIN-rail energy-monitoring products. When a compatible device runs ESPHome, the bl0942 component can publish AC voltage, current, active power, accumulated energy and mains frequency directly to Home Assistant. You do not need to invent your own wattage formula or repeatedly poll an external cloud service: the metering chip already calculates the quantities and exchanges data with the device’s microcontroller over UART.
This guide explains what to verify before selecting a smart plug, how the BL0942 UART configuration works, why factory calibration should be preserved where possible, and how to avoid incorrect energy statistics. The worked YAML is an ESP32-host example for an already verified, electrically isolated BL0942 UART interface. Most commercial smart plugs do not expose an isolated interface; their hardware-specific firmware must instead use the exact MCU platform, GPIO map and safety features documented for that model.
Safety note: A 3.3 V UART signal is not evidence of galvanic isolation. In many mains-powered smart plugs, microcontroller ground and programming pads can be at a hazardous mains potential. Do not connect a powered, opened plug to a USB adapter, PC, development board, logic analyser or grounded oscilloscope. Use an intact, appropriately rated enclosure for operation; programming or repair of a non-isolated appliance requires a verified device-specific safe procedure and a suitably qualified person. This is a firmware and data-interpretation guide, not instructions to wire an exposed metering IC to live mains.
What BL0942 measures—and what it does not
The BL0942 samples the analogue voltage and current signals supplied by the finished metering product. The ESPHome component reads the IC’s results, applies reference coefficients and publishes sensor entities. The actual usable mains voltage and load-current ranges belong to the complete product, including its divider, current-sense element, relay, connectors and PCB layout. They cannot be inferred from the BL0942 chip name alone.
| Entity | Unit | Meaning in Home Assistant |
|---|---|---|
| Voltage | V | RMS AC voltage at the metered input, using the product’s sensing circuit. |
| Current | A | RMS current through the product’s current-sense path. |
| Power | W | Active/real power, accounting for the measured voltage–current relationship. |
| Energy | kWh | Accumulated energy calculated by the BL0942; behaviour on reset needs checking. |
| Frequency | Hz | Measured AC line frequency; normally close to the local nominal supply. |
A 100 W heater operating for three hours consumes roughly 0.3 kWh. Watts describe its current rate of energy use; kilowatt-hours describe a quantity used over time. Neither one equals the current reading in amperes multiplied by a fixed 230 V for every appliance: motors, switch-mode supplies and other non-resistive loads can have a power factor below one. A BL0942 measurement of active power is more informative than a crude voltage × current estimate.
The BL0942 is normally a single-channel AC meter. It cannot distinguish separate downstream loads behind a power strip, cannot individually measure three phases, and cannot provide an independent solar-export register unless the actual device and integration expose a reliable directional measurement. A single-channel smart plug is best treated as an individual-device submeter, not as a replacement for your electricity supplier’s billing meter.
Confirm the complete product before flashing
Commercial smart plugs may use an ESP8266, ESP32, Beken, Realtek or another controller. Devices sold under the same retail name can use different boards or firmware revisions. A YAML file that works for one model may choose the wrong UART, drive the wrong relay polarity, omit a safety cutoff or fail to boot on another. Confirm the exact hardware revision and find a device-specific configuration before replacing stock firmware.
- Identify the host MCU and its supported ESPHome platform. A Beken-based Tuya plug does not become an ESP32 because its metering chip is BL0942.
- Check the actual UART TX/RX mapping between the MCU and the BL0942. The host GPIO numbers in this article are illustrative only; use the device schematic or a trustworthy model-specific configuration.
- Preserve local button, relay, indicator LED, on-boot relay state, and any thermal or overcurrent protections. A sensor-only example must not replace the complete firmware of a switching appliance.
- Record the product’s operating voltage, plug type and continuous-load rating. A marketed “20 A” label does not by itself establish what an individual outlet, plug, thermal environment or supply circuit can safely sustain.
- Keep a backup of working YAML, Wi-Fi and API secrets, device identity and original calibration values. Do not assume a firmware change will preserve the energy counter.
The ESPHome Devices BL0942 smart-plug example illustrates a real-world device, but its Beken pin names, input/output assignments and switching configuration belong to that model. They should not be copied into a generic ESP32 board or an unverified Tuya revision. Prefer an already supported, enclosed product over designing a mains metering board from a bare IC.
UART interface and safe host-side connections
ESPHome specifies 4800 baud, one stop bit, and both TX and RX for the BL0942 component. The MCU sends requests to the chip as well as receiving measurements. A receive-only UART definition can leave the integration without working polls or initialisation. Unlike an I²C sensor, the BL0942 does not appear in an I²C address scan.
For a verified isolated evaluation assembly only, an ESP32 can use GPIO17 for its UART TX and GPIO16 for RX. The conceptual signal mapping is host TX → metering interface RX, host RX ← metering interface TX, and a shared reference ground only on the known-safe isolated side. Do not infer that an intact commercial smart plug contains such an isolation barrier: most inexpensive plug boards do not. Supply voltage, logic-level compatibility and isolation need device-specific verification.
# Host-side illustration ONLY: a verified, isolated,
# logic-level-compatible BL0942 UART interface is required.
# GPIOs do not describe any commercial smart plug.
uart:
id: energy_uart
tx_pin: GPIO17
rx_pin: GPIO16
baud_rate: 4800
stop_bits: 1
A second UART may coexist with other UART sensors when the controller has sufficient hardware peripherals and a suitable GPIO allocation. Make the BL0942 bus explicitly identifiable with id: energy_uart and bind the sensor using uart_id: energy_uart. If logs and metering share the same UART/pins on a board, configure the logger according to that board’s documented requirements; do not blindly disable all logging merely to silence an error.
Complete ESPHome configuration for an isolated ESP32 host
The following example is a complete host-side ESPHome configuration for a deliberately isolated test/evaluation interface. It does not provide a mains front end, a relay driver or firmware suitable for a commercial plug. Replace the board target, credentials and UART pins only after verifying your actual isolated hardware. For a commercial plug, retain the full model-specific device YAML and merge only the uart:/bl0942 sensor settings that match that product.
esphome:
name: bl0942-monitor
friendly_name: BL0942 Monitor
esp32:
board: esp32dev
framework:
type: esp-idf
logger:
api:
encryption:
key: !secret bl0942_api_key
ota:
- platform: esphome
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: "BL0942 Monitor Fallback"
password: !secret fallback_ap_password
captive_portal:
# GPIO map valid only for an electrically isolated
# evaluation interface. Not a commercial smart-plug pinout.
uart:
id: energy_uart
tx_pin: GPIO17
rx_pin: GPIO16
baud_rate: 4800
stop_bits: 1
sensor:
- platform: bl0942
uart_id: energy_uart
line_frequency: 50Hz # Use 60Hz where appropriate.
update_interval: 10s
voltage:
name: "AC Voltage"
current:
name: "AC Current"
power:
name: "Active Power"
energy:
name: "Energy"
frequency:
name: "AC Frequency"
The api.encryption.key is a Home Assistant native-API credential, not a BL0942 UART password or energy-meter calibration key. Generate and keep it in your ESPHome secrets. The current ESPHome OTA format uses a list under ota:, as shown; when updating existing devices, follow ESPHome’s documented migration path for their currently installed OTA authentication settings. If you are only adding monitoring to an existing device, do not replace its existing Wi-Fi, API, OTA or other top-level entries with duplicates.
A 10-second update interval is useful for a responsive individual-device dashboard, but it is not a guarantee of 10-second reporting if the UART communication fails or the MCU is offline. ESPHome’s documented default BL0942 interval is 60 seconds. For slow, continuous loads, 30–60 seconds may be perfectly adequate; for rapid appliance state changes, shorter intervals can improve graphs but increase entity updates.
Adding BL0942 to an existing smart-plug YAML
For an already flashed and working product, the simplest safe software change is often to leave all its GPIO controls untouched and add the following fragment using its verified UART pins. Insert the entries under the existing top-level uart: and sensor: sections or adapt the example to the form already in use; do not create conflicting duplicate definitions.
# FRAGMENT ONLY: verified device-specific TX and RX required.
# Merge into existing YAML; do not overwrite switch/relay safety.
uart:
id: plug_meter_uart
tx_pin: YOUR_VERIFIED_TX_GPIO
rx_pin: YOUR_VERIFIED_RX_GPIO
baud_rate: 4800
sensor:
- platform: bl0942
uart_id: plug_meter_uart
line_frequency: 50Hz
voltage:
name: "Plug Voltage"
current:
name: "Plug Current"
power:
name: "Plug Power"
energy:
name: "Plug Energy"
frequency:
name: "Plug Frequency"
The uppercase GPIO placeholders intentionally prevent this fragment from being mistaken for a universal, ready-to-flash smart-plug pinout. Replace them with pins verified for your exact model, then validate the YAML. If ESPHome reports that a UART is already defined, merge the BL0942 sensor into the existing UART and set uart_id accordingly. Only one driver should own a particular metering UART: two components sending commands to the same BL0942 can corrupt responses.
Calibration: why factory coefficients matter
ESPHome provides voltage_reference, current_reference, power_reference and energy_reference. They scale the chip’s raw measurements into volts, amperes, watts and kWh. The calibration coefficients depend on the completed device’s voltage-divider and current-sensing hardware; copying coefficients from a different plug model may yield plausible-looking but incorrect figures.
ESPHome documents generic defaults of voltage_reference: 15883.34116 and current_reference: 251065.6814. They are starting values, not universal calibration for every BL0942 product. In an original Tuya firmware conversion, device-specific factory values may be stored as data points or flash key-value settings. If a supported device configuration supplies them, preserve those values before any firmware changes. Avoid scraping or modifying unidentified flash partitions; offsets and encoding are not universal.
When checking calibration, compare with a trusted, correctly rated plug-in power meter using the intact, enclosed smart plug under normal operation. A stable, ordinary resistive load makes initial comparison easier because its power factor should be close to one, but never exceed the product’s safe load or use a high-current heater merely to get more resolution. Do not open the enclosure to attach instruments to energized circuitry.
The documented reference relationship is new_reference = displayed_value × old_reference ÷ independently_measured_value. For example, with a reference of 15,883.34, a displayed voltage of 226 V and a trusted comparison of 230 V, the adjusted value would be approximately 15,607.16. This is an illustrative arithmetic example, not the correct coefficient for your plug. Verify readings at more than one safe load and consider the reference instrument’s accuracy.
# Only if required by verified factory data or calibration.
# Add within your existing - platform: bl0942 entry.
# The numbers below illustrate the supported keys; they are
# generic defaults, NOT calibrated for your particular board.
voltage_reference: 15883.34116
current_reference: 251065.6814
# power_reference: <verified-device-specific-value>
# energy_reference: <verified-device-specific-value>
If you explicitly set voltage or current references, ESPHome can derive corresponding power and energy references. If you supply separate factory values for all four, keep their relationship consistent with the actual product. Do not adjust the power coefficient merely to force a preferred result while leaving voltage/current and accumulated energy visibly inconsistent. After changing coefficients, check both the instantaneous watt reading and the kWh accumulated over a meaningful test period.
Energy accumulation, resets and Home Assistant statistics
The BL0942 maintains an internal energy counter, which ESPHome reports as kWh. In the current component documentation, reset defaults to true: the chip is reset at ESPHome start-up, including its internal counters. Therefore the displayed energy value may start over after a reboot even though the appliance has continued operating. The underlying 24-bit counter can also wrap after enough accumulated energy. Do not mistake either event for energy being physically returned to the grid.
ESPHome’s source handles the counter as a sensor suitable for total_increasing, allowing downstream statistics to distinguish ordinary increases from legitimate counter resets. That is still not a guarantee of perfect accounting: a device that spends an hour offline with its metering chip unpowered cannot retrospectively measure that hour, while a reporting discontinuity, incorrect coefficients or an accidental entity replacement can create long-term statistics errors. Check how your exact hardware behaves after a deliberate firmware reboot before relying on annual cost figures.
Setting reset: false changes whether ESPHome explicitly resets the BL0942 at startup; it does not make a volatile hardware counter survive an actual loss of chip power, nor does it prevent natural counter wrap. For most users the right strategy is to leave the model-specific firmware’s reset choice intact, send the native energy entity to Home Assistant, and let Home Assistant’s recorder/statistics handle ordinary monotonic readings and real resets.
# OPTIONAL: include only when you have tested the actual
# BL0942 board, boot sequence and energy-counter behaviour.
# Under - platform: bl0942:
reset: false
Do not apply an ESPHome multiply: 0.001 filter to the BL0942 native energy sensor: ESPHome already publishes it in kWh. That factor is needed in some other power-to-energy recipes that first integrate watts into watt-hours; applying it here would shrink your energy readings by a factor of one thousand. Likewise, an additional integral sensor is not necessary merely to make this component report kWh.
Configure the Home Assistant Energy dashboard
Once the ESPHome device has joined Home Assistant, open the device page and verify five distinct entities. Confirm that voltage is near your local expected supply, current approaches zero with no connected load, active power changes with load, frequency is plausible and energy grows as the plug supplies a consuming appliance. The native energy entity must have an energy device class, compatible kWh unit and suitable total/total-increasing state class to appear in the Energy dashboard.
- In Home Assistant, open Settings → Dashboards → Energy and locate the individual-device energy area. Add the plug’s native kWh entity as a device consumption source.
- Do not add a smart plug as a second whole-house grid-import meter: its load is already included in the main electricity meter. Adding it twice to grid imports would double-count.
- Use a power gauge, history graph or statistics graph for the instantaneous watt reading. The energy entity is the one to use for cumulative usage and cost calculations.
- For “today”, “this week” and “this month” readings, use an appropriate Home Assistant Utility Meter helper against the verified source; validate its behaviour when the hardware counter resets.
- If an entity is missing, inspect Developer Tools → States for its device class, state class, unit and whether the state is numeric; then check Developer Tools → Statistics for any listed repair issues.
If you need a daily estimate from power because a particular device does not expose a trustworthy energy counter, Home Assistant can integrate watts over time. This is an alternative to the native kWh sensor, not a second source to sum with it. An integration helper needs regular, accurate power samples, and it cannot reconstruct missed usage while a smart plug is disconnected or switched off.
Useful, low-risk Home Assistant automations
The most helpful automations are often informational rather than remotely switching a potentially hazardous appliance. For instance, send a phone notification when a washing machine’s active power has stayed below a verified threshold for several minutes after it was previously running; the delay avoids false “finished” notifications during pauses. Alternatively, monitor a 24-hour energy total to identify an unexpectedly power-hungry dehumidifier or persistent standby load.
A power threshold is not a substitute for an appliance’s overcurrent or thermal safety system. A software automation that notices high watts only after several delayed readings is not a protective cutout. For heater, motor, charging and other high-power circuits, use equipment with correctly rated independent hardware protection; avoid using a hobby firmware rule as the sole safety mechanism.
Troubleshooting BL0942 readings
| Symptom | Likely checks |
|---|---|
| All five entities unavailable | Confirm the device actually runs ESPHome, that Wi-Fi/API connectivity works and that the sensor block is included in the active YAML. |
| Device online but all measurements stay unknown | Confirm MCU type, actual TX/RX pins, 4800-baud settings and that no other UART component owns the metering chip. |
| ESPHome logs show UART checksum or frame errors | Investigate wrong pinout, wrong UART peripheral, other devices sharing the port or incorrect logic-level assumptions; do not probe energized live pads. |
| Voltage plausible but power too high or low | Check factory calibration coefficients and compare with a known, safely rated reference meter and a stable resistive load. |
| Power negative on an ordinary consuming appliance | Verify device-specific sign conventions and load mapping. Do not use an absolute-value filter on a genuinely bidirectional installation. |
| Energy restarts from zero after reboot | Check BL0942 reset policy, power-loss behaviour and the resulting Home Assistant long-term statistics; the physical energy has not been refunded. |
| Energy grows in wildly incorrect units | BL0942 native energy is already kWh. Remove accidental extra Wh→kWh conversion and confirm calibration. |
| Frequency missing or implausible | Verify UART communication and nominal line_frequency configuration, then investigate hardware-specific calibration or firmware compatibility. |
| Plug becomes hot, trips, smells abnormal or shows damaged housing | Stop using it, disconnect it safely and have the product professionally assessed. Do not attempt to fix a hardware safety defect by changing ESPHome coefficients. |
How BL0942 compares with other metering options
Compared with the INA260, INA226 and INA228 articles in this series, BL0942 measures AC appliance consumption rather than DC bus current and battery energy. Its UART connection is different from the SPI ATM90E32 or I²C ADE7953. It is particularly convenient when an enclosed smart plug already contains the BL0942 and has a known ESPHome firmware profile, since its own metering hardware is built into the finished product.
A PZEM-016 module instead measures single-phase AC using a current transformer and communicates over RS485. An optical pulse reader observes an existing electricity meter without tapping into internal mains circuitry. Neither approach is a direct firmware replacement for the BL0942 inside a plug; choose based on the measurement location, installation safety, need for per-appliance control, local connectivity and the equipment’s actual approvals. For individual plug loads, retaining a factory-tested enclosed device may be much more practical than assembling a custom mains metering board.
Key takeaways
For a compatible BL0942 product, configure a real two-way UART at 4800 baud, preserve device-specific GPIO and factory calibration settings, and use the built-in kWh energy entity in Home Assistant. Verify whether the counter resets on reboot so that long-term statistics remain interpretable. Above all, separate UART voltage from electrical isolation: a 3.3 V test pad in a mains smart plug can still be dangerous, and a generic ESP32 wiring example never establishes that a commercial appliance is safe to probe.
Official documentation and further reading
- ESPHome: Belling BL0942 Energy Monitor — supported UART settings, calibration references, reset and measurement fields.
- ESPHome: UART Bus — pins, logger conflicts, debugging and framing settings.
- ESPHome Devices: BL0942 smart-plug example — a particular model’s board-specific configuration, not a universal pinout.
- Home Assistant: Energy management — grid meters versus individual device consumption.
- Home Assistant: Energy FAQ — required entity metadata and statistics troubleshooting.
- ESPHome: OTA updates — supported firmware update configuration.