Installing Dallas 1-Wire
I needed to install the Dallas Semiconductor (now Maxim) 1-Wire system (OWFS - One Wire File System) for a project to monitor my central heating boiler's water input, water output, flue gas and ambient air temperature. The software is packaged as owfs. The online instructions seemed a bit vague to me, but the following steps appear to work. As a test, I used the DS9490R USB adapter and a DS1820 thermometer chip.
The project was to replace a PC-based system that used a Velleman K8055 I/O card and a set of DS18S20s - all that is described here.
Use apt-get update to download any package updates and to then write the changes to the local package cache. How long it takes depends upon how recently you ran the command previously and also how many new packages there are.
sudo apt-get update
Use apt-get install to install the owfs package and all of its dependencies.
sudo apt-get install autoconf libtool libusb-dev libfuse-dev
Now enter the following commands to load, configure, compile and install the software. This may take some time - see the approximate timings below:
sudo wget http://sourceforge.net/projects/owfs/files/owfs/2.8p15/owfs-2.8p15.tar.gz/download
sudo tar zxvf owfs-2.8p15.tar.gz
sudo ./configure # takes about <3m
sudo make # takes about <28m
sudo make install # takes about <1m
You now need to create a directory under /mnt so that the 1-Wire devices' directories can be created and mounted there:
sudo mkdir /mnt/1wire
Plug in your DS9490R USB adapter and run the following program:
sudo /opt/owfs/bin/owfs --allow_other -u -m /mnt/1wire
The owfs program should display two messages similar to those below, though the bus master address may be different and the unique serial number of the adapter will be different:
DEFAULT: ow_usb_msg.c:(295) Opened USB DS9490 bus master at 1:5.
DEFAULT: ow_usb_cycle.c(191) Set DS9490 1:5 unique id to 81 57 C7 30 00 00 00 3A
Each 1-Wire device has its own directory created in the directory you specified above, in this case, /mnt/1wire. Use ls -l to view the sub-directory names. They will look similar to:
drwxrwxrwx 1 root root 8 Apr 28 19:13 10.207F3D00000 drwxrwxrwx 1 root root 8 Apr 28 19:13 81.57C73000000 . etc.
The directory names use the format ff.ssssssssssss where ff is the device family identifier and ssssssssssss is the device's unique serial number. The two hexadecimal check digits are not part of the directory name In each directory there are various files that contain information about the device. Depending upon the device type, not all files may be present. These files are:
- address - contains the full device address as 16 hexadecimal characters
- alias - not populated for DS1820
- crc8 - the two hexadecimal check digits
- family - the two hexadecimal family identifier
- id - the unique twelve hexadecimal character serial number
- locator - FFFFFFFFFFFFFFFF
- r_address - as address but with the byte order reversed (e.g. if address=10207F3D0000009A, r_address=9A0000003D7F2010
- r_id - as id but with the byte order reversed
- r_locator - as locator but with the byte order reversed
- type - the device type, e.g. DS18S20
As an example, if you have a DS18S20 device, the full pathname to its temperature and type files will be respectively:
If you're writing a program in C you'll need to open, in read-only mode, the value files that you need in each device's directory. You can either write your program to discover what directories exist and then load the required files, or use a configuration file to specify exactly what devices you expect to find.