{"id":21466,"date":"2024-09-10T14:10:27","date_gmt":"2024-09-10T12:10:27","guid":{"rendered":"https:\/\/chochol.io\/smart-home\/home-assistant-measure-electricity-with-pzem004t\/"},"modified":"2025-08-23T19:55:48","modified_gmt":"2025-08-23T17:55:48","slug":"home-assistant-measure-electricity-with-pzem004t","status":"publish","type":"post","link":"https:\/\/chochol.io\/en\/smart-home\/home-assistant-measure-electricity-with-pzem004t\/","title":{"rendered":"Home Assistant: Measure electricity with PZEM004T"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"21466\" class=\"elementor elementor-21466 elementor-21427\" data-elementor-post-type=\"post\">\n\t\t\t\t<div class=\"elementor-element elementor-element-fc63804 e-flex e-con-boxed e-con e-parent\" data-id=\"fc63804\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-d4772fe elementor-toc--minimized-on-tablet elementor-widget elementor-widget-table-of-contents\" data-id=\"d4772fe\" data-element_type=\"widget\" data-e-type=\"widget\" data-settings=\"{&quot;exclude_headings_by_selector&quot;:[],&quot;no_headings_message&quot;:&quot;No headings were found on this page.&quot;,&quot;headings_by_tags&quot;:[&quot;h2&quot;,&quot;h3&quot;,&quot;h4&quot;,&quot;h5&quot;,&quot;h6&quot;],&quot;marker_view&quot;:&quot;numbers&quot;,&quot;minimize_box&quot;:&quot;yes&quot;,&quot;minimized_on&quot;:&quot;tablet&quot;,&quot;hierarchical_view&quot;:&quot;yes&quot;,&quot;min_height&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:&quot;&quot;,&quot;sizes&quot;:[]},&quot;min_height_tablet&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:&quot;&quot;,&quot;sizes&quot;:[]},&quot;min_height_mobile&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:&quot;&quot;,&quot;sizes&quot;:[]}}\" data-widget_type=\"table-of-contents.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<div class=\"elementor-toc__header\">\n\t\t\t\t\t\t<div class=\"elementor-toc__header-title\">\n\t\t\t\tSpis tre\u015bci\t\t\t<\/div>\n\t\t\t\t\t\t\t\t\t\t<div class=\"elementor-toc__toggle-button elementor-toc__toggle-button--expand\" role=\"button\" tabindex=\"0\" aria-controls=\"elementor-toc__d4772fe\" aria-expanded=\"true\" aria-label=\"Open table of contents\"><svg aria-hidden=\"true\" class=\"e-font-icon-svg e-fas-chevron-down\" viewBox=\"0 0 448 512\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\"><path d=\"M207.029 381.476L12.686 187.132c-9.373-9.373-9.373-24.569 0-33.941l22.667-22.667c9.357-9.357 24.522-9.375 33.901-.04L224 284.505l154.745-154.021c9.379-9.335 24.544-9.317 33.901.04l22.667 22.667c9.373 9.373 9.373 24.569 0 33.941L240.971 381.476c-9.373 9.372-24.569 9.372-33.942 0z\"><\/path><\/svg><\/div>\n\t\t\t\t<div class=\"elementor-toc__toggle-button elementor-toc__toggle-button--collapse\" role=\"button\" tabindex=\"0\" aria-controls=\"elementor-toc__d4772fe\" aria-expanded=\"true\" aria-label=\"Close table of contents\"><svg aria-hidden=\"true\" class=\"e-font-icon-svg e-fas-chevron-up\" viewBox=\"0 0 448 512\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\"><path d=\"M240.971 130.524l194.343 194.343c9.373 9.373 9.373 24.569 0 33.941l-22.667 22.667c-9.357 9.357-24.522 9.375-33.901.04L224 227.495 69.255 381.516c-9.379 9.335-24.544 9.317-33.901-.04l-22.667-22.667c-9.373-9.373-9.373-24.569 0-33.941L207.03 130.525c9.372-9.373 24.568-9.373 33.941-.001z\"><\/path><\/svg><\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<div id=\"elementor-toc__d4772fe\" class=\"elementor-toc__body\">\n\t\t\t<div class=\"elementor-toc__spinner-container\">\n\t\t\t\t<svg class=\"elementor-toc__spinner eicon-animation-spin e-font-icon-svg e-eicon-loading\" aria-hidden=\"true\" viewBox=\"0 0 1000 1000\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\"><path d=\"M500 975V858C696 858 858 696 858 500S696 142 500 142 142 304 142 500H25C25 237 238 25 500 25S975 237 975 500 763 975 500 975Z\"><\/path><\/svg>\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-0ef38d9 elementor-widget elementor-widget-text-editor\" data-id=\"0ef38d9\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h2>Hello!<\/h2><p>Configuring the monitoring of electricity consumption is a key element in building a smart home. Some time ago I described how to integrate Eastron\u2019s single-phase energy meter with your home automation system, and if you haven\u2019t seen it yet, I encourage you to read that article. Today, we\u2019re going a step further and will cover how to configure the PZEM004T v3 module with ESPHome. In this article, I\u2019ll show you step-by-step how to connect it to Home Assistant so you can precisely monitor your home\u2019s electricity consumption.<\/p><p><strong>Ready? Here we go!<\/strong> \ud83d\ude80<\/p><h3>What is the ESP8266 NodeMCU?<\/h3><p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignleft wp-image-1241\" src=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/01\/assets2F-LpXqB3J1BMD5s4OpYSg2F-LpXslUdklMPEtHLTfE22F-LpXt-jt9761qMH3KcKY2Fnodemcu-300x162.webp\" sizes=\"(max-width: 351px) 100vw, 351px\" srcset=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/01\/assets2F-LpXqB3J1BMD5s4OpYSg2F-LpXslUdklMPEtHLTfE22F-LpXt-jt9761qMH3KcKY2Fnodemcu-300x162.webp 300w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/01\/assets2F-LpXqB3J1BMD5s4OpYSg2F-LpXslUdklMPEtHLTfE22F-LpXt-jt9761qMH3KcKY2Fnodemcu.webp 629w\" alt=\"ESP8266, board\" width=\"346\" height=\"186\" \/>The <strong>ESP8266 NodeMCU<\/strong> is a small but extremely powerful development board based on the popular ESP8266 chip from <strong>Espressif<\/strong>. Equipped with an integrated Wi-Fi module operating at 802.11 b\/g\/n, it allows easy connection to existing wireless networks and communication with other devices over the Internet.<\/p><p class=\"whitespace-pre-wrap\">At the heart of the board is a 32-bit Tensilica L106 processor at 80-160 MHz and 64 KiB of instruction memory and 96 KiB of data memory. The NodeMCU has a built-in USB-UART converter (CP2102), so it can be easily connected to a computer and programmed using the Arduino IDE or other environment.<\/p><p class=\"whitespace-pre-wrap\">A key advantage is the existence of as many as 17 GPIO (General-Purpose Input\/Output) pins, which can be freely used as digital I\/O or assigned other functions, such as I2C, SPI, UART, etc. This allows communication and control of all kinds of sensors, displays and executive devices.<\/p><p class=\"whitespace-pre-wrap\">Despite its compact size and low price, the ESP8266 NodeMCU has great potential in DIY and Internet of Things projects thanks to its strong capabilities, low cost and excellent community support.<\/p><h3>What is ESPHome?<\/h3><p><img decoding=\"async\" class=\" wp-image-21414 alignleft\" src=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/09\/45919759.png\" alt=\"ESPHome, Nowe logo\" width=\"230\" height=\"230\" srcset=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/09\/45919759.png 460w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/09\/45919759-150x150.png 150w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/09\/45919759-300x300.png 300w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/09\/45919759-60x60.png 60w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/09\/45919759-360x360.png 360w\" sizes=\"(max-width: 230px) 100vw, 230px\" \/><\/p><p><strong>ESPHome<\/strong> is a powerful, open source development environment designed specifically for devices based on the popular ESP8266 and ESP32 microcontrollers. Its main goal is to facilitate the creation of smart Internet of Things (IoT) devices, which can then be fully integrated and controlled through the Home Assistant platform.<\/p><p class=\"whitespace-pre-wrap\">Configuration of devices in ESPHome is done through friendly files in YAML format, which allow defining the operation of various components, sensors, displays or actuators. This makes programming intuitive and accessible even to those without in-depth coding knowledge.<\/p><p class=\"whitespace-pre-wrap\">In addition to native integration with Home Assistant, ESPHome also supports a wide range of off-the-shelf modules and libraries, allowing it to support many popular other components.<\/p><h2>Preparation<\/h2><p>Before diving into system adaptation using ESP and ESPHome, it\u2019s a good idea to prepare properly. Below you will find key steps to get your project started.<\/p><p>Make sure you have all the necessary materials:<\/p><ul><li><a href=\"https:\/\/amzn.to\/4d6bbkF\" target=\"_blank\" rel=\"noopener\">ESP8266<\/a> NodeMCU board (or <a href=\"https:\/\/amzn.to\/4dfeZQG\" target=\"_blank\" rel=\"noopener\">ESP32<\/a>, if you opt for a newer model),<ul><li>It is worth verifying before purchasing an ESP board that Wi-Fi coverage reaches our installation site. We may need to purchase a board with the ability to connect an external antenna.<\/li><\/ul><\/li><li>PZEM004T v3 \u2013 single-phase electricity meter (<a href=\"https:\/\/pl.aliexpress.com\/item\/1005005461285334.html?spm=a2g0o.order_list.order_list_main.136.21ef1c24LPi8Hj&gatewayAdapt=glo2pol\" target=\"_blank\" rel=\"noopener\">Link to shop<\/a>),<\/li><li>Power source for the ESP board (5V DC),<\/li><li><a href=\"https:\/\/botland.com.pl\/920-kostki-elektryczne\" target=\"_blank\" rel=\"noopener\">Wire connectors<\/a>,<\/li><li>(Optional) DIN box in which to hide the ESP board with the converter module,<\/li><li>Connection wires for all components.<\/li><\/ul><h3>Installing ESPHome in Home Assistant<\/h3><p><strong>Install ESPHome<\/strong> in your Home Assistant environment to easily configure and manage the ESP8266. Use the <a href=\"https:\/\/esphome.io\/guides\/getting_started_hassio#installing-esphome-dashboard\" target=\"_blank\" rel=\"noopener\">ESPHome documentation<\/a> and follow the instructions.<\/p><h3>Preparation of workspace<\/h3><p>Organize a workspace where you will assemble the system. Make sure you have access to tools and are comfortable working on the project.<\/p><h3>Health and safety of working with electric voltage<\/h3><p><strong><img decoding=\"async\" class=\"size-full wp-image-20689 alignright\" src=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/04\/Projekt-bez-nazwy-2.png\" sizes=\"(max-width: 250px) 100vw, 250px\" srcset=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/04\/Projekt-bez-nazwy-2.png 250w, https:\/\/chochol.io\/wp-content\/smush-webp\/2024\/04\/Projekt-bez-nazwy-2-150x150.png.webp 150w, https:\/\/chochol.io\/wp-content\/smush-webp\/2024\/04\/Projekt-bez-nazwy-2-60x60.png.webp 60w\" alt=\"Warning pictogram\" width=\"250\" height=\"250\" \/><\/strong>Electrical safety is key when working with electricity. Here are some important recommendations:<\/p><ul><li><strong>Power Off:<\/strong> Before any work on the circuit, turn off the power supply to avoid electric shock.<\/li><li><strong>Appropriate Tools: <\/strong>Use tools that are insulated and designed for electrical work \u2013 they should meet appropriate safety standards.<\/li><li><strong>Experience:<\/strong> Electrical installation work requires experience. If you are unsure of your skills, it is advisable to enlist the help of an experienced person.<\/li><li><strong>Eye and Hand Protection:<\/strong> Wearing eye and hand protection is recommended, especially when soldering and handling connections.<\/li><li><strong>Check the Power Supply:<\/strong> Make sure you know where the main power supply is and that it is off before taking any action.<\/li><li><strong>Knowledge of the Electrical System:<\/strong> Always verify that you know how an electrical system works. <strong>Do not take action blindly.<\/strong><\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-5c641cb elementor-alert-danger elementor-widget elementor-widget-alert\" data-id=\"5c641cb\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"alert.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-alert\" role=\"alert\">\n\n\t\t\t\t\t\t<span class=\"elementor-alert-title\">Warning<\/span>\n\t\t\t\n\t\t\t\t\t\t<span class=\"elementor-alert-description\">Remember that tampering with electrical installations can be dangerous, and if you are unsure of your skills, it is always a good idea to consult an electrician or an electrical specialist. electrical installations.<\/span>\n\t\t\t\n\t\t\t\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-c59df86 elementor-widget elementor-widget-text-editor\" data-id=\"c59df86\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h2>Step 1 \u2013 VLAN IoT<\/h2><p>As a security practice, I recommend setting up a separate network for IoT devices, separate from the main home network. For this purpose, it is worth using the <strong>VLAN<\/strong> (<a href=\"https:\/\/pl.wikipedia.org\/wiki\/Wirtualna_sie%C4%87_lokalna\" target=\"_blank\" rel=\"noopener\">Virtual Local Area Network<\/a>) function, which allows physical separation of devices, such as those based on ESPHome, from other devices in the home infrastructure.<\/p><h3>Benefits<\/h3><p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-20687 alignright\" src=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/04\/Projekt-bez-nazwy-1.png\" sizes=\"(max-width: 250px) 100vw, 250px\" srcset=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/04\/Projekt-bez-nazwy-1.png 250w, https:\/\/chochol.io\/wp-content\/smush-webp\/2024\/04\/Projekt-bez-nazwy-1-150x150.png.webp 150w, https:\/\/chochol.io\/wp-content\/smush-webp\/2024\/04\/Projekt-bez-nazwy-1-60x60.png.webp 60w\" alt=\"Cloud icon as VLAN\" width=\"250\" height=\"250\" \/><\/p><p>Creating a dedicated network for IoT devices offers several advantages:<\/p><ul><li><strong>Security:<\/strong> Separating IoT devices from the main network haelps minimize the potential risk of attacks. If an IoT device is possibly compromised, access to the main home network is difficult.<\/li><li><strong>Controlling Communications:<\/strong> Creating a separate network allows for more precise control over who communicates with IoT devices and how. You can define communication rules that only allow specific devices (for example, a server or virtual machine from Home Assistant) to interact with IoT devices.<\/li><li><strong>Network Traffic Optimization:<\/strong> Separating IoT device traffic from main network traffic can help optimize network performance.<\/li><\/ul><h3>Implementation<\/h3><p>To implement such separation, it is worth consulting the documentation and settings of the router. In the case of Home Assistant, using the appropriate firewall rules on the router, you can customize access to IoT devices. This approach introduces a layer of additional security to our smart home infrastructure.<\/p><h2>Step 2 \u2013 Install and configure firmware to work with Home Assistant<\/h2><p>Once you run the ESPHome add-on on the Home Assistant server, you can proceed to add your first ESPHome-based device.<\/p><h3>Connecting to a computer<\/h3><ul><li><strong>Connect the board using a USB cable to your computer.<\/strong> It is important to use a USB cable with data transmission, as many cheap cables only provide power.<ul><li>To be sure of correct operation, I recommend using <strong>Chrome<\/strong> or <strong>Edge<\/strong> browser (there is a transfer of data transmission through the COM port to the browser using WebSerial).<\/li><\/ul><\/li><\/ul><h3>Home Assistant<\/h3><ul><li>After completing these steps, log in to <strong>Home Assistant<\/strong>,<\/li><\/ul><p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1258\" src=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-11-at-12.19.37.png\" sizes=\"(max-width: 565px) 100vw, 565px\" srcset=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-11-at-12.19.37.png 565w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-11-at-12.19.37-273x300.png 273w\" alt=\"Home Assistant, login screen\" width=\"565\" height=\"622\" \/><\/p><ul><li>From the side panel, go to the <strong>ESPHome<\/strong> tab,<\/li><li>Then click <strong>New Device<\/strong>,<\/li><\/ul><p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1262\" src=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-11-at-12.30.16.png\" alt=\"ESPHome, Button New device\" width=\"180\" height=\"67\" \/><\/p><ul><li><p>After selecting the option to add a new device, we may encounter a browser incompatibility message, especially for browsers that do not support WebSerial. Alternatively, we may also encounter a message indicating that there is no secure connection (HTTPS) to the dashboard. In this situation, we can click <strong>Continue<\/strong> to continue the process of adding the device.<\/p><\/li><\/ul><p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1260\" src=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-11-at-12.28.56.png\" sizes=\"(max-width: 399px) 100vw, 399px\" srcset=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-11-at-12.28.56.png 399w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-11-at-12.28.56-251x300.png 251w\" alt=\"ESPHome, New device\" width=\"399\" height=\"477\" \/><\/p><ul><li>In the next window, we enter a <strong>name for our device<\/strong> (it can be a name or alias we created) and <strong>the details of our Wi-Fi network<\/strong>.<ul><li>Wi-Fi network entry is only necessary when adding a device for the first time. Subsequent ESPHome-based additions will not require this step.<\/li><\/ul><\/li><li>Then, for ESPHome to install the firmware on the ESP8266 board, click Connect.<\/li><\/ul><p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1264\" src=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-11-at-12.35.53.png\" sizes=\"(max-width: 381px) 100vw, 381px\" srcset=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-11-at-12.35.53.png 381w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/01\/Screenshot-2024-01-11-at-12.35.53-300x264.png 300w\" alt=\"ESPHome, Installation\" width=\"381\" height=\"335\" \/><\/p><ul><li>After a while, the browser will display a window for selecting a device for serial port communication. Find your device, whose name should include <strong>CP210x UART<\/strong>, and click <strong>Connect<\/strong>.<\/li><li>Then wait until the firmware is installed on the board.<\/li><\/ul><h3>Completion of the process<\/h3><p>After a successful installation, you should receive a message confirming the completion of the process. Your device will also appear on the dashboard with the description <strong>ONLINE<\/strong>. This means that the board has been correctly configured and is ready to proceed.<\/p><h2>Step 3 \u2013 Mount the module<\/h2><p>Connecting the PZEM004T v3 energy meter to the electrical system requires accuracy and following proper safety procedures.<\/p><h3>Types of modules<\/h3><p>When installing the module, it is worth noting the two types of models available: supporting currents up to 10A and up to 100A. The difference between them lies mainly in the way the current transformer (CT) is connected.<\/p><ul><li><p><strong>10A version:<\/strong> The module contains a built-in current sensor that directly measures the current flowing through the circuit. This is simpler to install, but limited to circuits that do not exceed 10A.<\/p><\/li><li><p><strong>100A version:<\/strong> This version uses an external current transformer (CT), which is more flexible for installation. This transformer must be mounted on the phase conductor, and has the advantage that it can be easily attached to the existing conductor without disconnecting the installation. It is ideal for monitoring larger circuits with currents up to 100A.<\/p><\/li><\/ul><p>The installation method described will be based on the 100A version using a current transformer.<\/p><h3>Preparation<\/h3><ul><li><strong>Location selection:<\/strong> The PZEM004T v3 module does not have a display, so you don\u2019t need to install it in a location that is easily accessible for reading data. You can mount it in any safe location near the circuit you want to monitor. However, it is important that the mounting location is dry, well ventilated and complies with local electrical codes.<\/li><li><strong>Installation preparation:<\/strong> Turn off the power to the electrical circuit where you will be installing the meter. Always make sure you work in a de-energized condition to avoid the risk of electric shock. Check that the wires are dry and free from damage.<\/li><li><strong>Module installation:<\/strong> Mount the PZEM004T v3 in the desired location using the fasteners of your choice. Make sure the module is firmly attached to avoid accidental damage during use.<\/li><\/ul><h3>Actions<\/h3><ul><li><strong>Connecting electrical wires:<\/strong><ul><li><strong>Current transformer (CT):<\/strong> The current transformer (split-core) should be installed on the <strong>phase conductor (L)<\/strong> of the circuit you wish to monitor. Ensure that the arrow on the transformer housing points in the direction of the current flow, from the energy source to the load. This positioning is crucial for accurate readings. Unlike a standard conductor, the CT doesn\u2019t carry the current directly through itself. Instead, it detects the magnetic field generated by the current flow, enabling it to measure the current without interrupting the circuit.<\/li><li><strong>Phase wire (L):<\/strong> The phase wire connected to the PZEM004T module doesn\u2019t carry the full load of current; its primary role is to measure the voltage in the circuit. It should be connected to the designated terminal on the module, as indicated by the markings. Proper connection of the phase wire ensures that the meter can accurately monitor the voltage in the system.<\/li><li><strong>Neutral (N) wire:<\/strong> The neutral wire is used for voltage measurement in the system and must be connected to the appropriate terminal on the PZEM004T module. Unlike the phase wire, the neutral does not pass through the current transformer (CT), but its connection is essential for accurate voltage measurements and overall functionality of the monitoring system.<\/li><\/ul><\/li><li><strong>Power on:<\/strong> Once the connection is complete, power up the circuit and verify that the module is working properly. PZEM004T v3 communicates via UART, so verification of proper operation will be through readings in ESPHome or Home Assistant.<\/li><\/ul><h3>Recommendations<\/h3><ul><li><strong>Checking connections:<\/strong> Make sure all wires are securely fastened and connections are well insulated. Loose connections can lead to incorrect readings or pose a safety hazard.<\/li><li><strong>Testing:<\/strong> Check that all parameters are correctly reported by the module in the monitoring system. You can run load tests to make sure the meter is accurately monitoring power consumption.<\/li><li><strong>Use of cable ferrules<\/strong>: Crimping ferrules should be applied to the ends of cable wires to prevent them from fraying during terminal installation. By using these sleeves, you ensure a more durable connection, improve electrical contact, and protect the wires from mechanical damage that can occur while tightening the terminals.<\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b6a079f elementor-widget elementor-widget-gallery\" data-id=\"b6a079f\" data-element_type=\"widget\" data-e-type=\"widget\" data-settings=\"{&quot;columns&quot;:2,&quot;lazyload&quot;:&quot;yes&quot;,&quot;gallery_layout&quot;:&quot;grid&quot;,&quot;columns_tablet&quot;:2,&quot;columns_mobile&quot;:1,&quot;gap&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:10,&quot;sizes&quot;:[]},&quot;gap_tablet&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:10,&quot;sizes&quot;:[]},&quot;gap_mobile&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:10,&quot;sizes&quot;:[]},&quot;link_to&quot;:&quot;file&quot;,&quot;aspect_ratio&quot;:&quot;3:2&quot;,&quot;overlay_background&quot;:&quot;yes&quot;,&quot;content_hover_animation&quot;:&quot;fade-in&quot;}\" data-widget_type=\"gallery.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-gallery__container\">\n\t\t\t\t\t\t\t<a class=\"e-gallery-item elementor-gallery-item elementor-animated-content\" href=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/09\/IMG_8526-scaled.jpeg\" data-elementor-open-lightbox=\"yes\" data-elementor-lightbox-slideshow=\"b6a079f\" data-elementor-lightbox-title=\"ESPHome i pomiar energii PZEM, zamontowany modu\u0142\" data-e-action-hash=\"#elementor-action%3Aaction%3Dlightbox%26settings%3DeyJpZCI6MjE0MzksInVybCI6Imh0dHBzOlwvXC9jaG9jaG9sLmlvXC93cC1jb250ZW50XC91cGxvYWRzXC8yMDI0XC8wOVwvSU1HXzg1MjYtc2NhbGVkLmpwZWciLCJzbGlkZXNob3ciOiJiNmEwNzlmIn0%3D\">\n\t\t\t\t\t<div class=\"e-gallery-image elementor-gallery-item__image\" data-thumbnail=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/09\/IMG_8526-768x576.jpeg\" data-width=\"768\" data-height=\"576\" aria-label=\"Wn\u0119trze urz\u0105dzenia z okablowaniem, czerwone przewody 12V\/74A i niebieski modu\u0142 zabezpiecze\u0144 na baterii o\u0142owiowej\" role=\"img\" ><\/div>\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"elementor-gallery-item__overlay\"><\/div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/a>\n\t\t\t\t\t\t\t<a class=\"e-gallery-item elementor-gallery-item elementor-animated-content\" href=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/09\/IMG_8527-scaled.jpeg\" data-elementor-open-lightbox=\"yes\" data-elementor-lightbox-slideshow=\"b6a079f\" data-elementor-lightbox-title=\"ESPHome i pomiar energii PZEM, zamontowany modu\u0142\" data-e-action-hash=\"#elementor-action%3Aaction%3Dlightbox%26settings%3DeyJpZCI6MjE0NDEsInVybCI6Imh0dHBzOlwvXC9jaG9jaG9sLmlvXC93cC1jb250ZW50XC91cGxvYWRzXC8yMDI0XC8wOVwvSU1HXzg1Mjctc2NhbGVkLmpwZWciLCJzbGlkZXNob3ciOiJiNmEwNzlmIn0%3D\">\n\t\t\t\t\t<div class=\"e-gallery-image elementor-gallery-item__image\" data-thumbnail=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/09\/IMG_8527-768x576.jpeg\" data-width=\"768\" data-height=\"576\" aria-label=\"Wewn\u0119trzna p\u00f3\u0142ka szafy IT: kable niebieski i czerwony w prowadnicy z przezroczyst\u0105 os\u0142on\u0105, diody LED na torze\" role=\"img\" ><\/div>\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"elementor-gallery-item__overlay\"><\/div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/a>\n\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-4ea7a38 elementor-widget elementor-widget-text-editor\" data-id=\"4ea7a38\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h2>Step 4 \u2013 Connect the module to the board<\/h2><ul><li>Connect the<strong> 5V<\/strong> on PZEM-004T to pin <strong>5V<\/strong> on board.<\/li><li>Connect the<strong> GND<\/strong> on PZEM-004T to pin <strong>GND<\/strong> on board.<\/li><li>Connect the<strong> RX<\/strong>on PZEM-004T to pin <strong>RX<\/strong> on board ESP8266 (or another pin according to the configuration).<\/li><li>Connect the<strong> TX<\/strong> on PZEM-004T to pin <strong>RX<\/strong> on board ESP8266 (or another pin according to the configuration).<\/li><\/ul><p><strong>Checking connections:<\/strong><\/p><ul><li>Make sure to connect all wires firmly and correctly assign them to their respective pins (5V, GND, RX, TX).<\/li><li>Verify that the communication wires (RX, TX) are in the correct order, as proper connection is key for UART communication.<\/li><li>Check that the board contacts do not touch metal (possibly) parts of the case or other wires that could damage your electronics.<\/li><li>Connect the installation to the power supply.<\/li><li>Wait for the board to connect to your Wi-Fi network.<\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7ec855d elementor-widget elementor-widget-gallery\" data-id=\"7ec855d\" data-element_type=\"widget\" data-e-type=\"widget\" data-settings=\"{&quot;columns&quot;:2,&quot;lazyload&quot;:&quot;yes&quot;,&quot;gallery_layout&quot;:&quot;grid&quot;,&quot;columns_tablet&quot;:2,&quot;columns_mobile&quot;:1,&quot;gap&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:10,&quot;sizes&quot;:[]},&quot;gap_tablet&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:10,&quot;sizes&quot;:[]},&quot;gap_mobile&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:10,&quot;sizes&quot;:[]},&quot;link_to&quot;:&quot;file&quot;,&quot;aspect_ratio&quot;:&quot;3:2&quot;,&quot;overlay_background&quot;:&quot;yes&quot;,&quot;content_hover_animation&quot;:&quot;fade-in&quot;}\" data-widget_type=\"gallery.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-gallery__container\">\n\t\t\t\t\t\t\t<a class=\"e-gallery-item elementor-gallery-item elementor-animated-content\" href=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/09\/IMG_8528-scaled.jpeg\" data-elementor-open-lightbox=\"yes\" data-elementor-lightbox-slideshow=\"7ec855d\" data-elementor-lightbox-title=\"ESPHome i pomiar energii PZEM, p\u0142ytka ESP8266\" data-e-action-hash=\"#elementor-action%3Aaction%3Dlightbox%26settings%3DeyJpZCI6MjE0NDYsInVybCI6Imh0dHBzOlwvXC9jaG9jaG9sLmlvXC93cC1jb250ZW50XC91cGxvYWRzXC8yMDI0XC8wOVwvSU1HXzg1Mjgtc2NhbGVkLmpwZWciLCJzbGlkZXNob3ciOiI3ZWM4NTVkIn0%3D\">\n\t\t\t\t\t<div class=\"e-gallery-image elementor-gallery-item__image\" data-thumbnail=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/09\/IMG_8528-768x576.jpeg\" data-width=\"768\" data-height=\"576\" aria-label=\"P\u0142ytka elektroniczna z gniazdem GPIO i z\u0142\u0105czami, po\u0142\u0105czona przewodami kolorowymi do obudowy urz\u0105dzenia\" role=\"img\" ><\/div>\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"elementor-gallery-item__overlay\"><\/div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/a>\n\t\t\t\t\t\t\t<a class=\"e-gallery-item elementor-gallery-item elementor-animated-content\" href=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/09\/IMG_8529-scaled.jpeg\" data-elementor-open-lightbox=\"yes\" data-elementor-lightbox-slideshow=\"7ec855d\" data-elementor-lightbox-title=\"ESPHome i pomiar energii PZEM, p\u0142ytka ESP8266\" data-e-action-hash=\"#elementor-action%3Aaction%3Dlightbox%26settings%3DeyJpZCI6MjE0NDgsInVybCI6Imh0dHBzOlwvXC9jaG9jaG9sLmlvXC93cC1jb250ZW50XC91cGxvYWRzXC8yMDI0XC8wOVwvSU1HXzg1Mjktc2NhbGVkLmpwZWciLCJzbGlkZXNob3ciOiI3ZWM4NTVkIn0%3D\">\n\t\t\t\t\t<div class=\"e-gallery-image elementor-gallery-item__image\" data-thumbnail=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/09\/IMG_8529-768x576.jpeg\" data-width=\"768\" data-height=\"576\" aria-label=\"Tablica z opisem 18Ah 12V oraz modu\u0142 \u0142adowarki z uk\u0142adem elektroniki i przewodami niebieskim oraz br\u0105zowym\" role=\"img\" ><\/div>\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"elementor-gallery-item__overlay\"><\/div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/a>\n\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-c03b563 elementor-widget elementor-widget-text-editor\" data-id=\"c03b563\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<h2>Step 5 \u2013 Upload the code in ESPHome<\/h2><div>In this section, we will now upload the relevant entries for configuring the connection to the electricity meter. Copy the necessary code elements into your installation.<\/div>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f2a2f57 elementor-widget elementor-widget-mdp-coder-elementor\" data-id=\"f2a2f57\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"mdp-coder-elementor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t        <!-- Start Coder for Elementor WordPress Plugin -->\n        <div\n            id=\"mdp-coder-f2a2f57\"\n            class=\"mdp-coder-elementor-box\"\n            data-theme=\"mdp-theme-material-dark\"\n            data-dark-theme=\"mdp-theme-material-dark\"\n        >\n            \n                <pre class=\"language-yaml line-numbers copy-to-clipboard\"data-previewers=\"\"><code>esphome:\n  name: esp06-pzemac\n  comment: &quot;I like pancakes&quot;\n  area: &quot;Roof&quot; \n#  on_boot: \n#    then:\n#      - pzemac.reset_energy: pzemac_wardrobe\n\nesp8266:\n  board: esp01_1m\n\n# Enable logging\nlogger:\n  baud_rate: 0\n\nweb_server:\n  port: 80\n\n# Enable Home Assistant API\napi:\n  encryption:\n    key: &quot;HERE WILL BE THE CODE GENERATED BY ESPHOME&quot;\n\nota:\n  - platform: esphome\n    password: &quot;HERE WILL APPEAR THE PASSWORD GENERATED BY ESPHOME&quot;\n\nwifi:\n  ssid: !secret wifi_ssid\n  password: !secret wifi_password\n\n  # Enable fallback hotspot (captive portal) in case wifi connection fails\n  ap:\n    ssid: &quot;Esp06-Roof Fallback Hotspot&quot;\n    password: &quot;123456789&quot;\n\ncaptive_portal:\n    \nuart:\n  tx_pin: RX\n  rx_pin: TX\n  baud_rate: 9600\n  stop_bits: 1\n\nmodbus: \n\nbutton:\n  - platform: restart\n    name: &quot;Restart device&quot;   \n\nsensor:\n  - platform: pzemac\n    address: 1\n    current:\n      name: &quot;Current&quot;\n      id: &quot;pzem_current&quot;\n      unit_of_measurement: &quot;A&quot;\n    voltage:\n      name: &quot;Voltage&quot;\n      id: &quot;pzem_voltage&quot;\n      unit_of_measurement: &quot;V&quot;\n    energy:\n      name: &quot;Energy&quot;\n      id: &quot;pzem_energy&quot;\n      unit_of_measurement: &quot;kWh&quot;\n      accuracy_decimals: 2\n      filters:\n        - lambda: return x \/ 1000.0;\n    power:\n      name: &quot;Power&quot;\n      id: &quot;pzem_power&quot;\n      unit_of_measurement: &quot;W&quot;\n    frequency:\n      name: &quot;Frequency&quot;\n      id: &quot;pzem_frequency&quot;\n      unit_of_measurement: &quot;Hz&quot;\n    power_factor:\n      name: &quot;Power Factor&quot;\n      id: &quot;pzem_power_factor&quot;\n      unit_of_measurement: &quot;%&quot;\n    update_interval: 10s\n    id: &quot;pzemac_roof&quot;\n  - platform: wifi_signal\n    name: &quot;Wi-Fi Signal&quot;\n    update_interval: 60s\n\nbinary_sensor:\n  - platform: status\n    name: &quot;Connection status&quot;  <\/code><\/pre>\n                    <\/div>\n                <script>\n            \"use strict\";\n\n            \/** Handler when the DOM is fully loaded. *\/\n            let callback_f2a2f57 = function() {\n\n                \/** Set theme for coder widget. *\/\n                function setTheme() {\n\n                    \/** Foreach Code Widget. *\/\n                    let coderBoxes = document.querySelectorAll( '.mdp-coder-elementor-box' );\n\n                    for ( let coderBox of coderBoxes ) {\n\n                        let lightTheme = coderBox.dataset.theme;\n                        let darkTheme = coderBox.dataset.darkTheme;\n\n                        coderBox.className = '';\n                        if ( window.matchMedia && window.matchMedia( '(prefers-color-scheme: dark)' ).matches ) {\n\n                            coderBox.className = 'mdp-coder-elementor-box ' + darkTheme;\n\n                        } else {\n\n                            coderBox.className = 'mdp-coder-elementor-box ' + lightTheme;\n\n                        }\n\n                    }\n\n                }\n                setTheme();\n\n\n                \/** Watch for changes color-scheme. *\/\n                window.matchMedia(\"(prefers-color-scheme: dark)\").addListener( function() {\n                    setTheme();\n                } );\n\n                \n                if ( typeof Prism !== 'undefined' ) {\n\n                    Prism.plugins.autoloader.languages_path = 'https:\/\/chochol.io\/wp-content\/plugins\/coder-elementor\/js\/prism\/components\/';\n                    Prism.highlightAll();\n                    Prism.fileHighlight();\n\n                }\n\n                \n            };\n\n            if (\n                document.readyState === \"complete\" ||\n                ( document.readyState !== \"loading\" && !document.documentElement.doScroll )\n            ) {\n                callback_f2a2f57();\n            } else {\n                document.addEventListener( \"DOMContentLoaded\", callback_f2a2f57 );\n            }\n\n        <\/script>\n                <!-- End Coder for Elementor WordPress Plugin -->\n\n        \t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-41a6c31 elementor-widget elementor-widget-text-editor\" data-id=\"41a6c31\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<ul><li>We\u2019re now waiting for the software to compile and upload to the board. After the installation finishes successfully, the log preview shows a summary of your board\u2019s configuration, allowing you to verify that everything is set up correctly.<\/li><\/ul><h2>Step 6 \u2013 Reverse proxy on Synology using Nginx Proxy Manager<\/h2><p>Do you use Synology and want to improve access to your Home Assistant server? Here\u2019s a quick step-by-step guide on how to set up a login using a domain name and subdomain, such as ha.xyz.com, instead of entering an IP address. You can achieve all this with Docker Compose in the Portainer.<\/p><p>\ud83d\udc49 <a href=\"https:\/\/chochol.io\/en\/hardware\/synology-free-ports-80-443-for-nginx-proxy-manager\/\" target=\"_new\">Check it out now<\/a> and get your environment ready for more improvements!<\/p><p>Thus, by using a domain name instead of an IP address, you simplify the process of logging into your Home Assistant server on Synology.<\/p><h2>Step 7 \u2013 Adding a device to Home Assistant<\/h2><ul><li>In the Home Assistant notification section, you\u2019ll notice that our home automation server has detected a new device,<\/li><li>Next, navigate to <strong>Settings<\/strong>, then to <strong>Integrations and Devices<\/strong>,<\/li><li>You\u2019ll see the new device highlighted with a blue border. <strong>Approve the new device for integration.<\/strong><\/li><li><strong>Set the area<\/strong> where the device will be located.<\/li><li><strong>Congratulations!<\/strong> You\u2019ve made it to this stage, which means you\u2019ve successfully completed the configuration process. Now it\u2019s time to test your new device! Head over to it and check the parameters measured by the electricity metering module directly from Home Assistant. \ud83d\ude80<\/li><li>Depending on the set reporting time \u2013 wait a while until the module installed at the ESP board detects the values measured by the meter. You can preview the raw data from the logs in ESPHome.<\/li><\/ul><p>Good luck!<\/p><p>If you have additional questions about the setup, <strong>go ahead and leave a comment under this article<\/strong> or <strong>contact me directly<\/strong>. I will be happy to answer any concerns and help solve any problems. Your questions can help improve this guide for other users.<\/p><h2>Additional materials and information<\/h2><h3>Electricity meter reset<\/h3><p>If you want to reset the energy (kWh) meter and delete the stored data, you can use the reset function available in ESPHome. In the code, you can add a section <code>on_boot<\/code>, which will automatically reset the counter every time the device is started. Such a record looks like this:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e095163 elementor-widget elementor-widget-mdp-coder-elementor\" data-id=\"e095163\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"mdp-coder-elementor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t        <!-- Start Coder for Elementor WordPress Plugin -->\n        <div\n            id=\"mdp-coder-e095163\"\n            class=\"mdp-coder-elementor-box\"\n            data-theme=\"mdp-theme-material-dark\"\n            data-dark-theme=\"mdp-theme-material-dark\"\n        >\n            \n                <pre class=\"language-yaml line-numbers\"data-previewers=\"\"><code>on_boot:\n  then:\n    - pzemac.reset_energy: pzemac_roof<\/code><\/pre>\n                    <\/div>\n                <script>\n            \"use strict\";\n\n            \/** Handler when the DOM is fully loaded. *\/\n            let callback_e095163 = function() {\n\n                \/** Set theme for coder widget. *\/\n                function setTheme() {\n\n                    \/** Foreach Code Widget. *\/\n                    let coderBoxes = document.querySelectorAll( '.mdp-coder-elementor-box' );\n\n                    for ( let coderBox of coderBoxes ) {\n\n                        let lightTheme = coderBox.dataset.theme;\n                        let darkTheme = coderBox.dataset.darkTheme;\n\n                        coderBox.className = '';\n                        if ( window.matchMedia && window.matchMedia( '(prefers-color-scheme: dark)' ).matches ) {\n\n                            coderBox.className = 'mdp-coder-elementor-box ' + darkTheme;\n\n                        } else {\n\n                            coderBox.className = 'mdp-coder-elementor-box ' + lightTheme;\n\n                        }\n\n                    }\n\n                }\n                setTheme();\n\n\n                \/** Watch for changes color-scheme. *\/\n                window.matchMedia(\"(prefers-color-scheme: dark)\").addListener( function() {\n                    setTheme();\n                } );\n\n                \n                if ( typeof Prism !== 'undefined' ) {\n\n                    Prism.plugins.autoloader.languages_path = 'https:\/\/chochol.io\/wp-content\/plugins\/coder-elementor\/js\/prism\/components\/';\n                    Prism.highlightAll();\n                    Prism.fileHighlight();\n\n                }\n\n                \n            };\n\n            if (\n                document.readyState === \"complete\" ||\n                ( document.readyState !== \"loading\" && !document.documentElement.doScroll )\n            ) {\n                callback_e095163();\n            } else {\n                document.addEventListener( \"DOMContentLoaded\", callback_e095163 );\n            }\n\n        <\/script>\n                <!-- End Coder for Elementor WordPress Plugin -->\n\n        \t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-47a8499 elementor-widget elementor-widget-text-editor\" data-id=\"47a8499\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>This will reset the energy meter to zero, allowing you to start new measurements from zero, for example, after the end of a particular billing period or after testing. This is useful when you want to start tracking energy consumption from scratch, without having to reset it manually.<\/p><p>If you need to reset the kWh value once, you can temporarily add this section to your code, start the device, and then delete or \u201ccomment out\u201d (#) the code to remember the new values in the future.<\/p><h2>Useful links<\/h2><p>For further exploration and detailed information, I recommend checking out the links below. They are valuable sources that were used in the development of this guide.<\/p><ul><li>Getting Started with ESPHome and Home Assistant. <a href=\"https:\/\/esphome.io\/guides\/getting_started_hassio#installing-esphome-dashboard\" target=\"_blank\" rel=\"noopener\">https:\/\/esphome.io\/guides\/getting_started_hassio<\/a><\/li><li>Peacefair PZEM-004T v3 Energy monitor. <a href=\"https:\/\/esphome.io\/components\/sensor\/pzemac.html\" target=\"_blank\" rel=\"noopener\">https:\/\/esphome.io\/components\/sensor\/pzemac.html<\/a><\/li><\/ul>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3bfdf28 elementor-widget elementor-widget-gallery\" data-id=\"3bfdf28\" data-element_type=\"widget\" data-e-type=\"widget\" data-settings=\"{&quot;columns&quot;:1,&quot;aspect_ratio&quot;:&quot;16:9&quot;,&quot;lazyload&quot;:&quot;yes&quot;,&quot;gallery_layout&quot;:&quot;grid&quot;,&quot;columns_tablet&quot;:2,&quot;columns_mobile&quot;:1,&quot;gap&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:10,&quot;sizes&quot;:[]},&quot;gap_tablet&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:10,&quot;sizes&quot;:[]},&quot;gap_mobile&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:10,&quot;sizes&quot;:[]},&quot;link_to&quot;:&quot;file&quot;,&quot;overlay_background&quot;:&quot;yes&quot;,&quot;content_hover_animation&quot;:&quot;fade-in&quot;}\" data-widget_type=\"gallery.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-gallery__container\">\n\t\t\t\t\t\t\t<a class=\"e-gallery-item elementor-gallery-item elementor-animated-content\" href=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/09\/IMG_8530-scaled.jpeg\" data-elementor-open-lightbox=\"yes\" data-elementor-lightbox-slideshow=\"3bfdf28\" data-elementor-lightbox-title=\"ESPHome i pomiar energii PZEM, p\u0142ytka ESP8266\" data-e-action-hash=\"#elementor-action%3Aaction%3Dlightbox%26settings%3DeyJpZCI6MjE0NTYsInVybCI6Imh0dHBzOlwvXC9jaG9jaG9sLmlvXC93cC1jb250ZW50XC91cGxvYWRzXC8yMDI0XC8wOVwvSU1HXzg1MzAtc2NhbGVkLmpwZWciLCJzbGlkZXNob3ciOiIzYmZkZjI4In0%3D\">\n\t\t\t\t\t<div class=\"e-gallery-image elementor-gallery-item__image\" data-thumbnail=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/09\/IMG_8530-1024x768.jpeg\" data-width=\"1024\" data-height=\"768\" aria-label=\"Przeka\u017anik\/regulator \u0142adowania do akumulatora kwasowo-o\u0142owiowego z listw\u0105 zaciskow\u0105 i przewodami 12V oraz USB\" role=\"img\" ><\/div>\n\t\t\t\t\t\t\t\t\t\t\t<div class=\"elementor-gallery-item__overlay\"><\/div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/a>\n\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9acb48a elementor-grid-3 elementor-grid-tablet-2 elementor-grid-mobile-1 elementor-posts--thumbnail-top elementor-card-shadow-yes elementor-posts__hover-gradient elementor-widget elementor-widget-global elementor-global-20844 elementor-widget-posts\" data-id=\"9acb48a\" data-element_type=\"widget\" data-e-type=\"widget\" data-settings=\"{&quot;cards_row_gap&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:10,&quot;sizes&quot;:[]},&quot;cards_columns&quot;:&quot;3&quot;,&quot;cards_columns_tablet&quot;:&quot;2&quot;,&quot;cards_columns_mobile&quot;:&quot;1&quot;,&quot;cards_row_gap_tablet&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:&quot;&quot;,&quot;sizes&quot;:[]},&quot;cards_row_gap_mobile&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:&quot;&quot;,&quot;sizes&quot;:[]}}\" data-widget_type=\"posts.cards\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-posts-container elementor-posts elementor-posts--skin-cards elementor-grid\" role=\"list\">\n\t\t\t\t<article class=\"elementor-post elementor-grid-item post-20563 post type-post status-publish format-standard has-post-thumbnail hentry category-hardware tag-ads-b tag-raspberry-pi\" role=\"listitem\">\n\t\t\t<div class=\"elementor-post__card\">\n\t\t\t\t<a class=\"elementor-post__thumbnail__link\" href=\"https:\/\/chochol.io\/en\/hardware\/how-to-change-rtl-sdr-dongle-serial-number-on-linux\/\" tabindex=\"-1\" target=\"_blank\"><div class=\"elementor-post__thumbnail\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"169\" src=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/04\/Okladka-artykulow-Chochol.io_-4-300x169.png\" class=\"attachment-medium size-medium wp-image-20537\" alt=\"RTL-SDR V4 USB radio receiver module with SMA antenna connector over blurred SDR UI screenshot\" srcset=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/04\/Okladka-artykulow-Chochol.io_-4-300x169.png 300w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/04\/Okladka-artykulow-Chochol.io_-4-1024x576.png 1024w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/04\/Okladka-artykulow-Chochol.io_-4-768x432.png 768w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/04\/Okladka-artykulow-Chochol.io_-4-1536x864.png 1536w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/04\/Okladka-artykulow-Chochol.io_-4.png 1920w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/div><\/a>\n\t\t\t\t<div class=\"elementor-post__badge\">Hardware<\/div>\n\t\t\t\t<div class=\"elementor-post__text\">\n\t\t\t\t<span class=\"elementor-post__title\">\n\t\t\t<a href=\"https:\/\/chochol.io\/en\/hardware\/how-to-change-rtl-sdr-dongle-serial-number-on-linux\/\">\n\t\t\t\tHow to change RTL-SDR dongle serial number on Linux\t\t\t<\/a>\n\t\t<\/span>\n\t\t\t\t<div class=\"elementor-post__excerpt\">\n\t\t\t<p>Discover simple instruction for changing the serial number of an RTL-SDR dongle on Linux. A step-by-step guide through the modification process.<\/p>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/article>\n\t\t\t\t<article class=\"elementor-post elementor-grid-item post-21043 post type-post status-publish format-standard has-post-thumbnail hentry category-hardware tag-diy tag-iot tag-raspberry-pi\" role=\"listitem\">\n\t\t\t<div class=\"elementor-post__card\">\n\t\t\t\t<a class=\"elementor-post__thumbnail__link\" href=\"https:\/\/chochol.io\/en\/hardware\/ogn-receiver-installation-and-configuration-on-raspberry-pi\/\" tabindex=\"-1\" target=\"_blank\"><div class=\"elementor-post__thumbnail\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"169\" src=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/05\/Okladka-artykulow-Chochol.io_-4-300x169.png\" class=\"attachment-medium size-medium wp-image-21001\" alt=\"Glidernet.org map interface with RG logo and GN marker icons over a blurred geographic map and legend panel\" srcset=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/05\/Okladka-artykulow-Chochol.io_-4-300x169.png 300w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/05\/Okladka-artykulow-Chochol.io_-4-1024x576.png 1024w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/05\/Okladka-artykulow-Chochol.io_-4-768x432.png 768w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/05\/Okladka-artykulow-Chochol.io_-4-1536x864.png 1536w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/05\/Okladka-artykulow-Chochol.io_-4.png 1920w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/div><\/a>\n\t\t\t\t<div class=\"elementor-post__badge\">Hardware<\/div>\n\t\t\t\t<div class=\"elementor-post__text\">\n\t\t\t\t<span class=\"elementor-post__title\">\n\t\t\t<a href=\"https:\/\/chochol.io\/en\/hardware\/ogn-receiver-installation-and-configuration-on-raspberry-pi\/\">\n\t\t\t\tOGN: Receiver installation and configuration on Raspberry Pi\t\t\t<\/a>\n\t\t<\/span>\n\t\t\t\t<div class=\"elementor-post__excerpt\">\n\t\t\t<p>A simple guide to installing and configuring an OGN receiver on a Raspberry Pi for air traffic monitoring. Watch air traffic.<\/p>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/article>\n\t\t\t\t<article class=\"elementor-post elementor-grid-item post-1672 post type-post status-publish format-standard has-post-thumbnail hentry category-computer-networking tag-mikrotik\" role=\"listitem\">\n\t\t\t<div class=\"elementor-post__card\">\n\t\t\t\t<a class=\"elementor-post__thumbnail__link\" href=\"https:\/\/chochol.io\/en\/computer-networking\/how-to-configure-a-leox-gpon-ont-module-on-a-mikrotik-router\/\" tabindex=\"-1\" target=\"_blank\"><div class=\"elementor-post__thumbnail\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"169\" src=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/01\/Okladka-artykulow-Chochol.io-3-300x169.png\" class=\"attachment-medium size-medium wp-image-1626\" alt=\"Network router with green and yellow Ethernet cables, server rack ports, and wireless icon overlay\" srcset=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/01\/Okladka-artykulow-Chochol.io-3-300x169.png 300w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/01\/Okladka-artykulow-Chochol.io-3-1024x576.png 1024w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/01\/Okladka-artykulow-Chochol.io-3-768x432.png 768w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/01\/Okladka-artykulow-Chochol.io-3-1536x864.png 1536w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/01\/Okladka-artykulow-Chochol.io-3.png 1920w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/div><\/a>\n\t\t\t\t<div class=\"elementor-post__badge\">Computer networking<\/div>\n\t\t\t\t<div class=\"elementor-post__text\">\n\t\t\t\t<span class=\"elementor-post__title\">\n\t\t\t<a href=\"https:\/\/chochol.io\/en\/computer-networking\/how-to-configure-a-leox-gpon-ont-module-on-a-mikrotik-router\/\">\n\t\t\t\tHow to configure a Leox GPON ONT module on a Mikrotik router\t\t\t<\/a>\n\t\t<\/span>\n\t\t\t\t<div class=\"elementor-post__excerpt\">\n\t\t\t<p>Step-by-step guide on how to configure Leox LXT-010S-H GPON ONT module on Mikrotik RB5009 router, instead of ONT module from Orange.<\/p>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/article>\n\t\t\t\t<article class=\"elementor-post elementor-grid-item post-1095 post type-post status-publish format-standard has-post-thumbnail hentry category-blog\" role=\"listitem\">\n\t\t\t<div class=\"elementor-post__card\">\n\t\t\t\t<a class=\"elementor-post__thumbnail__link\" href=\"https:\/\/chochol.io\/en\/blog\/printhello-world\/\" tabindex=\"-1\" target=\"_blank\"><div class=\"elementor-post__thumbnail\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"171\" src=\"https:\/\/chochol.io\/wp-content\/uploads\/2023\/12\/jedna-osoba-piszaca-na-laptopie-w-biurze-wygenerowana-przez-sztuczna-inteligencje-300x171.jpg\" class=\"attachment-medium size-medium wp-image-984\" alt=\"Person typing on a laptop keyboard in a dim office, hands visible over the trackpad and keys\" srcset=\"https:\/\/chochol.io\/wp-content\/uploads\/2023\/12\/jedna-osoba-piszaca-na-laptopie-w-biurze-wygenerowana-przez-sztuczna-inteligencje-300x171.jpg 300w, https:\/\/chochol.io\/wp-content\/uploads\/2023\/12\/jedna-osoba-piszaca-na-laptopie-w-biurze-wygenerowana-przez-sztuczna-inteligencje-1024x585.jpg 1024w, https:\/\/chochol.io\/wp-content\/uploads\/2023\/12\/jedna-osoba-piszaca-na-laptopie-w-biurze-wygenerowana-przez-sztuczna-inteligencje-768x439.jpg 768w, https:\/\/chochol.io\/wp-content\/uploads\/2023\/12\/jedna-osoba-piszaca-na-laptopie-w-biurze-wygenerowana-przez-sztuczna-inteligencje-1536x878.jpg 1536w, https:\/\/chochol.io\/wp-content\/uploads\/2023\/12\/jedna-osoba-piszaca-na-laptopie-w-biurze-wygenerowana-przez-sztuczna-inteligencje-2048x1170.jpg 2048w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/div><\/a>\n\t\t\t\t<div class=\"elementor-post__badge\">Blog<\/div>\n\t\t\t\t<div class=\"elementor-post__text\">\n\t\t\t\t<span class=\"elementor-post__title\">\n\t\t\t<a href=\"https:\/\/chochol.io\/en\/blog\/printhello-world\/\">\n\t\t\t\tHello World! My beginnings in IT and technology\t\t\t<\/a>\n\t\t<\/span>\n\t\t\t\t<div class=\"elementor-post__excerpt\">\n\t\t\t<p>Welcome on my blog, where \u2018Hello World\u2019 is a symbolic start. Discover with me the fascinating world of coding and news from the world of technology. <\/p>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/article>\n\t\t\t\t<article class=\"elementor-post elementor-grid-item post-1120 post type-post status-publish format-standard has-post-thumbnail hentry category-software tag-authentik tag-docker tag-portainer\" role=\"listitem\">\n\t\t\t<div class=\"elementor-post__card\">\n\t\t\t\t<a class=\"elementor-post__thumbnail__link\" href=\"https:\/\/chochol.io\/en\/software\/authentik-single-sign-on-configuration-for-portainer\/\" tabindex=\"-1\" target=\"_blank\"><div class=\"elementor-post__thumbnail\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"148\" src=\"https:\/\/chochol.io\/wp-content\/uploads\/2023\/12\/Untitled-design-2-300x148.png\" class=\"attachment-medium size-medium wp-image-989\" alt=\"Icon of a plugin or setting connected by arrows to cloud-upload graphic in a blurred IDE dashboard UI\" srcset=\"https:\/\/chochol.io\/wp-content\/uploads\/2023\/12\/Untitled-design-2-300x148.png 300w, https:\/\/chochol.io\/wp-content\/uploads\/2023\/12\/Untitled-design-2-1024x506.png 1024w, https:\/\/chochol.io\/wp-content\/uploads\/2023\/12\/Untitled-design-2-768x380.png 768w, https:\/\/chochol.io\/wp-content\/uploads\/2023\/12\/Untitled-design-2-1536x760.png 1536w, https:\/\/chochol.io\/wp-content\/uploads\/2023\/12\/Untitled-design-2.png 1632w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/div><\/a>\n\t\t\t\t<div class=\"elementor-post__badge\">Software<\/div>\n\t\t\t\t<div class=\"elementor-post__text\">\n\t\t\t\t<span class=\"elementor-post__title\">\n\t\t\t<a href=\"https:\/\/chochol.io\/en\/software\/authentik-single-sign-on-configuration-for-portainer\/\">\n\t\t\t\tAuthentik: Single Sign-On configuration for Portainer\t\t\t<\/a>\n\t\t<\/span>\n\t\t\t\t<div class=\"elementor-post__excerpt\">\n\t\t\t<p>Single sign-on to Portainer, step by step. Discover an easy way to single sign-on. Get the convenience of container management!<\/p>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/article>\n\t\t\t\t<article class=\"elementor-post elementor-grid-item post-20374 post type-post status-publish format-standard has-post-thumbnail hentry category-software tag-authentik\" role=\"listitem\">\n\t\t\t<div class=\"elementor-post__card\">\n\t\t\t\t<a class=\"elementor-post__thumbnail__link\" href=\"https:\/\/chochol.io\/en\/software\/authentik-single-sign-on-configuration-for-wordpress\/\" tabindex=\"-1\" target=\"_blank\"><div class=\"elementor-post__thumbnail\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"169\" src=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/04\/Okladka-artykulow-Chochol.io_-2-300x169.png\" class=\"attachment-medium size-medium wp-image-20353\" alt=\"WordPress logo icon with orange circle, overlaid on blurred multi-screen website previews\" srcset=\"https:\/\/chochol.io\/wp-content\/uploads\/2024\/04\/Okladka-artykulow-Chochol.io_-2-300x169.png 300w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/04\/Okladka-artykulow-Chochol.io_-2-1024x576.png 1024w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/04\/Okladka-artykulow-Chochol.io_-2-768x432.png 768w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/04\/Okladka-artykulow-Chochol.io_-2-1536x864.png 1536w, https:\/\/chochol.io\/wp-content\/uploads\/2024\/04\/Okladka-artykulow-Chochol.io_-2.png 1920w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/div><\/a>\n\t\t\t\t<div class=\"elementor-post__badge\">Software<\/div>\n\t\t\t\t<div class=\"elementor-post__text\">\n\t\t\t\t<span class=\"elementor-post__title\">\n\t\t\t<a href=\"https:\/\/chochol.io\/en\/software\/authentik-single-sign-on-configuration-for-wordpress\/\">\n\t\t\t\tAuthentik: Single Sign-On Configuration for WordPress\t\t\t<\/a>\n\t\t<\/span>\n\t\t\t\t<div class=\"elementor-post__excerpt\">\n\t\t\t<p>Configure Single Sign-On between Authentik and WordPress for secure and comfortable login. Learn about step-by-step configuration.<\/p>\n\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/article>\n\t\t\t\t<\/div>\n\t\t\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Discover how to configure PZEM004T v3 with ESPHome to monitor electricity consumption in a smart home. Practical guide. <\/p>\n","protected":false},"author":1,"featured_media":21430,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[86],"tags":[136,138,139,135,141],"class_list":["post-21466","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-smart-home","tag-diy","tag-esphome","tag-home-assistant","tag-home-automation","tag-iot"],"_links":{"self":[{"href":"https:\/\/chochol.io\/en\/wp-json\/wp\/v2\/posts\/21466","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chochol.io\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chochol.io\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chochol.io\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chochol.io\/en\/wp-json\/wp\/v2\/comments?post=21466"}],"version-history":[{"count":0,"href":"https:\/\/chochol.io\/en\/wp-json\/wp\/v2\/posts\/21466\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/chochol.io\/en\/wp-json\/wp\/v2\/media\/21430"}],"wp:attachment":[{"href":"https:\/\/chochol.io\/en\/wp-json\/wp\/v2\/media?parent=21466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chochol.io\/en\/wp-json\/wp\/v2\/categories?post=21466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chochol.io\/en\/wp-json\/wp\/v2\/tags?post=21466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}