1-wire

1-wire (or one-wire, but I prefer the name Maxim uses) is a simple bus to connect electronic devices. Other sites can explain it much better: But basically it is a way to create a simple network of devices that can communicate with one master device aimed at low-speed communications with measuring devices like thermometers and output devices like relays. The minimal 1-wire network has two wires: one for ground and one for data and power. Simple devices can be powered using parasitic power derived from the data line. The network of 1-wire devices is also known as 'Microlan'.

All 1-wire devices have unique addresses and an in my opinion very neat protocol is used to discover devices.

I got interested in 1-wire because at work we had a 4-channel thermometer based on 1-wire sensors which we now use to monitor rack temperatures. That sensor is using the Quozl's Temperature Sensor design which is very simple and does not use the full power of the 1-wire bus. It measures temperatures quite accurately and we have a nice display of our rack temperatures. Ofcourse all nicely graphed with rrdtool.
temperature sensors one week
I quite liked the whole idea of 1-wire and how it could make hooking up temperature and other sensors to the computer simple and cheap. Well, with all the supporting electronics, cases and shipping charges that is: not too expensive.

And I learned electronics before I got into applied computer science so I know which end of the soldering iron to hold. And it's nice to "play with" technology like this.

My projects

Onewire sensor in base of Gamma isdn connector housing Onewire sensor in base of Gamma isdn connector housing

Temperature logging

Measuring temperature is quite easy with 1-wire: just hook up a DS18S20 sensor. So I started with a 1-Wire serial adapter DS9097U and 4 DS18S20 sensors. I ordered the sensors as parts with no case or anything. The DS9097U plugs into a free serial port on home server gosper and I use old phone and network connection boxes to put the DS18S20 sensors in. When moving into our house I bought RJ45 ISDN+network connection boxes at the local DIY store Gamma but found out later both connectors are wired together. Not at all useful for using ISDN in one connector and LAN in the other. But for daisychaining the sensors on a 1-wire bus this works fine. For software I use digitemp which is available as debian package digitemp And it works! First to enumerate the 1-wire network:
$ digitemp_DS9097U -s /dev/ttyS1 -w
DigiTemp v3.3.2 Copyright 1996-2004 by Brian C. Lane
GNU Public License v2.0 - http://www.brianlane.com
Turning off all DS2409 Couplers
....
Devices on the Main LAN
10A8B16B0108005D : DS1820/DS18S20/DS1920 Temperature Sensor
1011756B010800F1 : DS1820/DS18S20/DS1920 Temperature Sensor
1073B06B010800AC : DS1820/DS18S20/DS1920 Temperature Sensor
09C9440F0500009C : DS2502/DS1982 1Kbit Add only memory
And for some readouts after creating .digitemprc:
$ digitemp_DS9097U -q -a
Aug 01 14:10:32 Sensor 0 C: 32.38
Aug 01 14:10:33 Sensor 1 C: 30.75
Aug 01 14:10:34 Sensor 2 C: 30.31
The results are visible: assorted sensors at home.
Onewire sensor in closed Gamma isdn connector housing
Onewire sensor in closed Gamma isdn connector housing

Digitemp and rrdtool

I rolled my own scripts for importing data from 1-wire into rrdtool databases. I gathered the sensor numbers in digitemp can change over time as you add and remove sensors or rescan the 1-wire network so I use the unique sensor addresses as key for looking up where to store the data.

fetchdigitemp.pl perl script to fetch temperatures and counters via digitemp and store them in rrd databases.

Finding new sensors

Finding that new sensor in the 1-wire network can be hard when the output of digitemp -w always shows the order in which sensors were found using the 1-wire discovery algorithm. But, the trick I used to find the new sensor is to first enumerate the network without the new sensors:
$ digitemp_DS9097U -w > digitemp.before
Then, add 1 sensor, and rerun and let unix diff(1) do the magic:
$ digitemp_DS9097U -w > digitemp.after
$ diff digitemp.before digitemp.after
> 10D30B8A01080009 : DS1820/DS18S20/DS1920 Temperature Sensor
That is the new sensor.

Lightning strikes detector

I bought this when I was ordering some sensors anyway. I installed it indoors in the attic where I wasn't too happy about the counting since it also reacted to the fluorescent lights being switched on. But when a real thunderstorm hit the Netherlands on 26 May 2009, it did show the results:

More temperatures

Onewire sensor in thermostat
Onewire temperature sensor mounted inside the room thermostat. The resulting measurement is more a wall temperature than an inside room temperature.

Onewire sensor on heating pipe
Onewire temperature sensor on the output heating pipe.
I'm considering measuring more temperatures. This is quite easy with the DS18S20 sensors.
Since I use simple rj45 connection boxes for the ends of the long cable run I decided to put DS18S20 sensors in them resulting in one temperature sensor at the top end named 'Server rack' and one at the end in the cupboard beneath the stairs named 'Wine rack'.
Water or heating pipe surface temperatures can also be measured easily according to Home Systems Monitoring Components at Kampmeier's blog with tie-wraps and a bit of isolation tape or heatshrunk isolation. When the heater showed issues in December 2009 I decided to implement this myself. Some soldering and tie-wraps and I had a nice temperature sensor on the output pipe of the central heating system.

I later bought newer temperature sensors inside of the 18B20 type, this sensor offers a higher resolution: 12bits over the 9bits of the 18S20.

Weather monitoring

The weather station with alternative power is used for outside weather monitoring, results visible on Weather station Utrecht Overvecht.

Electricity monitoring

img_6924 img_6929
The next project (currently in rest). I'm using the 1-wire electricity monitoring design by Jon00 also used by Bwired.nl for measuring power use via 1-wire. A minor modification is that I'll use the hobby-boards dual counter DC2.5-R1-A. I also did the modification of the Velleman MK120 receiver a bit different, I crossed the wires using two wires in the IC holder crossed to the bent out pins 9 and 10 of the IC.

Project status on 2008-08-31

Using the Velleman kit is no success but simply using a photodiode and a resistor directly connected to the counter input counts lightpulses (from a white flashlight).

Project status on 2009-05-01

The red pulses from the electricity meter fail to register on the photodiodes I tried.
The lenghts of wire to get to the electricity meter from the server mean it will be wise to use a 1-wire hub which will also allow me to add a few temperature sensors. That part is in use, the electricity monitoring is just not (yet) working.

Project status 2013-04-07

No update, but I found YouLess LS110 (Dutch) which has a photodiode on one side and a network connector on the other and does all the logging/parsing, including making the data available in Youless LS110 data in ASCII and JSON format. The downside is that it does everything and therefore has a price of 79 euros. Found via Youless - Log al het verbruik (Dutch)

Links


Comments about this page and updates are welcome. E-mail is the preferred contact method.
Koos van den Hout e-mail: koos@kzdoos.xs4all.nl
Other webprojects: Camp Wireless The Virtual Bookcase webcam.idefix.net Weather maps