Showing posts with label 1-wire. temperature. Show all posts
Showing posts with label 1-wire. temperature. Show all posts

Thursday, June 6, 2013

Arch Linux Iomega IConnect I2C Sensors

I recently wrote about installing Arch Linux on the Iomega IConnect.

This shows how to get the I2C interface working and have a look at the built in LM63 temperature sensors.

Install lm_sensors.

pacman -S lm_sensors

Have a look and see what the package gives us, binary wise.

pacman -Ql lm_sensors

/usr/bin/fancontrol
/usr/bin/healthd
/usr/bin/pwmconfig
/usr/bin/sensord
/usr/bin/sensors
/usr/bin/sensors-conf-convert
/usr/bin/sensors-detect


We need to load a few kernel modules. i2c-mv64xxx is the driver for the I2C bus and lm63 for the sensors.

[root@biggles ~]# modprobe i2c-mv64xxx
[root@biggles ~]# modprobe lm63
[root@biggles ~]# lsmod
Module                  Size  Used by
lm63                    5257  0
hwmon                   1187  1 lm63
i2c_mv64xxx             4121  0
i2c_core               15344  2 i2c_mv64xxx,lm63
rt2800pci               7802  0
rt2800lib              39393  1 rt2800pci
rt2x00pci               3661  1 rt2800pci
rt2x00lib              30207  3 rt2x00pci,rt2800lib,rt2800pci
eeprom_93cx6            1150  1 rt2800pci
mac80211              170543  3 rt2x00lib,rt2x00pci,rt2800lib
cfg80211              143659  2 mac80211,rt2x00lib
rfkill                 14400  2 cfg80211
ds2490                  6254  0
wire                   15857  1 ds2490
ipv6                  259694  10
mv_cesa                 9128  0
autofs4                22074  2
[root@biggles ~]#
[root@biggles ~]# sensors-detect
# sensors-detect revision 6170 (2013-05-20 21:25:22 +0200)
# DMI data unavailable, please consider installing dmidecode 2.7
# or later for better results.

This program will help you determine which kernel modules you need

------------------------ snip -------------------------------------------

Some boring text and all negative, so skipping it

------------------------ snip -------------------------------------------

Module i2c-dev loaded successfully.

Next adapter: mv64xxx_i2c adapter (i2c-0)
Do you want to scan it? (YES/no/selectively):
Client found at address 0x4c
Handled by driver `lm63' (already loaded), chip type `lm63'

Now follows a summary of the probes I have just done.
Just press ENTER to continue:

Driver `lm63':
  * Bus `mv64xxx_i2c adapter'
    Busdriver `i2c_mv64xxx', I2C address 0x4c
    Chip `lm63' (confidence: 6)

Do you want to generate /etc/conf.d/lm_sensors? (YES/no):
ln -s '/usr/lib/systemd/system/lm_sensors.service' '/etc/systemd/system/multi-user.target.wants/lm_sensors.service'
Unloading i2c-dev... OK

[root@biggles ~]# sensors
lm63-i2c-0-4c
Adapter: mv64xxx_i2c adapter
temp1:        +38.0°C  (high = +70.0°C)
temp2:        +38.2°C  (low  =  +0.0°C, high = +70.0°C)
                       (crit = +85.0°C, hyst = +75.0°C)
                      
All Done

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.