OWFS with I2C support on Raspberry Pi

Created 02/10/2015 | Using the 1 Wire File System with the 1 Wire Pi Plus and 1 Wire Pi Zero

This page details how to set up the 1 Wire File System to use with the 1 Wire Pi Plus and 1 Wire Pi Zero on Raspbian "Jessie" from http://www.raspberrypi.org/downloads

Step 1: Download the latest Raspbian linux image and burn to your SD Card following the instructions on http://elinux.org/RPi_Easy_SD_Card_Setup

Step 2: Follow our I2C, SMBus and Raspbian Linux tutorial to set up I2C on the Raspberry Pi.

Step 3: Go into the raspberry pi config utility and enable 1-Wire.

sudo raspi-config

Select 8 Advanced Options and then  A9 1-Wire. A prompt will appear asking Would you like the one-wire interface to be enabled?, select Yes, exit the utility and reboot your raspberry pi.

sudo reboot

Step 4:  Install OWFS and Python-OW

sudo apt-get install owfs python-ow

Step 5: Edit owfs.conf to enable the I2C 1 Wire interface

sudo nano /etc/owfs.conf

Comment out the following line

# server: FAKE = DS18S20,DS2405

Find the following section

# USB device: DS9490
#server: usb = all
#

Insert the line below to enable i2c support. 

server: device = /dev/i2c-1

Find the section titled

######################### OWFS ##########################

Remove the hashes from the lines

mountpoint = /mnt/1wire
allow_other

Save your changes and exit the nano editor.

Step 6: Before you can use OWFS with Python you will need to start owserver.  To start this when the Raspberry Pi boots you will need to modify rc.local.

sudo nano /etc/rc.local

Insert the following command at the top of the file.

sudo /opt/owfs/bin/owserver -c /etc/owfs.conf --pid-file /var/run/owfs/owserver.pid

Save your changes and exit the nano editor.

Step 7: Reboot your Raspberry Pi

sudo reboot

Step 8: Your Raspberry Pi should now work with OWFS.  To test this we will create a python script which lists all 1 Wire devices connected to the 1 Wire Pi.

Create a new python script called 1wiretest.py

nano 1wiretest.py

Insert the following python code:

import ow
ow.init('localhost:4304')
sensorlist = ow.Sensor('/').sensorList()
for sensor in sensorlist:
    print('Device Found')
    print('Address: ' + sensor.address)
    print('Family: ' + sensor.family)
    print('ID: ' + sensor.id) print('Type: ' + sensor.type)
    print(' ')

Step 9: Save and run the file.

python 1wiretest.py

If everything works correctly the script should list every 1 Wire devices connected to the Raspberry Pi.

Shop

Support

Click to contact us.
X

Have any Questions?

Send us any questions about this page or product and we will reply within 24 hours.

Submit your Message

X

Have any Questions?

Thank you for contacting us.

We will respond to your enquiry in the next 24 hours.

You can find answers to many questions and additional product support in our Knowledge Base and the Community Forum.