Accessing 1-wire devices on Raspberry Pi using OWFS
By Leo Gaggl
To connect 1-wire serial devices to the RPi I am using a DS9490R USB 1-wire adapter (rather than wiring I2C 1-Wire master components to GPIO I2C – which I might look at sometime down the track)
Install packages
sudo apt-get install owfs ow-shell
Edit config file
vim /etc/owfs.conf
! server: server = localhost:4304<br></br># USB device: DS9490<br></br>server: usb = all<br></br>######################### OWFS ##########################<br></br>mountpoint = /mnt/1wire<br></br>allow_other<br></br>####################### OWHTTPD #########################<br></br>http: port = 2121<br></br>####################### OWFTPD ##########################<br></br>ftp: port = 2120<br></br>####################### OWSERVER ########################<br></br>server: port = localhost:4304
Create Startup Script
I created a startup script for owfs modelled on the owserver script (not sure why this one is actually missing)
vim /etc/init.d/owfs
#!/bin/sh<br></br>### BEGIN INIT INFO<br></br># Provides: owfs<br></br># Required-Start: $remote_fs $syslog $network $named<br></br># Required-Stop: $remote_fs $syslog $network $named<br></br># Should-Start: owfs<br></br># Should-Stop: owfs<br></br># Default-Start: 2 3 4 5<br></br># Default-Stop: 0 1 6<br></br># Short-Description: 1-wire file system mount & update daemon<br></br># Description: Start and stop 1-wire file system mount & update daemon.<br></br>### END INIT INFO<br></br>CONFFILE=/etc/owfs.conf<br></br>DESC="1-Wire file system mount"<br></br>NAME="owfs"<br></br>DAEMON=/usr/bin/$NAME<br></br>case "$1" in<br></br> start)<br></br> echo "Starting $NAME"<br></br> $DAEMON -c $CONFFILE<br></br> ;;<br></br> stop)<br></br> echo "Stopping $NAME"<br></br> killall $NAME<br></br> ;;<br></br> *)<br></br> echo "Usage: $N {start|stop}" >&2<br></br> exit 1<br></br> ;;<br></br>esac<br></br>exit 0
Starting daemons
/etc/init.d/owserver start<br></br>/etc/init.d/owfs start
Checking output
#ls /mnt/1wire/
Should show output similar to:
10.575349000000 12.95DD17000000 alarm simultaneous uncached
10.575349000000 12.95DD17000000 bus.0 statistics
12.57DD16000000 81.B2EA2E000000 bus.1 structure
12.57DD16000000 81.B2EA2E000000 settings system
cat /mnt/1wire/10.575349000000/temperature
Will then show the temperature of the particular DS18S20 temperature sensor.