... ...

Anagram Solver Solar Artwork

TuftedPuffin.co.uk

... ...

 

... ...
 

Live Data

Live

Today

Yesterday

Energy

PV

Electricity Usage

Write Up

Introduction

OneWire

Scripts

Mysql

Gnuplot

Energy

Theoretical

SVG

Behaviour

PV Monitor

Current Monitor

Bandwidth Monitor

One wire

My home PC runs Ubuntu, currently I'm on version 10.10. I alread had a small 1-wire system that I had experimented with a few years back, consisting of a handful of 1-wire sensors and an RS-232 to 1-wire adapter, a DS9097U. I therefore knew the potential of the 1-wire system.

1-wire is relatively cheap and very easy to use, so it seemed that the obvious thing to do was to bring my 1-wire network up to date. I bought a usb to 1-wire adapter, a DS9490R-A and a number of DS18B20 chips via e-bay.

The cable run from the PC to the elements of the hot water system is fairly long, I initialy tried using telephone extensions cable, this didn't work. I replaced the telephone extension cable with CAT 5E spec cable, this worked a lot better. As the cable had to be routed through various parts of the house, sensors were added so that I could monitor the temperature of the rooms that the cable passed through.

The topology of my 1-wire network is shown below.

The branch that serves the small bedroom and the hall uses the unused twisted pairs within an existing Cat 5 ethernet cable. If I ever go to gigabit ethernet then I will have to re-consider this.

OWFS

In my original 1-wire network I used "digitemp", very straight forward to install as it is included within the Ubuntu repositories. But since then I've discovered OWFS , the One Wire File System. This isn't quite so easy to install as it involves downloading the source code and re-compiling for your specific system. Having said that though all the scripts worked perfectly and installation was fairly easy, even though I did have to go through the process twice because I didn't have FUSE installed. In fact the two extra packages I had to install were :-

libfuse-dev

libusb-dev

Being Ubuntu based this was very easy using the synaptic package management sofware.

OWFS maps your one-wire network onto the Linux file system. So each device on the network appears as a directory within the file system, getting the temperature reading from a DS18B20 then becomes as easy as reading a file, called "temperature" in that devices directory.

I use 3 parts of the OWFS:-

owserver - allows more than one application to access the 1-wire network

owfs - the process that maps the 1-wire network to the file system

owhttpd - Allows the 1-wire network to be interrogated via an internet browser.

I start the owserver when the PC is re-booted (which is hardly ever), using the following script:-

#/bin/bash

killall owserver
killall owfs
killall owhttpd

sleep 5

owserver --alias=alias.txt -uall -d /dev/ttyS3
sleep 5
owfs --alias=alias.txt -s 127.0.0.1 -m /var/1wire
sleep 5
owhttpd --alias=alias.txt -s 127.0.0.1 -p5000

For the above script to work I find it easiest to run it as root, otherwise the linux module ds9094r gets in the way

As devices are added to or removed from the 1-wire network the owfs will automatically add or remove the appropriate directories. These changes can easily be seen via the web interface supplied by owhttpd.

I have a breadboard connected to the 1-wire network. I can test out 1-wire devices before I build them into the network, simply by plugging the legs into the breadboard. This has two advantages, firstly I can check that the 1-wire device is working, it's unique serial number will appear at the top level in the web interface. Secondly, once I've seen it's unique serial number I can add it into the owfs alias file. The owfs alias file provides a means of mapping the device serial number to something more meaningful, it provides a one-to-one mapping of device to user-defined name. So, for instance, instead of the directory name being something like 28A07CEE020000 it becomes CollectorFeed. The format of this file is one line per device, each line looks like this:-

The name has to be a valid Linux file name.

/26.E84581000000 Yellow1Study
/26.421281000000 Yellow2OutsideHumidity
/26.9E1D81000000 Yellow3Larder
/26.1B7C7D000000 Yellow4WorkshopLight
/28.A07CEE020000 CollectorReturn
/28.6C7FEE020000 CollectorFeed
/28.607AEE020000 SolarPipe1
/28.6766EE020000 SolarPipe2
/28.9048EE020000 Chip3
/28.A85EEE020000 Dead
/28.D868EE020000 Chip5
/28.1446EE020000 WorkshopRoofSpace
/28.741ECE020000 ColdWaterTank
/28.22D5EE020000 MainBedroom
/28.4020CE020000 Loft1
/28.B754EE020000 Lounge
/81.0C392F000000 BusMaster
/28.C829CE020000 SolarOut
/28.D828CE020000 SolarIn
/28.224FCE020000 MidTank
/28.1253CE020000 TwixtSolar
/28.B211CE020000 TopOfTank
/28.CA45CE020000 GasIn
/28.5117CE020000 TankBottom
/28.5D44CE020000 TwixtGas
/28.E319CE020000 GasOut
/28.531DCE020000 ColdWaterIn
/28.1B85e8020000 HotWaterOut
/28.E60CCE020000 HallCupboard
/28.F22CCE020000 SmallBedroom
/26.D841F5000000 OutsideSun

Building a 1-wire network

First of all, the type of cable used is important, I tried to use telephone extension cable because I had a reel of it that needed using up. I wasn't able to attach many sensors or get a long run of cable to work. I now use CAT5e cable, with this I have managed to build a reasonable size network with very little trouble.

For most of the sensors, I cut a short length of CAT5e cable and solder this to the DS18B20, I use heat shrink to cover the individual legs, and then use a larger diameter heatshrink to cover the whole device and part of the cable. For the sensors that are directly on the water cylinder I had the end of the device poking out of the end of the heatshrink so that it could butt up agains the wall of the cylinder. For sensors that were to be attached to pipes I soldered the device on the other way round, so that when the heatshrink was added, the device appears as a bulge in the heatshrink, this means I can use cable ties either side of the device to ensure that the sensor is tight against the pipe.

I am a little concerned about the temperature rating of the Cat5e cable, which claims to be rated to 70 Degrees C, which may be a little on the low side for clamping to the pipes. I am keeping an eye on it though and may have to replace the wire for the six sensors which are actually attached to the pipes.

The sensors on the cylinder are inserted into the insulation. I used an 8mm masonry drill and just twisted it into the insulation by hand to make a hole. The sensors are a push fit into the holes.

Scripts

This page is best viewed using Firefox Spread Firefox Affiliate Button

 

... ...