{"id":8258,"date":"2024-11-12T09:22:56","date_gmt":"2024-11-12T08:22:56","guid":{"rendered":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/2024\/11\/12\/read-evu-smart-meters-with-esp32-and-esphome-and-use-them-in-homeassistant\/"},"modified":"2024-11-12T09:22:56","modified_gmt":"2024-11-12T08:22:56","slug":"read-evu-smart-meters-with-esp32-and-esphome-and-use-them-in-homeassistant","status":"publish","type":"post","link":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/2024\/11\/12\/read-evu-smart-meters-with-esp32-and-esphome-and-use-them-in-homeassistant\/?lang=en","title":{"rendered":"Read EVU smart meters with ESP32 and ESPhome and use them in Homeassistant"},"content":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_8258\" class=\"pvc_stats all  \" data-element-id=\"8258\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p style=\"text-align: justify\">edit 7.11.24<br \/>\nIn the meantime, I have also layouted an interface board with a USB type B socket for the 5V supply. (see layout below). Because as small and fine as the micro USB plugs are, I need something more robust.<\/p>\n<div id=\"attachment_8247\" style=\"width: 484px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/im350_interface_usbB-e1730984071458.png\"><img fetchpriority=\"high\" decoding=\"async\" aria-describedby=\"caption-attachment-8247\" class=\"wp-image-8246 size-large\" src=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/im350_interface_usbB-e1730984071458.png\" alt=\"\" width=\"474\" height=\"238\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/im350_interface_usbB-e1730984071458.png 3000w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/im350_interface_usbB-e1730984071458-300x151.png 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/im350_interface_usbB-e1730984071458-1024x515.png 1024w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/im350_interface_usbB-e1730984071458-768x387.png 768w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/im350_interface_usbB-e1730984071458-1536x773.png 1536w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/im350_interface_usbB-e1730984071458-2048x1031.png 2048w\" sizes=\"(max-width: 474px) 100vw, 474px\" \/><\/a><p id=\"caption-attachment-8247\" class=\"wp-caption-text\">new board version with USB type B socket for power supply<\/p><\/div>\n<p>As I am asked more and more often for the production data, I am making the Gerber data of the circuit boards available for download:<\/p>\n<p><a href=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/ESP32_interface_2023-05-12.zip\">ESP32_interface_2023-05-12<\/a><\/p>\n<p><a href=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/interface_usbB_2024-06-27-1.zip\">interface_usbB_2024-06-27<\/a><\/p>\n<hr \/>\n<p style=\"text-align: justify\">In the article entitled: \u201cReading energy supply company smart meters with ESP32 and sending data via MQTT\u201d (link), I described how the energy supply companies&#8216; smart meters can be read out via the customer interface. The measurement data is then available as topics via the mqtt broker and can be further processed in various home automation systems (HomeMatic, Homeassistant, etc.). All you need is an ESP32 board and a few small parts to establish the connection to the smart meter. As a small update, I have now embellished the structure (back then with pin headers on a breadboard) a little and made a circuit board.<\/p>\n<div id=\"attachment_8156\" style=\"width: 484px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/im350_interface-1024x683.png\"><img decoding=\"async\" aria-describedby=\"caption-attachment-8156\" class=\"wp-image-8155 size-large\" src=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/im350_interface-1024x683.png\" alt=\"\" width=\"474\" height=\"316\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/im350_interface-1024x683.png 1024w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/im350_interface-300x200.png 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/im350_interface-768x512.png 768w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/im350_interface-1536x1024.png 1536w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/im350_interface-2048x1365.png 2048w\" sizes=\"(max-width: 474px) 100vw, 474px\" \/><\/a><p id=\"caption-attachment-8156\" class=\"wp-caption-text\">Layout preview in designtool<\/p><\/div>\n<p style=\"text-align: justify\">The associated circuit diagram essentially corresponds to the sketch in the previous article. To make things a little more convenient with the new circuit board, the connection to the customer interface of the smart meter can be plugged in via an RJ socket. I have also implemented the power supply via a USB socket.<\/p>\n<p><a href=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/schematic_im350-1024x700.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8159 size-large\" src=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/schematic_im350-1024x700.png\" alt=\"\" width=\"474\" height=\"324\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/schematic_im350-1024x700.png 1024w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/schematic_im350-300x205.png 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/schematic_im350-768x525.png 768w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/schematic_im350-1536x1050.png 1536w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/schematic_im350-2048x1401.png 2048w\" sizes=\"(max-width: 474px) 100vw, 474px\" \/><\/a><\/p>\n<p style=\"text-align: justify\">Once the ESP32 circuit board had been fitted and plugged in, the device was given a small housing and is now doing its job in the electrical distribution cabinet.<\/p>\n<p><a href=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/storageemulated0DCIM.convert_security_files1711014437466-scaled.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8165 size-large\" src=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/storageemulated0DCIM.convert_security_files1711014437466-1024x708.jpg\" alt=\"\" width=\"474\" height=\"328\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/storageemulated0DCIM.convert_security_files1711014437466-1024x708.jpg 1024w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/storageemulated0DCIM.convert_security_files1711014437466-300x207.jpg 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/storageemulated0DCIM.convert_security_files1711014437466-768x531.jpg 768w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/storageemulated0DCIM.convert_security_files1711014437466-1536x1062.jpg 1536w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/storageemulated0DCIM.convert_security_files1711014437466-2048x1416.jpg 2048w\" sizes=\"(max-width: 474px) 100vw, 474px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/storageemulated0DCIM.convert_security_files1711014437564-scaled.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8163 size-large\" src=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/storageemulated0DCIM.convert_security_files1711014437564-scaled-e1711019979664.jpg\" alt=\"\" width=\"474\" height=\"322\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/storageemulated0DCIM.convert_security_files1711014437564-scaled-e1711019979664.jpg 2560w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/storageemulated0DCIM.convert_security_files1711014437564-scaled-e1711019979664-300x204.jpg 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/storageemulated0DCIM.convert_security_files1711014437564-scaled-e1711019979664-1024x696.jpg 1024w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/storageemulated0DCIM.convert_security_files1711014437564-scaled-e1711019979664-768x522.jpg 768w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/storageemulated0DCIM.convert_security_files1711014437564-scaled-e1711019979664-1536x1044.jpg 1536w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2024\/03\/storageemulated0DCIM.convert_security_files1711014437564-scaled-e1711019979664-2048x1392.jpg 2048w\" sizes=\"(max-width: 474px) 100vw, 474px\" \/><\/a><\/p>\n<p style=\"text-align: justify\">The hardware is therefore ready and functional. I have also considered changing something about the software. Until now, the ESP was running a program that decrypted the data from the smart meter and then sent it to the IP address of the broker via MQTT. However, as I am now also a user of the ESPHome integration in my HomeAssistant environment, I have flashed the ESP with an ESPHome base image. On GitHub there is the repository of Andre-Schuiki, where he publishes a version for ISKRA and SIEMENS Smartmeter for use with ESPHome. The installation instructions can be found under the following link: <a href=\"https:\/\/github.com\/Andre-Schuiki\/esphome_im350\/tree\/main\/esp_home\">https:\/\/github.com\/Andre-Schuiki\/esphome_im350\/tree\/main\/esp_home<\/a><\/p>\n<p>The script for the ESPHome device looks like this:<\/p>\n<pre style=\"font-family: arial;font-size: 12px;border: 1px dashed #CCCCCC;width: 99%;height: auto;overflow: auto;background: #f0f0f0;;background-image: url('http:\/\/2.bp.blogspot.com\/_z5ltvMQPaa8\/SjJXr_U2YBI\/AAAAAAAAAAM\/46OqEP32CJ8\/s320\/codebg.gif');padding: 0px;color: #000000;text-align: left;line-height: 20px\"><code style=\"color: #000000\"> esphome:  \r\n  name: kelagsmartmeter  \r\n  friendly_name: KelagSmartmeter  \r\n  libraries:  \r\n  - \"Crypto\" # !IMPORTANT! we need this library for decryption!  \r\n esp32:  \r\n  board: esp32dev  \r\n  framework:  \r\n   type: arduino  \r\n # Enable logging  \r\n logger:  \r\n # Enable Home Assistant API  \r\n api:  \r\n  encryption:  \r\n   key: \"da kommt der key rein des neu angelegten ESPHome Ger\u00e4tes rein\"  \r\n ota:  \r\n  password: \"das automatisch generierte ota passwort\"  \r\n wifi:  \r\n  ssid: !secret wifi_ssid  \r\n  password: !secret wifi_password  \r\n  # Enable fallback hotspot (captive portal) in case wifi connection fails  \r\n  ap:  \r\n   ssid: \"Kelagsmartmeter Fallback Hotspot\"  \r\n   password: \"das automatisch generierte password\"  \r\n captive_portal:  \r\n external_components:  \r\n  - source:  \r\n    type: local  \r\n    path: custom_esphome  \r\n sensor:  \r\n  - platform: siemens_im350  \r\n   update_interval: 5s  \r\n   trigger_pin: 26 # this pin goes to pin 2 of the customer interface and will be set to high before we try to read the data from the rx pin  \r\n   rx_pin: 16 # this pin goes to pin 5 of the customer interface  \r\n   tx_pin: 17 # not connected at the moment, i added it just in case we need it in the future..  \r\n   decryption_key: \"00AA01BB02CC03DD04EE05FF06AA07BB\" # you get the key from your provider!  \r\n   use_test_data: false # that was just for debugging, if you set it to true data are not read from serial and the test_data string is used  \r\n   test_data: \"7EA077CF022313BB45E6E700DB0849534B697460B6FA5F200005C8606F536D06C32A190761E80A97E895CECA358D0A0EFD7E9C47A005C0F65B810D37FB0DA2AD6AB95F7F372F2AB11560E2971B914A5F8BFF5E06D3AEFBCD95B244A373C5DBDA78592ED2C1731488D50C0EC295E9056B306F4394CDA7D0FC7E0000\"  \r\n   delay_before_reading_data: 1000 # this is needed because we have to wait for the interface to power up, you can try to lower this value but 1 sec was ok for me  \r\n   max_wait_time_for_reading_data: 1100 # maximum time to read the 123 Bytes (just in case we get no data)  \r\n   ntp_server: \"pool.ntp.org\" #if no ntp is specified pool.ntp.org is used  \r\n   ntp_gmt_offset: 3600  \r\n   ntp_daylight_offset: 3600  \r\n   counter_reading_p_in:  \r\n    name: reading_p_in  \r\n    filters:  \r\n     - lambda: return x \/ 1000;  \r\n    unit_of_measurement: kWh  \r\n    accuracy_decimals: 3  \r\n    device_class: energy  \r\n   counter_reading_p_out:  \r\n    name: reading_p_out  \r\n    filters:  \r\n     - lambda: return x \/ 1000;  \r\n    unit_of_measurement: kWh  \r\n    accuracy_decimals: 3  \r\n    device_class: energy  \r\n   counter_reading_q_in:  \r\n    name: reading_q_in  \r\n    filters:  \r\n     - lambda: return x \/ 1000;  \r\n    unit_of_measurement: kvarh  \r\n    device_class: energy  \r\n   counter_reading_q_out:  \r\n    name: reading_q_out  \r\n    filters:  \r\n     - lambda: return x \/ 1000;  \r\n    unit_of_measurement: kvarh  \r\n    device_class: energy  \r\n   current_power_usage_in:  \r\n    name: power_usage_in  \r\n    filters:  \r\n     - lambda: return x \/ 1000;  \r\n    unit_of_measurement: kW  \r\n    accuracy_decimals: 3  \r\n    device_class: energy  \r\n   current_power_usage_out:  \r\n    name: power_usage_out  \r\n    filters:  \r\n     - lambda: return x \/ 1000;  \r\n    unit_of_measurement: kW  \r\n    accuracy_decimals: 3  \r\n    device_class: energy  \r\n  # Extra sensor to keep track of uptime  \r\n  - platform: uptime  \r\n   name: IM350_Uptime Sensor  \r\n switch:  \r\n  - platform: restart  \r\n   name: IM350_Restart  \r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_8258\" class=\"pvc_stats all  \" data-element-id=\"8258\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p>edit 7.11.24 In the meantime, I have also layouted an interface board with a USB type B socket for the 5V supply. (see layout below). Because as small and fine as the micro USB plugs are, I need something more robust. As I am asked more and more often for the production data, I am&hellip; <br \/> <a class=\"read-more\" href=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/2024\/11\/12\/read-evu-smart-meters-with-esp32-and-esphome-and-use-them-in-homeassistant\/?lang=en\">Weiterlesen<\/a><\/p>\n","protected":false},"author":86,"featured_media":8168,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"ngg_post_thumbnail":0,"footnotes":""},"categories":[1499],"tags":[2448,2572,2451,2573,2571,2447,2454,2450,2452,2449,2453],"class_list":["post-8258","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-miscellaneous","tag-energycounter","tag-esp-home-en","tag-esp32-en","tag-esphome-en","tag-homeassistant-en","tag-im350-en","tag-im350-kelag-mqtt-en","tag-kelag-en","tag-nodemcu-en","tag-smartmeter-en","tag-wroom32-en"],"a3_pvc":{"activated":true,"total_views":351,"today_views":0},"_links":{"self":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/posts\/8258","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/users\/86"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/comments?post=8258"}],"version-history":[{"count":0,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/posts\/8258\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/media\/8168"}],"wp:attachment":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/media?parent=8258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/categories?post=8258"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/tags?post=8258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}