The plan is to rig up some left over batteries with a cheap Chinese battery inverter to collect energy during the day and use it at night. Or more precisely prevent feeding energy to the grid (because I'm not payed for export) and to some extend, prevent using energy from the grid.
To start out we first need to know the energy flow from/to the grid. I had tried openenergymeter in the past but it was very inaccurate, I found it hard to use and also it required a Raspberry PI to run 24/7 which defeats the purpose: conserving energy.
So I researched my existing utility energy meter a bit to find out it actually outputs a serial data stream via infrared (apparently the format is called SML).
I started out with the physical layer. I mounted one of these reflective encoder heads (left over from Polo project) which essentially consists of an IR diode and a photo transistor. The diode is NOT needed! Nothing needs to be requested, the meter just dumps out the info every second. Ok, the photo transistor needs 15k pull up (47k makes it too slow, 10k gives too little amplitude). Since the waveform looks rather distorted we feed it through a logic gate, I just use two inverters 74ACT04.
Then it goes to the ESP via a 470 Ohm resistor to RX. RX is connected to 3V3 via a diode to level shift the 5V to a 3V3 signal. Serial data:
Code: Select all
/EBZ5DD3BZ06ETA_107 1-0:0.0.0*255(1EBZ0100200608) 1-0:96.1.0*255(1EBZ0100200608) 1-0:1.8.0*255(007306.09759253*kWh) 1-0:16.7.0*255(000179.47*W) 1-0:36.7.0*255(000044.82*W) 1-0:56.7.0*255(000134.65*W) 1-0:76.7.0*255(000000.00*W) 1-0:32.7.0*255(232.6*V) 1-0:52.7.0*255(233.1*V) 1-0:72.7.0*255(232.9*V) 1-0:96.5.0*255(001C0104) 0-0:96.8.0*255(064F18F0) !
Next we need to write some Arduino C++. Little surprise I took the inverter sketch and modified it. Serial interface runs at 9600 7E1 (first time I see parity used).
Soon had some output Now went off on a tangent and decided to record that data to a mysql database. That allows more systematic analysis.
So now have a 1-second updating web page And a daily overview Everything below 0 means we're exporting to the grid. Some number crunching later I found I "lost" 2 kWh today.
Decided to not run 10m of wire through the public stair case, below our apartment door and onto my desk. So put everything into a DIN rail enclosure next to a DIN rail 5V supply. Pretty huh? Code: https://github.com/jsphuebner/esp-egycounter