December 18, 20232 yr Background: I have certain 'trust issues' when it comes to utility supply companies. Whether it was 'Good Energy', who helped themselves to £3,000 from my bank account in the week my first child was born (they apparently transposed two digits on a meter read), or the corporate behemoth 'Octopus Energy', who in the 18 months I was with them (and since) never once managed to produce a bill that reflected the tariff or rates that I was supposedly on, or any number of sh*t-weasels in between, I don't know. Suffice to say, they all rank somewhere beneath Estate Agents in my book. So I like to keep tabs on my energy consumption. We have a 'SMETS2' Smart Meter (Landis + Gyr E470) on a dual-rate tariff. Supposedly, this meter transmits usage data (over the 3G network) to the supply company (via the DCC, or 'Data Collection Company') and it can communicate over the HAN (home area network) with a display unit, to give the customer real-time information on consumption, daily totals, costs etc. In practice, though, forget it. Even if they did eventually send me the display device, the data is only available via the display screen. There are other (expensive) ways of obtaining the data that require a third-party company/device, but not for me. I suspect it's only half-hourly logging, anyway. The only useful information that I can get from the meter itself are the two kWh (import) registers - visible on a tiny LCD panel, and accessible through an undocumented, utterly convoluted and unmemorable series of ninja key presses on the two buttons, plus a solitary blinking red LED that blinks once per Wh imported. Smart, huh? So, I built a device to count the pulses with a 3DU5C Phototransistor, using a L239 comparator to clean the signal and send it on to an ESP8266 (I used a wemos D1 mini, as it's what I had). It's largely based on this project, but adapted for my needs (influxdb). The D1 mini connects to my wifi network and every minute logs the number of pulses it's seen since the last successful database write. It also calculates the current Wattage (simply by multiplying the duration between pulses - (1000 / pulseDuration) * 3600. It also writes to a 'night' db table when the rate changes, then a 'day' table when it changes back - the actual switching of rates I opted to do via a single UDP packet sent from a 'node-red' instance elsewhere, to avoid having to do any time keeping or NTP synchronisation on the device itself (I wouldn't want to risk missing any pulses). I found the pulses from my particular meter to be around 23ms long, so adjusted the MIN / MAX in the code accordingly. Naturally, there is an LED, which changes state whenever a pulse is detected. All housed in my trademark little grey plastic 3D printed box and clipped to the front of the meter (you can just use blu-tac, if you can remember where you put it) and powered via the micro-USB on the D1 mini. Viewed in Grafana, I can select any period of time and sum the number of pulses to get a fairly accurate idea of consumption over that period, enabling me to very quickly check my bills. I've also hard-coded in (to the Grafana dashboard) my tariff rates and standing charge - It also writes a '1' to a separate db table every night when the rate changes, to enable easy calculation of the daily standing charge. You can just about see above that at around 4.45am, my router rebooted (so communication with the db failed for about 90 secs), but the pulse reader just kept totting up the pulses until the db came back online, hence the thin spike. I hope this is useful for someone, or if not, at least interesting. 🙂 The code (I use 'Platformio') including libs is attached: Pulse Meter v0.05.zip
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.