Here is the sequence of operations to be completed in order to install OWFS, to connect to a DS9490R USB 1-wire adapter, to read the temperature measured by a DS18B20 and to display it on the terminal using a small Python script.
Make sure you have the latest RPI firmware (earlier firmware apparently caused my DS9490R USB adapter to disconnect in a random fashion). For an easy way to update the firmware of your Raspberry, install rpi-update (https://github.com/Hexxeh/rpi-update). Then, on the terminal promt, type :
Code: Select all
pi@raspberrypi ~ $ sudo rpi-update
In order to prevent the the system to automatically launch modules that may interfere with OWFS, create a file in the "etc/modprobe.d" directory using the nano editor:
Code: Select all
pi@raspberrypi ~ $ sudo nano etc/modprobe.d/ds2490
Code: Select all
blacklist ds2490
blacklist ds9490r
blacklist wire
Code: Select all
sudo apt-get install owfs
Code: Select all
pi@raspberrypi ~ $ aptitude show owfs
Code: Select all
pi@raspberrypi ~ $ ls -l /usr/local/bin
owtap owdir owget easy_install rs232 owwrite owread
owexternal . owpresent .. owhttpd owserver
sjinn owfs easy_install-2.7 owftpd owexist owmon
Code: Select all
pi@raspberrypi ~ $ sudo nano /etc/owfs.conf
Code: Select all
# Sample configuration file for the OWFS suite for Debian GNU/Linux.
# This is the main OWFS configuration file. You should read the
# owfs.conf(5) manual page in order to understand the options listed
# here.
######################## SOURCES ########################
# With this setup, any client (but owserver) uses owserver on the
# local machine...
! server: server = localhost:4304
# ...and owserver uses the real hardware, by default fake devices
# This part must be changed on real installation
#server: FAKE = DS18S20,DS2405
# USB device: DS9490
server: usb = all
# Serial port: DS9097
#server: device = /dev/ttyS1
# owserver tcp address
#server: server = 192.168.10.1:3131
# random simulated device
#server: FAKE = DS18S20,DS2405
######################### OWFS ##########################
mountpoint = /mnt/1wire
allow_other
####################### OWHTTPD #########################
http: port = 2121
####################### OWFTPD ##########################
ftp: port = 2120
####################### OWSERVER ########################
server: port = localhost:4304
Code: Select all
pi@raspberrypi ~ $ sudo nano /etc/fuse.conf
Code: Select all
# Set the maximum number of FUSE mounts allowed to non-root users.
# The default is 1000.
#
#mount_max = 1000
# Allow non-root users to specify the 'allow_other' or 'allow_root'
# mount options.
#
user_allow_other
Code: Select all
pi@raspberrypi ~ $ sudo lsusb
Code: Select all
pi@raspberrypi ~ $ sudo mkdir /mnt/1wire
Code: Select all
pi@raspberrypi ~ $ sudo owfs -C -uall -m /mnt/1wire --allow_other
DEFAULT: ow_usb_msg.c:(295) Opened USB DS9490 bus master at 1:7.
DEFAULT: ow_usb_cycle.c:(191) Set DS9490 1:7 unique id to 81 22 65 2D 00 00 00 5C
Now let us explore the tree which has been created by OWFS:
Code: Select all
pi@raspberrypi ~ $ ls /mnt/1wire
28.2B7814020000 alarm settings statistics system
81.22652D000000 bus.0 simultaneous structure uncached
pi@raspberrypi ~ $ ls /mnt/1wire/28.2B7814020000
address errata id r_address temperature temperature12 templow
alias family locator r_id temperature10 temperature9 type
crc8 fasttemp power r_locator temperature11 temphigh
Code: Select all
pi@raspberrypi ~ $ cat /mnt/1wire/28.2B7814020000/temperature
21.4375
Code: Select all
#!/usr/bin/env python
# owtemp.py. This script prints the measured temperature in °C and updates every minute.
import time
import os
file_name=os.path.join("/","mnt","1wire","28.2B7814020000","temperature")
while 1:
file_object=open(file_name,'r')
line=file_object.read()
print(line+'C')
time.sleep(60)
file_object.close()
. To stop the script, type:python owtemp.py
If you experience some problem after starting OWFS and you want to restart it, an error message will be issued :ctrl c
Code: Select all
pi@raspberrypi ~ $ sudo owfs -C -uall -m /mnt/1wire --allow_other
........................
.........................
pi@raspberrypi ~ $ sudo owfs -C -uall -m /mnt/1wire --allow_other
DEFAULT: ow_usb_msg.c:(295) Opened USB DS9490 bus master at 1:7.
DEFAULT: ow_usb_cycle.c:(213) Set DS9490 1:7 unique id to 28 2B 78 14 02 00 00 7A
fuse: mountpoint is not empty
fuse: if you are sure this is safe, use the 'nonempty' mount option
Code: Select all
pi@raspberrypi ~ $ sudo umount /mnt/1wire