Thursday, 23 February 2012

Resuming work on the gas meter monitor

It's been over a year since any progress has been made with the gas meter monitor, partly because my elder son became interested in microcontrollers and borrowed my mbed for a while.  We built a home-made LED matrix to connect to it, and he used it to tackle some challenges that I set:

Anyway, he's moved onto other things now so I've got the mbed back, and have progressed with the gas meter monitor.

Firstly, I've splashed out on a workshop development board to make it a bit neater and more robust.  Here you can see the board with the mbed attached, fixed to the back wall of the under-stair cupboard where the meter is:

Secondly, I've made some further progress with the firmware.  The mbed is now detecting when the meter wheel starts and stops turning, and when the zero passes by.  At the moment, these events are being multicast onto the home network, but the plan is eventually to save them onto a memory card (there's a micro-SD card slot under the mbed on the development board), and get the NAS backup drive to collect updates each day when it switches on for the daily backups.

Here's a sample of the multicast events it's sending out now:

nas:~# emcast | grep '^[01Z] '
1 1330030611 1 0
Z 1330030624 1 1
Z 1330030636 1 2
Z 1330030648 1 3
Z 1330030660 1 4
Z 1330030672 1 5
0 1330030676 2 5 5
1 1330030927 1 5
Z 1330030938 1 6
Z 1330030949 1 7
Z 1330030961 1 8
Z 1330030973 1 9
Z 1330030985 1 10
0 1330030987 2 10 5

The first character of each line indicates the type of event: '1' indicates that the meter wheel has started moving, 'Z' indicates that the zero passed by, and '0' indicates that the meter wheel stopped turning.  The second field of each line is the time of the event, measured in seconds since the epoch.  The third field is a count of the number of following fields, which varies according to message type.  The fourth field is the total count of zeros passed since the last reset.  And finally, in the case of '0' events, the fifth field is the count of zeros since the meter wheel last started turning.

When the heating is on, and the house and the hot water tank are up to temperature, the boiler cycles on and off with a fairly regular pattern.  It will switch on and use gas at a fairly constant rate for five or six zeros, and then switch off again.  It repeats after several minutes.  I expect that this gap is going to vary inversely with the temperature outside, but don't have enough data to say more precisely yet.  (That reminds me - I need to add temperature sensors so I can record inside and outside temperate with the meter logs...)

Our central heating does not have a thermostat - it only has thermostatic radiator valves.  It will be interesting to see how its behaviour does vary with outside temperature.  Does it cycle on the heating at a regular rate (e.g. once every five minutes) and stay on for longer when it's colder outside, or does it wait less time before switching back on when it's colder outside?  I believe that it can only judge by the temperature of the water being circulated, which will drop quicker when the radiators are losing heat quicker.  We shall see...

Friday, 17 February 2012

Ikea wardrobe light hacking

Passing through the Ikea Marketplace the other day I was tempted into buying a pack of two battery-powered, motion-activated LED lights, intended for installation inside a wardrobe. £4.99 for the pair. I thought they'd make a good night-light for nocturnal trips to the loo.

What I hadn't realised is that they activate regardless of whether it is light or dark, so if I put one of these in the bathroom it'll be coming on during the daytime as well, which will run the batteries down a lot quicker.

I opened one up to see what was inside. I found a datasheet for the BISS0001 chip that powers it, and this revealed that it has a "Trigger disable input" pin, which was tied high with a 1M resistor.

One light-dependent resistor salvaged from an old night-light, a bit of dremelling and soldering, and the light now only activates when it's dark. The LDR pokes through a small new hole on the front:

and is connected between pin 9 of the IC and ground:

Now the only problem is that it's much too bright.