Another smaller Raspberry Pi project. This is in addition to the Growatt inverter read-out project where I keep track of energy production from my PV array. The next obvious thing to ask is how the energy consumption compares to the production. I.e. I need some way of measuring the energy consumed in my house hold. Looking at my power meter it is a sealed box and I am not interested/legally entitled/brave enough/smart enough to do any measuremets on the high voltage side of the system. But I was inspired by a colleague to utilize the small blinking LED on the power meter to keep track of energy consumption. The idea is quite simple since the LED blinks 10.000 times pr. consumed kWh… Yes you get the idea. The blink speed is a measure of power and the total number of blinks is a measure of energy. Making a few Google searches quickly revealed that the idea is not novel. There are several applications like this out there. Even commercial systems are available which are not that expensive and also offers some cool features. But hey! There is no need to go to the extremes and buy something reliable, ready made, cost effective and installation friendly when you can have some hours of fun making it your self.
I found this easy to understand and built circuit found at Adafruit. This circuit is actually not that well suited for the application since it will only give you an instantaneous reading of the light intensity (or an indication hereof anyways), which is a little tricky to translate to blink or no blink situation. This is a first version of the blink counter and if it does not work reliably I will upgrade it to a transistor type circuit as e.g.: http://electronics.stackexchange.com/questions/38258/plugging-a-ldr-into-gpio-pins-of-a-raspberry-pi
But let’s see how it goes. I have installed a 0.1 µF capacitor to be able to get some fast readings. Back-of-an-envelope calculations says that the blink rate at extreme consumption will be 20 kW*10.000 blink/kWh = 56 blinks pr. second which the circuit should be capable of following. That is one blink pr. 18 millisecond. The circuit at it’s present form looks to be fast enough at least up to 10 kW which was what I was able to test turning on all the rings on the stove and the teaboiler too :o) Much more than consumption than that is probably not going to occur I hope. The python script which I wrote for this is under ways. I’ll just debug a bit on it before I publish it here so it will be fairly well tested and stable when it hits the site .
Pictures of the installation:
Pyhton code for running the blink counter and upload to pvoutput-org is available here. The script will count blinks for 5 min. Then recalculate the blinks counted to an average power over the time period and he total energy. Subsequently both are uploaded to www.pvoutput.org. (Production from my PV array and the household power consumption can bee see here)
In its current state the script is run 5 min past midnight each day. The script then runs over a while-loop the entire day and writes data to a text file each min and uploads data to pvoutput.org each 5 min. Then when the date changes the while loop in the script ends and a new text file is created for the next day… Hmm. I just need the text files for a detailed look into if the counter counts correctly under all consumption situations. It seems to be running ok, but it’s a little hard to get a solid validation of since the power meter only reports consumption in kWh, which is a coarse resolution.
To set up the cron job use:
sudo crontab -e
and edit the file to this