Jan

18

LinkUSB(i) and 1-Wire setup

13 years ago, mid-January | 2 Comments

I’ve just configured my monitoring machine to use a LinkUSBi 1-Wire interface and it’s a rather simple process. First of all we’ll setup One Wire File System, or OWFS LinkUSB(i)for short, then we’ll add some udev rules and finally plug in a device and get some readings. Since we need to build OWFS we’re going to need a new libraries and files installed, I’m making the assumption that you already have automake, autoconf, autotools-dev, gcc, g++ installed so you can go ahead and install the libraries we need.

apt-get install libtool libusb-dev fuse-utils libfuse-dev swig python2.6-dev tcl8.4-dev php5-dev

You don’t actually have to have Python, Tcl or php5 installed if you don’t want them they add to the interfaces you can use with OWFS – unless you specifically don’t want them you may as well include them. Once the installs above have completed you’ll need to get a copy of OWFS – be sure to download the latest version of it.

Update : I’ve rolled back to using 2.8p4 since 2.8p5 seems to have some problems with owserver (owfs still works fine).

Once you’ve downloaded you’ll see the file is called something like owfs-2.8p5.tar.gz – this file name is made up of owfs-[version of owfs].tar.gz In my case I have version 2.8p5. Your version may differ, don’t worry about that (unless it’s older!). Now extract the tarball with

tar -zxvf owfs-2.8p5.tar.gz

replacing the file name with whichever version you downloaded. This will extract a lot of files and place them in a directory with the same name as the file you downloaded, minus the ‘.tar.gz’. Move to that directory with

cd owfs-2.8p5

now we need to run the configure and make scripts. First configure, if this fails make sure you have all the dependencies required.

./configure

this will spit out reams of text which really only matters if something goes wrong. The last few lines should be something like this

Current configuration:

Deployment location: /opt/owfs

Compile-time options:
Caching is enabled
USB is enabled
I2C is enabled
HA7Net is enabled
W1 is enabled
Multithreading is enabled
Parallel port DS1410E is enabled
TAI8570 barometer is enabled
Thermocouple is enabled
Zeroconf/Bonjour is enabled
Debug-output is enabled
Profiling is DISABLED
Tracing memory allocation is DISABLED
1wire bus traffic reports is DISABLED

Module configuration:
owlib is enabled
owshell is enabled
owfs is enabled
owhttpd is enabled
owftpd is enabled
owserver is enabled
ownet is enabled
ownetlib is enabled
owtap is enabled
owmon is enabled
owcapi is enabled
swig is enabled
owperl is enabled
owphp is enabled
owpython is DISABLED
owtcl is enabled

Now we build OWFS using make

make

After some churning, spewing output, cpu usage and warning messages (ignore them), which may all take 10 minutes or more depending on your cpu and memory, you should get your prompt back. Finally install owfs – do this as root.

make install

Since we need to mount the OWFS somewhere we create a directory

mkdir /var/lib/1wire

Ok, so now we come to the hardware side of things – I got my LinkUSBi from HomeChip – the ‘i’ variant has it’s own identity which may or may not be useful to you. If I’m honest I accidentally picked the ‘i’ version and could have easily saved 80 pence and gone for the non-‘i’ version without trouble – Quick Note, as I write this Quinten has had some issues that need investigation, he has the non-‘i’ variant – for now I’d stick with the ‘i’ variant that we know works. I’ll update once I get more information about the issue. Turns out that version 2.8p4 of OWFS worked with the LinkUSB for Quinten. The LinkUSB or LinkUSBi is the interface to 1-Wire devices, so now’s the time to plug it in. Be aware that if you have other FTDI devices you might want to set up some udev rules. This is what I have in a file called /etc/udev/rules.d/60-usb-serial.rules


# /etc/udev/rules.d/60-usb-serial.rules
# Determine XBEE, Current Cost and 1wire USB ports

KERNEL=="ttyUSB*", \
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="A600eD0C", \
SYMLINK+="1wire"

KERNEL=="ttyUSB*", \
ATTRS{idVendor}=="067b", ATTRS{idProduct}=="2303", \
SYMLINK+="currentcost"

KERNEL=="ttyUSB*", \
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", \
SYMLINK+="xbee"

Since I have 3 USB serial devices, a currentcost unit, some Xbee based wireless 1-wire devices I made and the LinkUSBi, two of which are FTDI I need to identify each so use the ATTRS{serial} to uniquely identify the LinkUSBi via its serial number. You can glean the serial number by using

lsusb -vv

and look at the output for the serial number of device you’re interested it. Once our LinkUSBi is connected and detected we can mount OWFS with

/opt/owfs/bin/owfs -d /dev/1wire -m /var/lib/1wire

Note that I use -d/dev/1wire because my udev rules create a symlink. If you don’t create the symlink then your device will be something like /dev/ttyUSBx – where x = a number. Now we can look at any attached devices with

# ls /var/lib/1wire/
01.BA0E0E140000 28.1842A1020000 alarm bus.0 settings simultaneous statistics structure system uncached

The 01.XXXXXX device is the LinkUSBi and the 20.XXXXX device is a DS18S20 temperature sensor. To read the output of the temperature sensor we simply do

cat /var/lib/1wire/28.1842A1020000/temperature
16.0625

As you can see the temperature is a rather chilly 16.0625 degrees Celsius. Stuart Poulton has some 1-Wire kits available to buy for creating some domestic environment friendly temperature sensors and Quinten has some good pictures of them. Kevin has also got some newer pictures up – thanks for the headsup Kevin.



[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Tagged with:
January 18, 2011 20:47

Current Electricity Use (15min)


iPhone/Webkit RSS Reader

Links


Tags

1-Wire android api Apple arduino currentcost DDAR development DVD FIC freerunner G1 google Google Phone gphone gprs GPS hardware image image builds inspiration iphone jailbreak kiosk linux Mac monitoring Music neo 1973 Nokia openmoko opensource OSX Pachube personal qtopia rhubarb rikki Rio slimp3 slimserver software tracking Trolltech u-boot


Twitpic


Graphy Stuff






Nasty Spam Monkeys