This project will not include any advanced stuff, but instead it aims to provide a simple description for how to make a simple DIY project — from start to finish. Maybe the first DIY project!? How to become a “maker”.
Background
A large portion of all energy meters display consumption by blinking (like 1,000 blinks every kWh).
There are many projects out there showing how to make an energy meter reading these blinks. But I thought I would share mine because every other instruction I found were a little bit too complicated for my liking, many involved Arduoni that I am not familiar with and so forth. And none described using the really easy ESPhome add on in Home Assistant and a ESP32 board.
If you have Home Assistant set up, this project shouldn’t take more than an hour to set up — max. And the result is pretty great, you will get an instant accurate electricity meter in your phone which will allow you to monitor your consumption.
Gear:
Any ESP32 development board
A micro USB to USB-a cable that can carry data communication (many are just for charging)
Dollatek Photoresistor (https://www.amazon.co.uk/DollaTek-Digital-Intensity-Resistor-Photoresistor/dp/B07DJ4C2SN)
Small breadbord
Cables
One hinge of any type
A piece of wood
A saw
(From one hinge… to here can be replaced with ducktape)
(A) ESPhome settings etc
-
Install ESPhome.
-
Connect the ESP32 to the RPI with the cable
-
Add a board, chose board type, and make the easiest possible upload with your WiFi details. After this is done you can uploaded over the air (OTA).
Warning: Press the boot button on the ESP32 when uploading, hold it, press and release EN and then let go of boot after the upload to the board have started (after compiling etc is done). This can be a little tricky at first, but after a while you get a hang of it, it is easy.
Create and upload the following settings:
esphome:
name: bleel
platform: ESP32
board: esp32dev
wifi:
ssid: "passwordis1234”
password: "1234"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Blebrygga Fallback Hotspot"
password: "ea0QLTX9C8bV"
captive_portal:
# Enable logging
logger:
api:
ota:
sensor:
- platform: pulse_counter
pin: GPIO14
unit_of_measurement: 'kW'
name: 'Power Meter'
filters:
- multiply: 0.06
total:
unit_of_measurement: 'kWh'
name: 'Energy Meter House'
filters:
- multiply: 0.001
(B) Wire the ESP32
- Draw a cable from ground (gnd) pin on the ESP32 board to ground on the Photoresistor (Google the symbol).
- Draw a cable from the 3v pin to vcc pin on the Photoresistor.
- Draw a cable from a suitable GIPO pin on your ESP32 to the data pin on the Photoresistor (the one left). Find which pin that is suitable by googling pinout for your ESP32 brand and model. In short — if a GIPO has no specific function it should do the trick. Some are needed for rebooting etc and then it will create problems/conflicts if that pin is chosen. State the GIPO/PIN number chosen by you in the setting (where I have pin: GPIO14).
(c )Mounting
- I used a hinge and a piece of wood to get the Photoresistor mounted immediately against the blinking light.
- I.e. just attach the hinge with screws next to the electricity meter (be careful with this if there could be cables behind the wall, glue can be used instead). Attach the piece of wood to the hinge. Then carefully apply the small breadboard (they usually have double mounted tape at the bottom) so that the head of the Photoresistor goes against the blinking light.
- Provide the ESP32 with power over a USB cable.
For me it looks like this:
When the meter blinks, so does the Photoresistor so that you can see that it works:
It’s of course possible to not use a breadboard and tape everything into place.
(D) Daily consumption meter
Add this to your configuration.yaml to get a second “sensor” measuring your daily consumption:
utility_meter:
energy:
source: sensor.power_meter
cycle: daily
(E) Install InfluxDB, IDE and Grafana in 15 minutes
Follow these instructions:
(F) Create a Lovelace card
- First create a new dashboard in Grafana.
- Chose measurement as Kw:
- FROM shall be identityid = power_meter
1-3b. Do the same for the energy meter created by editing configuration.yaml - For now, just select Vizulation and Timeline
- Select Share for the dashboard by hitting the four boxes below and do NOT select Use current timeframe:
- Create a Lovelace card using the Website alternative.
Paste the copied link from Grafana to the website. Add “&kiosk&fullscreen” to the url!
7. Now we have two editable electricity meters in a Lovelace card.
They are of course not pretty, but making improvements to the layout in Grafana is for another topic and easy for everyone to play around with.
It’s also possible to improve the energy metering to remove the spikes. I will revert to this in replies in this thread later.
Hope this helps!
And please — any tips, tricks or suggestions for improvements are greatly appreciated!!!