Real Time Power Meter Pulse Monitoring

TLDR; Monitoring LED Pulses on Power Meters to get real time energy consumption:

Screen Shot 2018-01-21 at 4.28.24 PM.png

My electricity supplier upgraded me a smart meter at home about a year ago, I was quite excited by the prospect of having a smart meter and being able to monitor the power usage in real time – how mistaken I was. It seems the infrastructure for smart metering in New Zealand (and maybe worldwide) is very much an afterthought.

My electricity retailer is Flick Electric who are fantastic and have a really neat concept of charging you whatever the spot price of power is at a given time + some fixed charges (which I expect is where their profit margin is) – this business model is really enabled by smart meters and the granularity on electricity consumption they provides retailers with.

flick

The problem (let’s be honest – my problem) is that Flick don’t get the data from the metering company in real time (or even close to real time) – in fact there’s usually a 2-3 day lag somewhere between the smart meter, the metering company and my electricity retailer.  The data is great, mind you – but it’s less interesting to me  personally when it’s 2 days old.

day_flick
Daily Data
week_flick
Weekly Data

My guess would be that metering infrastructure hasn’t been seriously looked at from an architectural perspective in many years –  in reality really Smart Meters are just a ‘bolt-on’ after thought to existing metering infrastructure – i’m sure the same is true all over the world – don’t get me wrong i’m not trying to cast aspersions here – it’s the nature of Information Technology in general – as a seasoned network engineer colleague of mine often says “everything is awful”.

Consumers have always been able to get an indication of current power consumption by looking at the meter itself – older meters have a spinning metal dial which operates on an electro-mechanical principle  which is really quite cool.

Modern meters are fed analog voltage and current inputs and convert to a digital signal for recording and ultimately display on the LCD panel that will be read off by a meter reader.

These newer style of meter form the basis of what are referred to as ‘smart’ meters – which are essentially add-in modules with some sort of communications technology built in (Such as GPRS or Zigbee)  these send the data back to the metering company – who act as the broker to the electricity retailer.

These modern meters are generally able to display the instantaneous power usage on the LCD panel, but also provide an optical indication (generally a pulsing LED), referred to as a meter pulse output, they generally look like this, you’ll see that the model below has 2 pulses. Though only Pulse 1 is enabled.

power

The principle is that you time the distance between the pulses of the LED.  Depending on the meter, a pulse can represent a different amount of electricity consumed. For my meter each pulse represents 1 Watt Hour (1/1000th of a kWh) – you can see this indicated just above the black rectangle i’ve drawn on over the serial number. (1000P/kWh)

plulse

1 Watt Hour is 3600 Joules. Therefore each pulse represents 3600 joules of energy consumed. We can convert this to power (i.e. Watts) by dividing 3600 by time. If a pulse is occurring exactly every 2 seconds then the power being used at the time of measurement is 1800 Watts (P=3600/2)

The barrier to entry is pretty high for consumers to get at this kind of real time data in a meaningful way. There are exceptions to this, such as meters designed from the outset for consumers – such as the now defunct Google Power Meter.

But this kind of consumer forms a very, very low proportion of the overall market – for a metering company the demand is low for instantaneous power consumptions information in an accessible way.

For consumers there are off the shelf products such as the EmonPi which also include CT Clamps (which are a real faff and require you to separate your live and neutral wires at your breaker box – you’ll need a qualified electrician to do this for you).

The less invasive method using this kit allows you to monitor the aforementioned pulses coming from the LED on the meter itself – I did not want to go down this path –  generally because they are very expensive! £183.97 (NZ$350/US$255) – but also because i enjoy making things myself.

You can also get a little pluggable module that goes into a standard power socket to give you readings for anything plugged into it.

plug

My solution

So I wanted to build something that could interpret those pulses and feed into my home sensor network. I initially started my prototype using a photoresistor with a LM393 comparator – which failed miserably. Whilst i could pick up ‘something’ from it, the changes in voltage were so low I couldn’t be sure that they were just within error margins.

LDR
Photo of Photoresistor – By © Nevit Dilmen, CC BY-SA 3.0

I’ll add that photoresistors are generally very sensitive to ambient light, this was not the issue as when my meter box is closed it is pitch black in there.

I was a little dismayed by the results but my friend offered to ask his father, who was an electrical engineer before he retired a couple of years ago. His father said LDRs are ‘old school’ and that I should use a photo transistor – the benefit of a transistor is I could do away with the need for a comparator circuit. (The irony of being told that I was using ‘old school’ tech by a retired engineer is not lost on me)

It seems that most photo transistors available in generalist stores (such as jaycar) are sensitive in the InfraRed range – the LED on my power meter is red which peaks at a wavelength of 625nm – my assumption was that it would still have a component of IR and worth an experiment – besides, it was all that was available to me without waiting for components to arrive in the mail.

wavelengths
Infrared in relation to electromagnetic spectrum – By Arkrishna – Own work, CC BY-SA 3.0

Unfortunately i had no luck with an IR sensitive photo transistor.

I did some research and came across the TSL257-LF Visible Light Photo Detector, it peaks at around 700nm, but crucially is still plenty sensitive at 625nm – which is what i needed!

graph
TSL257-LF Spectral Responsivity
Photo Transistor
TSL257-LF

Once I had identified this component, a google search for it with “pulse monitoring” turned up a handful of results where folk had used this exact photo transistor in the application I wanted to use it for (and somebody had even designed a 3D printable light blocking mount for it) – I had googled for ‘pulse meter monitoring’ before without knowledge of this component and not come across it – hindsight eh?

I’d say that through my trial and error I learnt a lot more than if i had got the right component straight away.

3D printed housing

I 3D printed the aforementioned mount for it, then used a toilet roll tube (I up-cycle these a lot) and a pulsing red LED hooked up to an Arduino to work out the best distance to place the diode away from the LED to get the best results, turned out to be about 30mm.

tube

I ended up using ADC on the Arduino to read the voltages very fast in a loop – I did read that another New Zealander – (who it turns out have actually met before at a 3D printing workshop – back when my friend and I owned our first 3D printer – a Cupcake!) – had success putting it straight into the digital input on a similar board  – this unfortunately didn’t work for me. It would  have been more elegant as I would have been able to use the Arduino’s digital input to detect the exact rising and falling of the pulses using interrupts. Maybe that’s something i’ll try and work out in a second revision.

The prototype in place

proto1

I wrote some quick Arduino code to time whenever the voltage hit a certain threshold and report the time in milliseconds  – as my sample rate was very high I would record the same pulse multiple times (another reason why digital input and interrupts would be more elegant)

Nevertheless I put the raw output into google sheets and worked out how to do my debouncing (not really debouncing in its purest sense, but similar in principle):

results.jpg

Huzzah! – Sane values!

I wired everything up and as my power meter box backs onto my garage it was easy for me to feed some servo cables through and run everything from power in the garage – rather than having to worry with the problem of powering the whole thing outdoors.

servos
I’ll replace the medical tape with some 3M double sided tape so i’m not obstructing the LCD display once i’ve finished calibration.

Next I needed to get the data going somewhere regularly to do some analysis and work out how well calibrated my solution was.

The dataflow design I went with to get the data into my existing sensor/monitoring network was using commonly available open source software and messaging protocols:

MQTT, Telegraf, InfluxDB and Grafana

Untitled Diagram (1)

Right now I have the system reporting instantaneous power consumption data every 30 seconds. I will share the Arduino code for reading the data and publishing to MQTT once i’ve finished calibration – so be sure to check back soon.

The results are very pretty and the 30 second granularity shows me some very interesting usage patterns in my house.

Screen Shot 2018-01-21 at 4.12.54 PM.png
Overnight Power Consumption

The first interesting thing you’ll see are the jagged spikes every 5 minutes or so – these are my espresso machine with it’s 1500 Watt boiler turning on to keep the water at temperature (this is a commercial coffee machine) – I could turn the coffee machine off overnight but i’ve been told on pretty good authority that the constant cycling of a copper boiler and the resultant contraction and expansion can cause cracking. So for now I leave it on 24/7 unless i’m away for a long period of time.

The second interesting observation is the spikes that occur approximately every hour and a half, this is my hot water cylinder with it’s 2000w heating element.

I turned off both the hot water cylinder and the coffee machine over night to confirm this and with all of that noise from the hot water cylinder and coffee machine gone I discovered something else with some periodicity – I say ‘found’ though i’ve not worked out exactly what it is yet – but my money is on my fridge.

Screen Shot 2018-01-21 at 4.24.49 PM

All of the data so far seems to suggest i’ve got my code pretty well tuned on my first attempt. But i’ll leave it running for a week and see how it compares to my utility bill.

How to Bake a Loaf of Sourdough

***This recipe assumes you already have a healthy sourdough starter, if you don’t then read this post on how to get started with one.
20180728_170211

The night before you want to bake

Every Friday night I take starter out of the fridge. I keep it in an ice cream tub-like container. Over the week it will have settled a bit and there will be fluid sitting on the top. Just grab your wooden spoon and stir it through again.

Next you want to get a measuring cup and take out 1/4 cup of starter and put it into a mixing bowl.

Before you get to work on making the bread, you want to put in 28 grams of whole grain flour and 1/4 cup of water back into the starter container. Mix it through and put back into the fridge.

To get the bread kicked off, you want to put about 28 grams of flour and 1/4 cup of water into a container and mix it through.

After an hour, add the same.

After another hour add the same.

Finally before bed put in double the amount, mix through and leave in a warm place overnight.

The next day

The mixture in your container should be full of tiny bubbles now, this means it has woken up and is active, if it doesn’t have any bubbled or very few then you’ll need to keep feeding it until it is… if it was left in a cold place overnight this could be why.

20180721_122528.jpg
Bubbling Starter

Measure out 150 grams of the mixture you made and add into another mixing bowl along with:

  • 500g flour
  • 250ml water
  • 25g olive oil
  • 10g salt
20180721_122525.jpg
Mixture

You want to squelch the mixture between your fingers until it is all pretty moist and a bit of a shaggy mess. Get your hands messy.

20180721_122735
Squelch

Cover mixing bowl with glad wrap and wait about 30 mins for it to rise a bit. This will give it time to become a bit less sticky and easier to knead.

20180721_123419
Shaggy Mess

After the 30 minutes, take it out onto the bench and  knead before shaping it into a ball and putting back into mixing bowl, covered again with gladwrap.

 

ball.jpg

WAIT

Now is the waiting game, there is no magic time to wait, you just need to wait until the dough has roughly doubled in size, the time for this depends on how active your starter was after you woke it up the night before, how warm your room is etc…

Now it has doubled, line a baking tray with some baking paper – or use semolina – take the dough out and put onto the tray, cover with clingfilm/gladwrap so that the surface doesn’t dry out.

20180728_151639
Doubled in size

It will have deflated a bit when you moved it, so we want to wait again for it to rise a bit more.

While it is rising, put your oven to its maximum temperature to heat up.

After the dough has risen, take off the clingfilm and give it a slash or two to control where the cracks occur (also to give it an artisanal look)

I don’t have any decent photos of a pre-baked slash, but you could do big slashes or several small slashes the effects are very different:

Run your hands under the tap, then flick off most of the water and rub your hands on the surface of the bread.

Get a small amount of flour and rub that over the top of the dough. (again this helps with the artisanal look)

Finally, put the baking tray in the oven. Immediately turn the temperature down to 220 degrees c (428 F). (the reason we have it start off much higher is that this causes “oven spring” – causing the yeasts to burst and creating one final rise)

I like to prepare a small tray of hot water to put in the oven at the same time as the bread, this – along with the high initial temperature helps to create oven-spring.

After 20 minutes, lower the temperature to 180 degrees c (356 F).

After another 20 minutes you should be okay to take the bread out of the oven.

Always remember you should wait for the bread to fully cool before you slice it, otherwise you can get a gummy crumb to it and it will go stale fast.

 

Toilet paper tube pots | Homemade DIY Biodegradable seed starting pots

We’re looking at making plant pots for starting your seeds in by recycling the inner tubes from toilet paper rolls – making environmentally friendly, biodegradable home made seed starting pots. Homemade plant pots come in all shapes and size but these will help save you money and are perfect to start your seedlings in.

 

Our Video on Home Made Seed Raising Mix

Is this an effective soil test? Mason jar soil test

Do you know how much sand, silt and clay you have in your soil? We’re looking at a soil texture test, namely a mason jar soil test to perform a soil texture profile to work out our soil composition.

This can then be used to determine what kind of soil loam you have in your garden, so you can put this knowledge to work to find out how build soil or improve your soil. But the question, is this an effective soil test?

The United States Department of Agriculture Tool
http://tinyurl.com/soilcalc

Is this the best seed starting mix?

Today we’re going to find out what makes the best seed starting mix / the best seed starting soil for seedlings – we’ll be showing you what you need to do to start your own seeds indoors or outdoors with our home blended seed starting mix. Is this the best seed starting mix?

Growing your own organic food is great fun, watch our videos for more tips and techniques on how to grow your own organic food and how to plant a vegetable garden.

How to grow heirloom tomatoes from seed

In this episode we’ll be growing heirloom tomatoes from germination of seed and transplanting them out into garden containers, the seeds from this episode were sourced through the Koanga Institute’s seed preservation collection, growing your own organic food is great fun, watch our videos for more tips and techniques on how to grow your own organic food and how to plant a vegetable garden

Part 1

Part 2

How to make a rustic pallet garden planter box | Pallet Ideas

Today’s project: a rustic pallet wood planter box.

Pallet wood is easy to find and makes a great planter box.

Get some ideas for your pallet garden! I show you how to make a pallet wood planter box in a few simple steps and you can use this planter box for vegetables, flowers, whatever you fancy.

This DIY pallet wood planter is a simple project and much cheaper than buying a planter box at the store!