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

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:
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.
IEC 62056‑21 (formerly IEC 61107) is an international standard for local data exchange with utility meters. It is widely used in:
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.
The standard defines multiple communication modes. ESPHome’s IEC 62056 component supports the following:
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
This probe is used daily by installers, utilities, and Home Assistant users worldwide.




The ESPHome IEC 62056 component operates in two core modes:
If transmission fails, ESPHome retries at lower speeds for maximum reliability.
OBIS (Object Identification System) codes identify meter values.
Format:
A-B:C.D.E*F
Where:
Example:
1-0:15.8.0
ℹ️ Enable DEBUG logging in ESPHome to discover which OBIS codes your meter provides.
To read IEC 62056‑21 meters you need:
Unlike cheap probes, this model offers:
This is critical for long‑term unattended logging.

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:
Add the external component:
external_components:
– source: github://aquaticus/esphome-iec62056
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.
Bidirectional (Modes A/B/C)
iec62056:
update_interval: 60s
baud_rate_max: 9600
battery_meter: falseUnidirectional (Mode D)
iec62056:
mode_d: trueIEC 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: energyText Sensor Example
text_sensor:
- platform: iec62056
obis: 1-0:15.6.0
group: 2
name: Meter TimestampSome 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.
Trigger a readout manually:
switch:
- platform: iec62056
name: Readout TriggerPerfect for battery‑powered meters where frequent polling is discouraged.
👉 Product page:
IEC 62056‑21 TTL Infrared Optical Read Head

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.
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:
4. What is Mode D vs Modes A/B/C?
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.

Posted on by Roel van Wanrooy
In this guide, we walk you through the process of integrating Zigbee2MQTT with Home Assistant using …
Posted on by Roel van Wanrooy
ESPHome IEC 62056-21 integration with smart meters. Optical IR probe, OBIS codes, Home Assistant set…
Posted on by Roel van Wanrooy / 20 comments
Creëer een compleet overzicht van je energiehuishouding met het Marstek Energy Dashboard in Home Ass…
Posted on by Roel van Wanrooy / 66 comments
Leer hoe je de Marstek Venus E V3.0 thuisbatterij volledig integreert in Home Assistant via Modbus L…
Posted on by Roel van Wanrooy / 2 comments
De Smart Gateways Actieve P1 Splitter Pro maakt van één P1-poort vier actieve uitgangen met signaalv…
Posted on by Roel van Wanrooy
Monitor your Landis+Gyr T550 or UH50 heat meter in Home Assistant using ESPHome and a Smart Gateways…
The Best Ultrasonic Sensor for Water Levels, Tanks, and Reservoirs: Smart Gateways Distance Meter WiFi Gateway (with SN-SR04T Sensor)
The Smart Gateways Distance Meter WiFi Gateway is the ideal solution for accurately monitoring liquid levels across a wide range of applications. It features the popular and durable SN-SR04T ultrasonic sensor — a waterproof sensor designed for both industrial and domestic level measurements.
This smart gateway transmits measurement data wirelessly via WiFi and integrates seamlessly with Home Assistant, Domoticz, and other smart home platforms. Thanks to the included manuals and ready-to-use firmware, even beginners can achieve reliable level monitoring without any coding.
Applications of the SN-SR04T Sensor with Smart Gateways
The SN-SR04T sensor is perfectly suited for:
The sensor works both indoors and outdoors and measures liquid levels or objects without making contact. This makes it ideal for situations where hygiene or water resistance is important.
Why Choose This Sensor?
Exceptional Value for Money
This sensor is widely appreciated for its outstanding price-to-performance ratio. For just a fraction of the cost of industrial alternatives, it offers reliability, flexibility, and ease of use — with no subscription fees or vendor lock-in. The gateway runs locally and continues working even without internet access.
Frequently Asked Questions and Support
The sensor comes with both Dutch and English manuals, including Home Assistant configuration guides. A comprehensive FAQ is available, along with troubleshooting tips — such as accessing real-time logs via USB. See the log instructions here:
https://smartgateways.nl/en/view-the-log-of-a-gateway/
A dedicated Home Assistant setup guide is also available:
https://haprofs.com/water-level-sensor-for-home-assistant/
Conclusion
The Smart Gateways Distance Meter with SN-SR04T is the best choice for anyone seeking a precise and dependable level sensor. Whether you’re monitoring the salt level in a water softener, the water level in a rain tank, or the contents of an underground reservoir — this sensor delivers everything you need. With excellent integration options, long-term reliability, and a strong user community, it’s a future-proof investment you can trust.