Smart Gateways IEC 62056-21 USB-C optical infrared probe attached to a smart electricity meter using the built-in magnet.

Introduction

Reading professional electricity, water, heat, and gas meters used to be something only utilities and installers could do. Thanks to IEC 62056‑21, ESPHome, and modern optical probes, this data is now fully accessible for Home Assistant, Domoticz, and other home automation platforms.

In this in‑depth guide, you’ll learn how IEC 62056‑21 works, how to read meters using ESPHome, and why the Smart Gateways IEC 62056‑21 TTL Optical Infrared Probe is the most reliable hardware choice for both professionals and enthusiasts.

This article is written for:

  • Home Assistant power users
  • Energy monitoring enthusiasts
  • Installers and system integrators
  • Developers working with ESPHome and UART-based meters

Summary: ESPHome IEC 62056-21 Smart Meter Integration for Home Assistant

This article covers ESPHome integration with IEC 62056-21 smart meters, explaining how to use an optical infrared probe for electricity, water, and heat meters. It details bidirectional (modes A, B, C) and unidirectional (mode D) communication, OBIS codes, UART configuration, sensor and text sensor setup, switches and binary sensors, data conversion, and troubleshooting tips. Ideal for Home Assistant users seeking reliable, fully automated smart meter readings.


What is IEC 62056‑21?

IEC 62056‑21 (formerly IEC 61107) is an international standard for local data exchange with utility meters. It is widely used in:

  • Electricity meters
  • Water meters
  • Heat and thermal meters
  • Gas meters

Communication is typically performed via an optical infrared interface, recognizable by a round metal ring with two optical elements on the meter front.

⚠️ Although the same optical interface is sometimes used by other protocols, IEC 62056‑21 is not compatible with proprietary smart meter standards.


Supported IEC 62056‑21 Modes

The standard defines multiple communication modes. ESPHome’s IEC 62056 component supports the following:

✅ Mode A, B, C – Bidirectional Communication

  • Meter sends data only after request
  • Requires IR transmitter + receiver
  • Automatic baud rate negotiation (starts at 300 baud)
  • Supports retry logic and fallback speeds

✅ Mode D – Unidirectional (Broadcast)

  • Meter sends data periodically
  • Requires IR receiver only
  • UART must be manually configured
  • Ideal for simple read‑only meters

❌ Mode E – Not Supported

  • Uses HDLC binary encoding
  • ESPHome attempts fallback to Mode C if possible
  • Pure Mode‑E meters cannot be read

Why Use an Optical Infrared Probe?

IEC 62056‑21 meters are electrically isolated from the grid. Communication is done optically for safety and noise immunity.

👉 Smart Gateways IEC 62056‑21 TTL Optical Infrared Probe
IEC 62056‑21 TTL Infrared Optical Read Head – Smart Meter Probe

Key Advantages

  • Strong >15N magnetic attachment
  • Dual‑color status LEDs (TX/RX)
  • Industrial‑grade IR diodes
  • USB‑C powered (no external PSU)
  • 50cm cable with RJ connector included
  • Works with ESP32 microcontrollers

This probe is used daily by installers, utilities, and Home Assistant users worldwide.


IEC 62056-21 TTL Infra-Red Optical Read Head with 50cm RJ12 cable for ESP32 and smart meter integration
TTL optical read head comes with a 50cm 4-wire RJ12 cable (Red 12V, Black GND, Yellow RX, Green TX) for easy connection to ESP32 and other microcontrollers.
IEC 62056-21 TTL Infra-Red Optical Read Head with RJ Connector for smart meters and ESP32 integration
Compact TTL Infra-Red optical read head with RJ connector for smart meters, compatible with ESP32 and Home Assistant.
IEC 62056-21 TTL Infra-Red Optical Read Head with TX and RX status indicator LEDs for smart meter reading
Infrared optical read head with clear TX (green) and RX (white) LED indicators, ensuring reliable data transfer from smart meters.
IEC 62056‑21 TTL Infrared Optical Read Head PCB with IR diodes and TX/RX status LEDs for smart meters
Close-up of the TTL optical read head PCB showing infrared diodes and dual-color status LEDs (green TX, white RX) for reliable smart meter communication.

How IEC 62056‑21 Works in ESPHome

The ESPHome IEC 62056 component operates in two core modes:

  1. Polled communication (Modes A/B/C)
  2. Passive listening (Mode D)

Initial Handshake (Modes A/B/C)

  1. ESPHome sends an identification request at 300 baud
  2. Meter responds with its maximum supported baud rate
  3. UART speed switches automatically
  4. Meter sends registers using OBIS codes

If transmission fails, ESPHome retries at lower speeds for maximum reliability.


Understanding OBIS Codes

OBIS (Object Identification System) codes identify meter values.

Format:

A-B:C.D.E*F

Where:

  • A – Medium (1=electricity, 6=heat, 7=gas, 8=water)
  • B – Channel
  • C – Physical value (voltage, current, flow, etc.)
  • D – Measurement type
  • E – Tariff
  • F – Billing period

Example:

1-0:15.8.0

ℹ️ Enable DEBUG logging in ESPHome to discover which OBIS codes your meter provides.


Hardware Requirements

To read IEC 62056‑21 meters you need:


Why the Smart Gateways Optical Probe with TTL?

Unlike cheap probes, this model offers:

  • Stable IR power levels
  • Noise‑free reception
  • Reliable baud rate switching
  • Clear TX/RX activity feedback via White (RX) and Green (TX) Leds

This is critical for long‑term unattended logging.

IEC 62056-21 TTL Infra-Red Optical Read Head with RJ Connector for smart meters and ESP32 integration
Compact TTL Infra-Red optical read head with RJ connector for smart meters, compatible with ESP32 and Home Assistant.

Connecting the TTL Optical Read Head to ESP32

To connect your IEC 62056‑21 TTL Infrared Optical Read Head to an ESP32, follow these steps:

Double-check connections to ensure proper TTL voltage (3.3V). Do not connect 5V directly.

Prepare the RJ12 cable from the read head (50 cm, 4-wire).

Connect the pins to the ESP32:

  • RX (Yellow)GPIO18 on the ESP32
  • TX (Green)GPIO05 on the ESP32
  • GND (Black)GND on the ESP32
  • 3.3V (Red)3.3V on the ESP32

ESPHome Installation for IEC 62056‑21

Add the external component:

external_components:

– source: github://aquaticus/esphome-iec62056


UART Configuration

Most meters use 7E1:

uart:
rx_pin: GPIO18
tx_pin: GPIO05
baud_rate: 9600
data_bits: 7
parity: EVEN
stop_bits: 1

⚠️ Disable UART logging if the probe shares the same port.


IEC 62056 Platform Configuration

Bidirectional (Modes A/B/C)

iec62056:
update_interval: 60s
baud_rate_max: 9600
battery_meter: false

Unidirectional (Mode D)

iec62056:
mode_d: true

Creating IEC 62056 Sensors in Home Assistant

IEC 62056‑21 meters are electrically isolated from the grid. Communication is done optically for safety and noise immunity.

Numeric Sensor Example

sensor:
  - platform: iec62056
    obis: 1-0:15.8.0
    name: Total Energy Consumption
    unit_of_measurement: kWh
    state_class: total_increasing
    device_class: energy

Text Sensor Example

text_sensor:
  - platform: iec62056
    obis: 1-0:15.6.0
    group: 2
    name: Meter Timestamp

Advanced Data Conversion (HEX → Decimal)

Some meters send values in hexadecimal.

Using ESPHome lambdas, you can convert them automatically and publish clean numeric sensors to Home Assistant.

This is especially useful for status registers, diagnostic counters, and vendor‑specific data.


On‑Demand Meter Readout (Switch)

Trigger a readout manually:

switch:
  - platform: iec62056
    name: Readout Trigger

Perfect for battery‑powered meters where frequent polling is discouraged.


Troubleshooting Tips

  • Ensure perfect magnetic alignment
  • Clean dusty meter interfaces
  • Reduce baud rate if CRC/BCC errors occur
  • Increase UART buffer size for high data volume

Why the Smart Gateways IEC 62056‑21 Optical Probe is the Best Choice

  • Professional‑grade reliability
  • Excellent compatibility with ESPHome
  • TTL levels for direct connection to ESP32 boards
  • Clear TX/RX activity feedback via White (RX) and Green (TX) Leds
  • Strong magnet prevents data loss
  • Trusted by installers and utilities

👉 Product page:
IEC 62056‑21 TTL Infrared Optical Read Head

IEC 62056-21 TTL Infra-Red Optical Read Head with 50cm RJ12 cable for ESP32 and smart meter integration
TTL optical read head comes with a 50cm 4-wire RJ12 cable (Red 12V, Black GND, Yellow RX, Green TX) for easy connection to ESP32 and other microcontrollers.

Conclusion

IEC 62056‑21 unlocks a massive amount of valuable energy data hidden inside professional meters. Combined with ESPHome, Home Assistant, and the Smart Gateways TTL Optical Infrared Probe, you get a future‑proof, local‑only, and extremely reliable energy monitoring solution.

Whether you are tracking electricity usage, water consumption, or thermal energy — this setup gives you full control, maximum transparency, and zero vendor lock‑in.


Frequently Asked Questions (FAQ)

1. What meters are compatible with IEC 62056-21?
IEC 62056-21 is the standard for optical communication with utility meters (electricity, water, heat, gas), provided the meter supports the ASCII IR protocol defined in the standard. Not all optical meters use IEC 62056-21 — some use proprietary or binary protocols.

2. Do I need an optical probe or hardware interface?
Yes. You need an optical IR interface (an IR LED and phototransistor) magnetically aligned with the meter’s optical port. For bidirectional modes (A/B/C) you need both TX and RX; for unidirectional (Mode D) only RX is required.

3. Why doesn’t my meter respond at all?
Common causes include:

  • The optical probe is not correctly aligned with the meter.
  • The meter is in a different communication mode than expected.
  • Wrong UART framing (should generally be 7E1).
  • Dirty or obscured optical window.

4. What is Mode D vs Modes A/B/C?

  • Modes A/B/C: Bidirectional — ESPHome requests data from the meter and negotiates baud rate automatically.
  • Mode D: Unidirectional — meter broadcasts periodically and ESPHome must match the fixed UART settings.

5. Why do I need to use correct OBIS codes?
OBIS codes uniquely identify each meter value. If your YAML uses a code the meter doesn’t actually emit, the sensor won’t populate. Always enable DEBUG logging to see exactly what your meter sends and adjust accordingly.

6. My ESPHome config fails — what’s common config mistakes?
Many users forget indentation or YAML structure under sensor: and iec62056:. Be careful to place - platform: iec62056 correctly under sensor: blocks, and quote OBIS codes containing only numbers to avoid YAML parsing issues.

7. Can this read water or heat meters as well as electricity meters?
Yes, as long as the meter supports IEC 62056-21 ASCII IR communication. Different meter types will have different OBIS codes for flow, energy, or heat values.

8. Why can’t I read my meter even though I see transmission errors?
Transmission errors like CRC/BCC errors often mean the baud rate is too high or the optical signal is weak/noisy. Lower the baud_rate_max and ensure solid magnetic alignment.

9. Why do I sometimes see incomplete readings or missing registers?
Some implementations (including the Home Assistant community modules) may miss certain initial datasets from a meter binding due to timing — ensure your device waits long enough and logs DEBUG output for troubleshooting.

10. How often should I poll a meter?
The default is 15 minutes (update_interval: 15min). For more frequent updates (e.g., live dashboards) shorten this, but be careful with battery-powered meters as frequent polling can reduce battery life.

11. Can I trigger readings manually?
Yes. In ESPHome you can create a switch that triggers a manual readout on demand instead of periodic polling — useful for on-demand snapshots or battery-preserving setups.

12. My ESPHome device shows YAML validation errors. What should I check?
Ensure that all numeric values like OBIS codes are either properly quoted or formatted. YAML is whitespace-sensitive, so verify indentation levels especially under sensor: and iec62056: blocks.

13. How do I see all OBIS codes my meter supports?
Enable DEBUG logs (logger: level: DEBUG) in your ESPHome config. The component will print every OBIS record the meter transmits on successful readouts.

14. Can IEC 62056-21 handle meters using binary encoding?
No. IEC 62056-21 component in ESPHome does not support binary or HDLC encoded modes (Mode E). It tries fallback to Mode C if the meter claims Mode E, but pure binary meters cannot be read.

15. Why is logging interfering with my optical probe on ESP8266?
If the same UART is used for both the optical probe and serial logging, data may conflict. Disable UART logging (logger: baud_rate: 0) or use a separate UART for the optical interface.

IEC 62056-21 TTL Infra-Red Optical Read Head with RJ Connector for smart meters and ESP32 integration
Compact TTL Infra-Red optical read head with RJ connector for smart meters, compatible with ESP32 and Home Assistant.

Wonitor water usage in Home Assistant

Wonitor water usage in Home Assistant

In this guide, we walk you through the process of integrating Zigbee2MQTT with Home Assistant using …

Smart Gateways IEC 62056-21 USB-C optical infrared probe mounted with built-in magnet on smart electricity meter

IEC 62056-21 Smart Meter Reading with ESPHome (Complete Guide)

ESPHome IEC 62056-21 integration with smart meters. Optical IR probe, OBIS codes, Home Assistant set…

Marstek Energy Dashboard maken in Home Assistant: combineer batterijen, slimme meter en zonnepanelen

Marstek Energy Dashboard maken in Home Assistant: combineer batterijen, slimme meter en zonnepanelen

Creëer een compleet overzicht van je energiehuishouding met het Marstek Energy Dashboard in Home Ass…

Marstek Venus E V3.0 thuisbatterij integreren in Home Assistant via MODBUS zonder extra hardware

Marstek Venus E V3.0 thuisbatterij integreren in Home Assistant via MODBUS zonder extra hardware

Leer hoe je de Marstek Venus E V3.0 thuisbatterij volledig integreert in Home Assistant via Modbus L…

Smart Gateways Actieve P1 Splitter Pro met 4 Poorten voor Slimme Meter – Verbind Warmtepompen, Laadpalen, Thermostaten en Energie Apps

Slimme meter? Met deze P1-splitter prik je álles tegelijk in

De Smart Gateways Actieve P1 Splitter Pro maakt van één P1-poort vier actieve uitgangen met signaalv…

Distancemeter gateway sensor placement and Common Issues Explained

Distancemeter gateway sensor placement and Common Issues Explained

Monitor your Landis+Gyr T550 or UH50 heat meter in Home Assistant using ESPHome and a Smart Gateways…

Leave a Reply

Your email address will not be published. Required fields are marked *