Skip to content

ESP32 firmware to read data from smart meters in PULL mode via RS485 wired connection and iec62056-21 protocol (DIN EN 62056-21)

Notifications You must be signed in to change notification settings

nevries/SmartMeter

Repository files navigation

Read your iec62056-21 protocol (DIN EN 62056-21) PULL mode smart meter via RS485 (not IR) into home assistant using this ESP32 software.

Hardware

  • Smart meter speaking iec62056-21 with RS485 port that is accessible to you (I tested only on Logarex LK13BE803039, but others should work fine with maybe small adjustments)
  • ESP32 (I'm using this one)
  • RS485 to TTL converter module (I'm using these)

Circuit

Circuit showing the smart meter Logarex LK13BE803039, an ESP32 dev board and an RS485 to TTL module

You might want to connect earth to the RS485 module if you assume a significant potential difference between your smart meter and the ESP32 power supply.

Software

Just load the SmartMeter32 into PlaformIO to compile and upload the firmware to your ESP32 device. Please note that you need to adjust some minor things, at a minimum you need to create a private.h file containing your wifi credentials (see main.cpp for explanation) and in main.cpp adjust the connection parameters to your MQTT broker.

In addition, you might want to adjust the [list of sensors](

telegrams = {
{"1-0:1.8.0*255",
new Telegram("logarex_energy1",
"Energy 1",
HABaseDeviceType::PrecisionP3,
"kWh",
"energy",
"total_increasing",
60000)},
{"1-0:2.8.0*255",
new Telegram("logarex_energy2",
"Energy 2",
HABaseDeviceType::PrecisionP3,
"kWh",
"energy",
"total_increasing",
60000)},
{"1-0:16.7.0*255",
new Telegram("logarex_power",
"Power",
HABaseDeviceType::PrecisionP0,
"W",
"power",
"measurement",
1000)},
{"1-0:32.7.0*255",
new Telegram("logarex_voltageL1",
"Voltage L1",
HABaseDeviceType::PrecisionP1,
"V",
"voltage",
"measurement",
1000)},
{"1-0:52.7.0*255",
new Telegram("logarex_voltageL2",
"Voltage L2",
HABaseDeviceType::PrecisionP1,
"V",
"voltage",
"measurement",
1000)},
{"1-0:72.7.0*255",
new Telegram("logarex_voltageL3",
"Voltage L3",
HABaseDeviceType::PrecisionP1,
"V",
"voltage",
"measurement",
1000)},
{"1-0:31.7.0*255",
new Telegram("logarex_currentL1",
"Current L1",
HABaseDeviceType::PrecisionP2,
"A",
"current",
"measurement",
1000)},
{"1-0:51.7.0*255",
new Telegram("logarex_currentL2",
"Current L2",
HABaseDeviceType::PrecisionP2,
"A",
"current",
"measurement",
1000)},
{"1-0:71.7.0*255",
new Telegram("logarex_currentL3",
"Current L3",
HABaseDeviceType::PrecisionP2,
"A",
"current",
"measurement",
1000)},
{"1-0:81.7.1*255",
new Telegram("logarex_phaseangleUL2UL1",
"Phase angle UL2:UL1",
HABaseDeviceType::PrecisionP2,
"°",
"None",
"measurement",
360000)},
{"1-0:81.7.2*255",
new Telegram("logarex_phaseangleUL3UL1",
"Phase angle UL3:UL1",
HABaseDeviceType::PrecisionP2,
"°",
"None",
"measurement",
360000)},
{"1-0:81.7.4*255",
new Telegram("logarex_phaseangleIL1UL1",
"Phase angle IL1:UL1",
HABaseDeviceType::PrecisionP2,
"°",
"None",
"measurement",
360000)},
{"1-0:81.7.15*255",
new Telegram("logarex_phaseangleIL2UL2",
"Phase angle IL2:UL2",
HABaseDeviceType::PrecisionP2,
"°",
"None",
"measurement",
360000)},
{"1-0:81.7.26*255",
new Telegram("logarex_phaseangleIL3UL3",
"Phase angle IL3:UL3",
HABaseDeviceType::PrecisionP2,
"°",
"None",
"measurement",
360000)},
{"1-0:14.7.0*255",
new Telegram("logarex_supplyfrequency",
"Supply frequency",
HABaseDeviceType::PrecisionP2,
"Hz",
"frequency",
"measurement",
60000)},
};
}
in platformio.ini) and/or their OBIS to match your device. If you don't know what your device provides, I recommend to start with an empty list of sensors and enable debugging (set build_flags = -DCORE_DEBUG_LEVEL=4), then connect to your smart meter and run the ESP32 connected to a serial monitor (for example in PlatformIO), it will print out all received OBIS including data on the serial output.

Helpful Resources

About

ESP32 firmware to read data from smart meters in PULL mode via RS485 wired connection and iec62056-21 protocol (DIN EN 62056-21)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages