How to get DS9490R adapter and DS18B20 sensors working

This how-to has multiple pages. This page is about how to configure DS9490R adapter so that it will be possible to read temperature data. If you have not connected DS9490R adapter and sensors yet, please read previous page first.

If you have adapter and sensors connected its time to:

  1. Create some non-root user account for 1wire- related stuff.
  2. Create mountpoint for OWFS (One Wire File System).
  3. Install OWFS packages.
  4. Configure OWFS, FUSE and UDEV
  5. Start and check is OWFS working.
  6. Configure services.

 

1. User account

Running everything as root user is easy but not the best practise. So lets make our lives more difficult and create system account named wire. This user must be set as owner of DS9490R adapter device with UDEV rules. Command creates also home directory for user wire, it should be something like /home/wire what I will use and refer to later as wire user home directory.

sudo useradd -r -m wire

 

2. Create mountpoint

Lets create mountpoint for OWFS. Following commands create mountpoint /wire if it does not already exist and change its owner.

sudo [ -d /wire ] || mkdir /wire
sudo chown wire:wire /wire

3. Install packages

You need to install few packages to get OWFS working. Its enough when you install owfs, rest of the packages should be installed automatically because of dependencies.

sudo apt-get install owfs

4. Configure OWFS, FUSE and UDEV

Switch off OFWS services what are not required at least in this project. Aparently if you don’t do it, some of these services grab DS9490R adapter for themselves and its not working properly later. I forgot to do that and spent half a day wondering why the f its not working although it was just perfect during previous install.

        update-rc.d -f owftpd disable
        update-rc.d -f owhttpd disable
        update-rc.d -f owserver disable
        service owftpd stop
        service owhttpd stop
        service owserver stop

Edit /etc/owfs.conf file. Comment in and modify mountpoint parameter – set value to /wire. Also comment in allow_other line.

 mountpoint = /wire
 allow_other

If you did not have FUSE installed yet, it should have been installed along with owfs packages. Edit fuse config file /etc/fuse.conf and comment in user_allow_other line.

user_allow_other

Load fuse module

sudo modprobe fuse

Add user wire to fuse group so that wire user could use it (fuse).

sudo usermod -a -G fuse wire

Add UDEV rule. I added it to file /etc/udev/rules.d/99-wire.rules . Generally this rule is needed to automatically change owner of DS9490R adapter when device is plugged in. If you don’t change owner, you can still use it as root user which means mounting owfs as root user. Symlink creation in rule below is optional.

ATTRS{idVendor}=="04fa", ATTRS{idProduct}=="2490", OWNER="wire", GROUP="wire", MODE="0660", SYMLINK+="ds1490f"

 

5. Start and check is OWFS working.

Start OWFS as user wire:

sudo -u wire /usr/bin/owfs --allow_other --timeout_volatile=30 --timeout_presence=300 -u -m /wire

Check by listing owfs mountpoint contents. Switch to user wire first or run commands using sudo as shown below. In that way you can be sure that wire user can actually read contents.

sudo -u wire ls -la /wire

Output should be something like below – note temperature sensor directories starting with 28.


pi@raspberrypi ~ $ sudo -u wire ls -la /wire
kokku 4
drwxr-xr-x  1 root root    8 juuli 13 23:51 .
drwxr-xr-x 23 root root 4096 juuli 10 22:31 ..
drwxrwxrwx  1 root root    8 juuli 13 23:51 05.4AEC29CDBAAB
drwxrwxrwx  1 root root    8 juuli 13 23:51 10.67C6697351FF
drwxrwxrwx  1 root root    8 juuli 13 23:51 28.1D174B050000
drwxrwxrwx  1 root root    8 juuli 13 23:51 28.A1CFBA030000
drwxrwxrwx  1 root root    8 juuli 13 23:51 81.8DED33000000
drwxr-xr-x  1 root root    8 juuli 13 23:51 alarm
drwxr-xr-x  1 root root    8 juuli 13 23:51 bus.0
drwxr-xr-x  1 root root    8 juuli 13 23:51 bus.1
drwxr-xr-x  1 root root    8 juuli 13 23:51 settings
drwxrwxrwx  1 root root    8 juuli 13 23:51 simultaneous
drwxr-xr-x  1 root root    8 juuli 13 23:51 statistics
drwxr-xr-x  1 root root   32 juuli 13 23:51 structure
drwxr-xr-x  1 root root    8 juuli 13 23:51 system
drwxr-xr-x  1 root root    8 juuli 13 23:51 uncached

If you don’t see any temperature sensor directories starting with “28.” although sensors are connected, kill owfs process and try to start it again as root user (omit -u wire in command above). If you see 28.* temperature sensors after that, there is something wrong with device ownership. If you still don’t see any 28.* device it is probably something wrong with wiring.

If you see contents like above, especially “catalogs” beginning with “28.” you can list sensor ID-s and temperatures with following command:

for f in `ls /wire/|grep 28.`; do echo -n "Sensor ${f} temperature is "; cat /wire/${f}/temperature; echo ; done

 

Scripts in this page were tested on:

  • Raspberry Pi Model B 512MB RAM. OS: Raspbian Wheezy, released in 2014-01-07. All updates installed on 1. september 2014.

If you found this useful, say thanks, click on some banners or donate, I can always use some beer money.

NEXT – How to get DS9490R adapter and DS18B20 sensors working (automated)

One thought on “How to get DS9490R adapter and DS18B20 sensors working

  1. Joachim Swigon

    runs under jessie
    Linux raspberrypi 4.4.13-v7+ #894 SMP Mon Jun 13 13:13:27 BST 2016 armv7l GNU/Linux

Comments are closed.