This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:tech:powermeter [2021/01/21 11:24] – bullar | en:tech:powermeter [2022/11/07 16:15] (current) – [Programming (ESPHome)] bullar | ||
---|---|---|---|
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? | + | {{ : |
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, | 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, | ||
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. | ||
- | {{: | + | {{ : |
One of the simplest approaches is an ESP-07 with the open source firmware [[https:// | One of the simplest approaches is an ESP-07 with the open source firmware [[https:// | ||
Line 48: | Line 48: | ||
{{ : | {{ : | ||
- | ===== 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:// | ||
+ | |||
+ | If everything went well and the module is integrated in the home WiFi, all further settings can be made via the web interface. For this we need: | ||
+ | * Controller setup | ||
+ | * HTTP | ||
+ | * MQTT | ||
+ | * Hardware setup | ||
+ | * Device setup | ||
+ | * Rules Setup | ||
+ | |||
+ | ==== Controler Setup ==== | ||
+ | |||
+ | In my case, I send the data to my [[https:// | ||
+ | In order to display the current consumption value on a panel (I use [[https:// | ||
+ | |||
+ | === HTTP === | ||
+ | |||
+ | The gray areas are the anonymization of the host and the UUID of the // | ||
+ | |||
+ | '' | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | === MQTT === | ||
+ | |||
+ | 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. | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | ==== Hardware Setup ==== | ||
+ | |||
+ | On this tab we only have to switch on the pull-ups at the inputs used. | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | ==== Device Setup ==== | ||
+ | |||
+ | 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. | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | Incidentally, | ||
+ | Here are the settings for the 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. | ||
+ | |||
+ | < | ||
+ | On S0Pulse# | ||
+ | publish / | ||
+ | endon | ||
+ | </ | ||
+ | |||
+ | 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:// | ||
+ | |||
+ | <code yaml> | ||
+ | esphome: | ||
+ | name: powermeter | ||
+ | |||
+ | esp8266: | ||
+ | board: esp01_1m | ||
+ | |||
+ | # Enable logging | ||
+ | logger: | ||
+ | |||
+ | # Enable Home Assistant API | ||
+ | api: | ||
+ | encryption: | ||
+ | key: " | ||
+ | |||
+ | ota: | ||
+ | password: " | ||
+ | |||
+ | wifi: | ||
+ | ssid: !secret wifi_ssid | ||
+ | password: !secret wifi_password | ||
+ | |||
+ | # Enable fallback hotspot (captive portal) in case wifi connection fails | ||
+ | ap: | ||
+ | ssid: " | ||
+ | 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: | ||
+ | name: 'Power Meter Flat' | ||
+ | id: powermeter_flat | ||
+ | internal_filter: | ||
+ | filters: | ||
+ | - multiply: 0.06 # (60s/1000 pulses per kWh) | ||
+ | |||
+ | - platform: total_daily_energy | ||
+ | name: "Total Daily Energy" | ||
+ | power_id: powermeter_flat | ||
+ | </ | ||
+ | |||
+ | Instead of measuring the time between two pulses the number of pulse per time interval is counted. | ||
+ | |||
+ | |||
+ | ===== Conclusion ===== | ||
+ | |||
+ | 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:// | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | The peaks include the oven, stove and kettle. The regular pulses come from the fridge/ | ||
+ | |||
+ | |||
+ | ===== Downloads ===== | ||
+ | |||
+ | * {{: | ||
+ | * {{: | ||
+ | * {{: | ||
+ | * {{: | ||
+ | |||
+ | |||
+ | ===== Donate ===== | ||
+ | |||
+ | If you like my articles feel to donate a cappuccino or so... | ||
+ | |||
+ | < | ||
+ | |||
+ | <form action=" | ||
+ | <input type=" | ||
+ | <input type=" | ||
+ | <img alt="" | ||
+ | </ | ||
+ | |||
+ | </ | ||