Tuesday, November 9, 2010

The Most Measured Fridge in the World

What would you measure about your fridge?

I wanted to measure Temperature and Energy Usage.

A few months ago, I used two 1-Wire DS18S20 Temperature sensors and OWFS to measure the temperature in the main fridge and the freezer compartment. It is a fairly standard and straightforward set-up which I am not going to cover here. I stick the readings in a MySQL database and produce graphs using gnuplot. Interesting in a very geeky way.

You can see the way behaviour such as leaving the door open for a minute or more can drastically effect the temperature. It can take over an hour go get to a stable temperature.



This is an average day. Not much activity. Quick opens and closes. There is a temperature spike in the freezer about 10 am. This happens about every 30 hours or so and I think this represents the automatic defrost function. This removes the requirement to have to defrost the fridge from time to time. Cool in my book.


The main reason for this article is to outline the process involved in installing a new Currentcost IAM (Individual Appliance Module) and how to extract the readings and process them.


I have using Currentcost sensors and display/receiver for a number of years to measure electricity consumption in my house.

I have a CC128 Display/Receiver Unit connected to a Linux computer which reads the XML output, parses it and stores it in a RRD database and a MySQL database.

I then use a few scripts to gather the data and product graphs which I display on a web page. Excellent stuff.

The set-up is based on the excellent write up on http://www.jibble.org/currentcost/.



So, after waiting for yonkity bonks for the Currentcost IAM to be released, I saw that they were available recently. They measure the energy usage of an particular appliance and send it to your receiver, in my case the CC128.



They are available on Amazon.co.uk for about £30. I am based in Dublin, so the postage was about £20. Feck I thought. My brother, who is also a Currentcost fan, bought 2 and posted it to me. Postage about £10, still to high. They need to do something about that.

Anyway, the time came to install one of the IAMs and set-up the logging and graphing processes. I had a look around but could not find much useful information about how to handle the extra sensors.

I found some information on the Currentcost site here http://www.currentcost.com/cc128/xml.htm. Not really much help though.

What I did at the end of the day, was just configure the new sensor and plugged in the fridge.

I watched the output from the CC128 and noticed, that there were two lines output. One was for the main energy sensor and the other one was from the new sensor.

Here is an example:

<msg><src>CC128-v0.11</src><dsb>00621</dsb><time>13:46:40</time><tmpr>21.9</tmpr><sensor>0</sensor><id>01223</id><type>1</type><ch1><watts>00601</watts></ch1></msg>

<msg><src>CC128-v0.11</src><dsb>00621</dsb><time>13:46:42</time><tmpr>21.9</tmpr><sensor>1</sensor><id>01181</id><type>1</type><ch1><watts>00001</watts></ch1></msg>

As you can see the lines are fairly similar. The first point of note is the sensor number 0 and 1. This was enough to discriminate between the sensors.

I then modified the data collection script as follows:
Original line
m!<ch1><watts>0*(\d+)</watts></ch1>.*<tmpr> *([\-\d.]+)</tmpr>!

had to be changed to
m!<tmpr>\s*(-*[\d.]+)</tmpr><sensor>0</sensor>.*<ch1><watts>0*(\d+)</watts></ch1>!

as in e.g.

#Sensor 0
if ($line =~ m!<tmpr>\s*(-*[\d.]+)</tmpr><sensor>0</sensor>.*<ch1><watts>0*(\d+)</watts></ch1>!)
{
my $watts = $2;
my $temp = $1;
system("rrdtool update /var/www/html/currentcost/data/powertemp.rrd N:$watts:$temp");
system("./mysql_bit.sh $watts $temp");
}

#Sensor 1
if ($line =~ m!<tmpr>\s*(-*[\d.]+)</tmpr><sensor>1</sensor>.*<ch1><watts>0*(\d+)</watts></ch1>!)
{
my $watts1 = $2;
my $temp1 = $1;
system("rrdtool update /var/www/html/currentcost/data/powertemp_mod1.rrd N:$watts1:$temp1");
system("./mysql_module_bit.sh 1 $watts1 $temp1");
}

That was it basically. Everything worked.



Here is an average 4 Hour Graph and Usage of the fridge at the weekend. Some activity, not much.

Bloody hungry machines. It makes up a significant part of our electricity bill. Not much you could do except increase the general minimum temperature. Some research required, I think.

I think I will produce a daily Fridge Electricity Bill. I have done this for the house, based on Dale Lanes idea

If you need more information, leave a comment.