Knowledge Base

The AB Electronics UK Knowledge Base provides support solutions, tutorials and troubleshooting guides.

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 "Stretch" 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 5 Interface Options and then  P7 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: Reboot your Raspberry Pi

sudo reboot

Step 7: 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 8: 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.