About Us Knowledge Base Community Forum Electronics Toolbox FAQ Shipping & Delivery

Knowledge Base

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

Knowledge Base

OWFS with I2C support on Raspberry Pi

Using the 1 Wire File System with the 1 Wire Pi Plus and 1 Wire Pi Zero
Created: 02/10/2015 | Last Updated: 03/07/2019

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 update

sudo apt-get install owfs python-ow ow-shell

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: Create a folder where the 1 Wire devices will be mounted.

sudo mkdir /mnt/1wire

Step 7: Reboot your Raspberry Pi

sudo reboot

Step 8: Enable the owserver service

sudo systemctl enable owserver.service

Step 9: 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 10: 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.

Using OWFS you can mount your 1 Wire devices to appear within the linux file system.  To mount the available devices run the following command.

sudo owfs -C -uall -m /mnt/1wire --allow_other

Your 1 Wire devices can be found in the directory /mnt/1wire

Was this article helpful? Yes / No

Releated Products

Order a 1 Wire Pi Plus 1-Wire expansion board for the Raspberry Pi

1 Wire Pi Plus

£11.99 Inc VAT: £14.39

Order a 1 Wire Pi Zero 1-Wire expansion board for the Raspberry Pi Zero

1 Wire Pi Zero

£10.49 Inc VAT: £12.59

Related Articles