Site Tools


en:tech:powermeter

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:tech:powermeter [2021/01/21 11:42] – [Conclusion] bullaren:tech:powermeter [2026/08/12 12:15] (current) – external edit 127.0.0.1
Line 6: Line 6:
 One method is to build a three-phase energy meter directly into the fuse box. Among other things, you can get [[https://www.amazon.de/gp/product/B006J3A8MC/ref=ppx_yo_dt_b_asin_title_o09_s00?ie=UTF8&psc=1|here]] inexpensive versions for less than 50 €, One method is to build a three-phase energy meter directly into the fuse box. Among other things, you can get [[https://www.amazon.de/gp/product/B006J3A8MC/ref=ppx_yo_dt_b_asin_title_o09_s00?ie=UTF8&psc=1|here]] inexpensive versions for less than 50 €,
  
-{{ :tech:drehstromzaehler.png?direct&200 |}}+{{ :media:tech:solarvilla:drehstromzaehler.png?direct&200 |}}
  
 The trusted electrician will help with the installation in the fuse box if you don't trust yourself to do it. \\ The trusted electrician will help with the installation in the fuse box if you don't trust yourself to do it. \\
Line 15: Line 15:
 The first task is to investigate into the S0 interface and then make it available for evaluation in our home WiFi. Let's take a look at the S0 signal, which comes from a three-phase meter: The first task is to investigate into the S0 interface and then make it available for evaluation in our home WiFi. Let's take a look at the S0 signal, which comes from a three-phase meter:
  
-{{: tech: s0_signal.png? direct & 400 |}}+{{ :media:tech:powermeter:s0_signal.png?direct&400 |}}
  
 There are pulses of approx. 44ms and the interval between the pulses reflects the current consumption. In the example it is 19.25 seconds. According to the device specification, we can expect 1000imp / KWh. This is also noted on the front of the meter. This results in the calculation formula for the consumption of: There are pulses of approx. 44ms and the interval between the pulses reflects the current consumption. In the example it is 19.25 seconds. According to the device specification, we can expect 1000imp / KWh. This is also noted on the front of the meter. This results in the calculation formula for the consumption of:
Line 28: Line 28:
 If you want to use WiFi with your own projects, it is always advisable to first take a look at the ESP8266 modules. If you want to use WiFi with your own projects, it is always advisable to first take a look at the ESP8266 modules.
  
-{{ :tech:esp07.jpg? nolink & 200 | ESP-07}}+{{ :media:tech:ut71:esp07.jpg? nolink & 200 | ESP-07}}
  
 One of the simplest approaches is an ESP-07 with the open source firmware [[https://www.letscontrolit.com/wiki/index.php/ESPEasy|ESP Easy]]. In fact, we can manage to implement the above task without our own programming. \\ One of the simplest approaches is an ESP-07 with the open source firmware [[https://www.letscontrolit.com/wiki/index.php/ESPEasy|ESP Easy]]. In fact, we can manage to implement the above task without our own programming. \\
 But first let's fix the electrical and mechanical structure. The circuit diagram is very clear and is similar to the [[en:tech:bedsensor | bed sensor]] project here elsewhere. The circuit has three S0 inputs if you want to evaluate the phases individually. I only used one in my installation because you already know that I get the total consumption delivered. But first let's fix the electrical and mechanical structure. The circuit diagram is very clear and is similar to the [[en:tech:bedsensor | bed sensor]] project here elsewhere. The circuit has three S0 inputs if you want to evaluate the phases individually. I only used one in my installation because you already know that I get the total consumption delivered.
  
-{{ :tech:powermeter_schematic.png?direct&400 |}}+{{ :media:tech:powermeter:powermeter_schematic.png?direct&400 |}}
  
 The internal pull-ups supply the optocoupler of the three-phase meter, so the impulse can be recognized at the respective pins. The diodes D1-D3 are only used to protect against polarity reversal and are not absolutely necessary. The internal pull-ups supply the optocoupler of the three-phase meter, so the impulse can be recognized at the respective pins. The diodes D1-D3 are only used to protect against polarity reversal and are not absolutely necessary.
 Of course, the S0 lines can also be connected directly to the module, thus avoiding the PCB with free wiring. For my solution, however, I created a PCB. Of course, the S0 lines can also be connected directly to the module, thus avoiding the PCB with free wiring. For my solution, however, I created a PCB.
  
-{{ :tech:powermeter_pcb.png?direct&400 |}} +{{ :media:tech:powermeter:powermeter_pcb.png?direct&400 |}} 
-{{ :tech:powermeter_pcb_3d.png?direct&400 |}}+{{ :media:tech:powermeter:powermeter_pcb_3d.png?direct&400 |}}
  
 The S0 lines are connected using screw terminals. The power supply can also be plugged in with a 5.5 / 2.1mm socket. For this you can find very inexpensive plug-in power supplies with a stabilized 3.3V DC voltage output. The PowerMeter does not need more wired connectivity. The S0 lines are connected using screw terminals. The power supply can also be plugged in with a 5.5 / 2.1mm socket. For this you can find very inexpensive plug-in power supplies with a stabilized 3.3V DC voltage output. The PowerMeter does not need more wired connectivity.
Line 45: Line 45:
 With a 3D printer, an inconspicuous housing can be realized which can easily be attached with double-sided adhesive tape outside the fuse box. With a 3D printer, an inconspicuous housing can be realized which can easily be attached with double-sided adhesive tape outside the fuse box.
  
-{{ :tech:powermeter_housing.png?direct&400 |}} +{{ :media:tech:powermeter:powermeter_housing.png?direct&400 |}} 
-{{ :tech:powermeter_3d_print.jpeg?direct&200 |}}+{{ :media:tech:powermeter:powermeter_3d_print.jpeg?direct&200 |}}
  
-===== Programmierung =====+===== Programming (ESPEasy)=====
  
 After the hardware has been created, we still have to program the ESP module. As already mentioned, the PowerMeter is based on [[https://www.letscontrolit.com/wiki/index.php/ESPEasy|ESPEasy]]. In the link you can also find instructions on how the ESPEasy firmware is installed on the module. In order to get into the programming mode, the jumper SJ1 must be closed during the reset release. The programming is done serially via JP1 (USB-serial converter). After the hardware has been created, we still have to program the ESP module. As already mentioned, the PowerMeter is based on [[https://www.letscontrolit.com/wiki/index.php/ESPEasy|ESPEasy]]. In the link you can also find instructions on how the ESPEasy firmware is installed on the module. In order to get into the programming mode, the jumper SJ1 must be closed during the reset release. The programming is done serially via JP1 (USB-serial converter).
Line 71: Line 71:
 '' middleware.php/data/<uuid>.json?operation=add&value=%val3%'' '' middleware.php/data/<uuid>.json?operation=add&value=%val3%''
  
-{{ :tech:powermeter_esp_http.png? direct & 200 |}}+{{ :media:tech:powermeter:powermeter_esp_http.png? direct & 200 |}}
  
 === MQTT === === MQTT ===
Line 77: Line 77:
 Now we select MQTT and enter the relevant data. This includes the IP address of the MQTT server and the account data for logging in. The result should look similar to the following example. Here only the IP of the own MQTT server is anonymized and must be adapted accordingly. Now we select MQTT and enter the relevant data. This includes the IP address of the MQTT server and the account data for logging in. The result should look similar to the following example. Here only the IP of the own MQTT server is anonymized and must be adapted accordingly.
  
-{{ :tech:powermeter_esp_mqtt.png?direct&200 |}}+{{ :media:tech:powermeter:powermeter_esp_mqtt.png?direct&200 |}}
  
 ==== Hardware Setup ==== ==== Hardware Setup ====
Line 83: Line 83:
 On this tab we only have to switch on the pull-ups at the inputs used. On this tab we only have to switch on the pull-ups at the inputs used.
  
-{{:tech:powermeter_esp_hardware.png?direct&400 |}}+{{ :media:tech:powermeter:powermeter_esp_hardware.png?direct&400 |}}
  
 ==== Device Setup ==== ==== Device Setup ====
Line 89: Line 89:
 Next we need a device that measures and stores the time between pulses. This can be achieved via the Devices tab. A separate device is required for each S0 input. Here is just one input shown in my solution. Next we need a device that measures and stores the time between pulses. This can be achieved via the Devices tab. A separate device is required for each S0 input. Here is just one input shown in my solution.
  
-{{ :tech:powermeter_esp_devices.png?direct&200 | Device Setup}}+{{ :media:tech:powermeter:powermeter_esp_devices.png?direct&200 | Device Setup}}
  
 Incidentally, the green numbers on the right indicate the current measured values. In the example, the time is 25991ms, which corresponds to a consumption of 138.5 watts. Incidentally, the green numbers on the right indicate the current measured values. In the example, the time is 25991ms, which corresponds to a consumption of 138.5 watts.
 Here are the settings for the pulse counter: Here are the settings for the pulse counter:
  
-{{ :tech:powermeter_esp_pulsecounter.png?direct&200 | Pulse Counter}}+{{ :media:tech:powermeter:powermeter_esp_pulsecounter.png?direct&200 | Pulse Counter}}
  
 Now we have a connection to the MQTT server and we can determine the consumption. What is missing is the flow control for MQTT. There are rules for this within ESPEasy: To do this, copy the following code into rules set 1. Now we have a connection to the MQTT server and we can determine the consumption. What is missing is the flow control for MQTT. There are rules for this within ESPEasy: To do this, copy the following code into rules set 1.
Line 105: Line 105:
  
 The calculated result is sent to the MQTT server at each completed measurement interval. The calculated result is sent to the MQTT server at each completed measurement interval.
 +
 +===== Programming (ESPHome)=====
 +The PowerMeter can also easily be integrated with help of [[https://esphome.io|ESPHome]] into [[https://www.home-assistant.io|Home Assistant]]. The sample code for one phase you will find here:
 +
 +<code yaml>
 +esphome:
 +  name: powermeter
 +
 +esp8266:
 +  board: esp01_1m
 +
 +# Enable logging
 +logger:
 +
 +# Enable Home Assistant API
 +api:
 +  encryption:
 +    key: "---key---"
 +
 +ota:
 +  password: "---password---"
 +
 +wifi:
 +  ssid: !secret wifi_ssid
 +  password: !secret wifi_password
 +
 +  # Enable fallback hotspot (captive portal) in case wifi connection fails
 +  ap:
 +    ssid: "Powermeter Fallback Hotspot"
 +    password: "--password--"
 +
 +captive_portal:
 +
 +time:
 +  - platform: sntp
 +    id: my_time
 +
 +sensor:
 +  - platform: pulse_counter
 +    pin: 
 +      number: GPIO14
 +      inverted: true
 +      mode:
 +        input: true
 +        pullup: true
 +    unit_of_measurement: 'kW'
 +    name: 'Power Meter Flat'
 +    id: powermeter_flat
 +    internal_filter: 10us
 +    filters:
 +      - multiply: 0.06  # (60s/1000 pulses per kWh)
 +
 +  - platform: total_daily_energy
 +    name: "Total Daily Energy"
 +    power_id: powermeter_flat
 +</code>
 +
 +Instead of measuring the time between two pulses the number of pulse per time interval is counted. 
  
  
 ===== Conclusion ===== ===== Conclusion =====
  
-The PowerMeter has been running for 2 months without any problems and is transmitting the data. A typical consumption curve looks like this (screen shot from my own //Volkszähler//):+The PowerMeter is running more than a year now without any problems and is transmitting the data. A typical consumption curve looks like this (screen shot from my own [[https://www.volkszaehler.org|//Volkszähler//]]):
  
-{{ :tech:verbrauch.png?direct&600 |}}+{{ :media:tech:solarvilla:verbrauch.png?direct&600 |}}
  
 The peaks include the oven, stove and kettle. The regular pulses come from the fridge/freezer equipment. My base load is 150 watts and is certainly also due to the automation. The peaks include the oven, stove and kettle. The regular pulses come from the fridge/freezer equipment. My base load is 150 watts and is certainly also due to the automation.
Line 118: Line 176:
 ===== Downloads ===== ===== Downloads =====
  
-  * {{:tech:powermeter_schematic.pdf| Schaltplan (,pdf)}} +  * {{:media:tech:powermeter:powermeter_schematic.pdf| Schaltplan (,pdf)}} 
-  * {{:tech:powermeter_bom.csv.zip| Bestückungsliste (BOM) als .csv}} +  * {{:media:tech:powermeter:powermeter_bom.csv.zip| Bestückungsliste (BOM) als .csv}} 
-  * {{:tech:powermeter.brd.zip| PCB Eagle File (.brd)}} +  * {{:media:tech:powermeter:powermeter.brd.zip| PCB Eagle File (.brd)}} 
-  * {{:tech:powermeter_v2.stl.zip| Gehäuse (.stl)}}+  * {{:media:tech:powermeter:powermeter_v2.stl.zip| Gehäuse (.stl)}}
  
  
-==== Donate ====+===== Donate =====
  
-If you line my articles feel to donate a cappuccino or so...+If you like my articles feel to donate a cappuccino or so...
  
 <html> <html>
en/tech/powermeter.1611229322.txt.gz · Last modified: by bullar