Wednesday, September 30, 2009

Installing 1-wire USB adapter DS9490R on Ubuntu 9.04

OK, let's install DS9490R 1-wire USB adapter on Ubuntu 9.04. Connecting adapter to my laptop, shows dmesg this:

$ dmesg
[1553881.079000] Driver for 1-wire Dallas network protocol.
[1553881.121233] usbcore: registered new interface driver DS9490R
[1553882.700959] w1_master_driver w1_bus_master1: Family 81 for 81.0000002d0f1d.39 is not registered.


I choosed a owfs to read sensors. To install it, I use Tomasz Korwel's guide.

1. Let's install packages needed for compiling owfs.

# apt-get install automake autoconf autotools-dev gcc g++ libtool libusb-dev fuse-utils libfuse-dev swig python2.4-dev tcl8.4-dev php5-dev


2. Download, extract and compile owfs

Download owfs from owfs Source Force download page. Extract it. Open terminal and cd into directory where owfs-2.7p26.tar.gz (or whatever version you download) was extracted.


$ cd Desktop/
$ cd owfs-2.7p26/
$ ./configure


If you get after ./configure 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

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
owside is enabled
owmon is enabled
owcapi is enabled
swig is enabled
owperl is enabled
owphp is DISABLED
owpython is enabled
owtcl is enabled

...where USB is enabled, then it's all OK.

Now, let's compile and install it.

$ make
$ sudo make install


If everything went well, then software should be installed. Let's try out.

$ sudo mkdir /media/1-wire
$ sudo /opt/owfs/bin/owfs --allow_other -u /media/1-wire
DEFAULT: ow_ds9490.c:DS9490_sub_open(552) Opened USB DS9490 adapter at 002/009.
DEFAULT: ow_ds9490.c:DS9490_detect_found(412) Set DS9490 002/009 unique id to 81 1D 0F 2D 00 00 00 39

-u key means USB and "/media/1-wire" is mountpoint and --allow_other means that non-root users can read 1-wire directory.
So, if you can see something like this in 1-wire folder...

$ ls -lah 1-wire
drwxr-xr-x 1 root root 8 2009-09-30 20:38 .
drwxr-xr-x 7 root root 4096 2009-09-30 20:30 ..
drwxrwxrwx 1 root root 8 2009-09-30 20:39 81.1D0F2D000000
drwxr-xr-x 1 root root 8 2009-09-30 20:38 bus.0
drwxr-xr-x 1 root root 8 2009-09-30 20:38 settings
drwxr-xr-x 1 root root 8 2009-09-30 20:38 statistics
drwxr-xr-x 1 root root 30 2009-09-30 20:38 structure
drwxr-xr-x 1 root root 8 2009-09-30 20:38 system
drwxr-xr-x 1 root root 8 2009-09-30 20:38 uncached

... then software is installed and you can proceed to hardware.

Now, let's try to connect hardware. A temperature sensor DS18S20. I wired it to use a parasite power. That means that I only use 2 wires, ground and data, and power comes also from data wire. Anyway, connect RJ11 to adapter and wait a little bit and look at 1-wire folder again.

$ ls -lah 1-wire
drwxr-xr-x 1 root root 8 2009-09-30 21:12 .
drwxr-xr-x 7 root root 4096 2009-09-30 20:30 ..
drwxrwxrwx 1 root root 8 2009-09-30 21:22 10.0FC3ED010800
drwxrwxrwx 1 root root 8 2009-09-30 21:22 81.1D0F2D000000
drwxr-xr-x 1 root root 8 2009-09-30 21:12 alarm
drwxr-xr-x 1 root root 8 2009-09-30 21:12 bus.0
drwxr-xr-x 1 root root 8 2009-09-30 21:12 settings
drwxrwxrwx 1 root root 8 2009-09-30 21:22 simultaneous
drwxr-xr-x 1 root root 8 2009-09-30 21:12 statistics
drwxr-xr-x 1 root root 30 2009-09-30 21:12 structure
drwxr-xr-x 1 root root 8 2009-09-30 21:12 system
drwxr-xr-x 1 root root 8 2009-09-30 21:12 uncached

As you can see, there is now new folder - 10.0FC3ED010800. This is my DS18S20 sensor. In this folder, there is temperature file. In that file, there is a temperature in celsius.

$ cat 1-wire/10.0FC3ED010800/temperature
20.0625

And putting sensor in front of my laptop fan, I get reading...

$ cat 1-wire/10.0FC3ED010800/temperature
45.5

I noticed that this file is always 12 bytes long, numbers is aligned to rights and it does not have new-line character at the end.

So, next thing is to create a script that will log a temperature reading and I will try to do a nice graph of it.

13 comments:

  1. Hi, I really like your blog! I was so happy to find it. I've been wanting to install owfs for quite a while now. You have inspired me to do it.

    I'm installing on Ubuntu 9.10. I get the following error. I was wondering if you could help me fix this error? Thanks

    $ sudo /opt/owfs/bin/owfs --allow_other -u 1-wire
    DEFAULT: ow_ds9490.c:DS9490_sub_open(555) Opened USB DS9490 adapter at 004/002.
    DEFAULT: ow_ds9490.c:DS9490_detect_found(415) Set DS9490 004/002 unique id to 81 2C 4D 12 00 00 00 25
    fuse: bad mount point `1-wire': No such file or director

    ReplyDelete
  2. I figured out what was wrong. I did not have the correct path name specified. You should update your tutorial from this:

    $sudo /opt/owfs/bin/owfs --allow_other -u 1-wire

    to this:

    #sudo /opt/owfs/bin/owfs --allow_other -u /media/1-wire

    ReplyDelete
  3. pets,
    Have you figured out a way to automount the owfs upon startup of Ubuntu? What I mean is, when I start my computer I want the following line to automatically execute. Is there a way to do this?

    sudo /opt/owfs/bin/owfs --allow_other -u /media/1-wire

    Thanks.

    ReplyDelete
  4. I have file /etc/init.d/onewire. It contains:
    #!/bin/sh
    mkdir /media/1wire
    /opt/owfs/bin/owfs --allow_other -u /media/1wire

    make it executable: chmod a+x onewire

    and to make it start on startup, then do:
    update-rc.d onewire defaults

    ReplyDelete
  5. Thanks for this post. Really, I mean it. I was able to install a DS9490R/DS18S20 on Windows and query the temperature through java but Ubuntu was another story :-)
    Anyway, made it work first time thanks to the details you are providing.
    I am planning to leave this system for a whole winter in an empty house and control the heater using 1-wire + X10 + eeebox.
    I wanted to have this working on Linux, more reliable.
    Thanks again.

    ReplyDelete
  6. Thanks for this useful post.
    But does anyone know how to access the 1-wire driver from Java? When I try to open the USB port it seems like the port is occupied by the kernel driver.

    ReplyDelete
  7. Great guide.
    Saved me a lot of time

    ReplyDelete
  8. Thanks to this post, i have finaly work the ds18s20 and 9490R under ubuntu 9.10 - -Thanks!!!!

    ReplyDelete
  9. Hello,

    could you explain how to wire the 2 wires to RJ11, please?
    Thanks

    ReplyDelete
  10. Hi Gunther,

    following the Dallas Standard for RJ11/12, you have:

    Pin Color Description
    -----------------------------------------
    1 White / Regulated 5VDC < 50mA
    Orange
    2 Black Power Return / Ground
    3 Red One Wire Data / OWIO / DQ
    4 Green One Wire Return / OWRTN / Ground
    5 Yellow Not Connected
    6 Blue Unregulated supply < 500 mA

    Maybe you'd like to go for RJ45? Then, I'd suspect to follow the proposed 1W-RJ45 Standard from Springbok.

    Have fun,
    Lutz

    ReplyDelete
  11. Great post, works first-time-right on Debian Lenny

    ReplyDelete
  12. Is FUSE really needed? I forgot to install it on my Ubuntu 11.10, but OWFS, DS9490R and DS18S20 work anyway. Maybe FUSE was installed out of the box - how do I check if it is already installed?

    ReplyDelete