Maxim DS9490R 1-Wire + Ubuntu 18.04 Server + python-ow

After having some challenges finding a simple way to use a Maxim (previous Dallas) DS9490R USB to 1-Wire/iButton adapter on Ubuntu 18.04 LTS Server (Bionic Beaver) with python-ow I decided to write down my experiences here.

Orientation

Plug it in! You should see something like:

Run the following command to load the built in kernel module:

You will now be able to reach the 1-wire bus master at this location:

If you have a working temperature sensor, like the DS18B20, you can run the following command and get its reading

I would like to use Python to handle the temperature in order to make good use of the temperature and it’s quite possible to just read this value from the file system. However, I would like to use the python-ow package instead.

python-ow

Start off with installing the python-ow package with:

This will also install the owfs-common package. Launch a python terminal to verify the installation:

import ow should work but you are most likely going to run into the permission issue, as can be seen here after the ow.init(‘u’) command. It is possible to run python as root with sudo python and it will not throw an error if all works correctly. However, it’s a bad idea to run all scripts with root so we need to take care of this issue.

libusb permissions

A kernel module (ds2490) is loaded by default which is why the first step works fine. However, python-ow and owfs use the libusb library and we need to disable the kernel module for this to work. Edit the kernel module blacklist:

and add the following to the end of the file:

Next we need to allow a user to use this specific USB device. To do this we create a udev rule:

and add the following content:

What this does is giving the user group plugdev access to the USB adapter. idVendor and idProduct points to the USB device as can be seen with the lsusb command shown earlier. Normal users are members of the plugdev group by default – verify with the groups command.

More information on the section can be found here:
https://www.maximintegrated.com/en/app-notes/index.mvp/id/5917

Important: Reboot the OS in order for all changes to take effect.

Verify functionality

Let’s see if it works. You can launch a python shell and enter the snippets shown earlier. Here is a more complete code section to try out:
(Stolen from https://raspberrypi.stackexchange.com/questions/62292/usage-of-python-ow-one-wire-file-system-python-package-for-reading-1-wire-ds18b2 and modified to taste)