Knowledge Base

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

OWFS with I2C support on Orange Pi

Created 11/02/2017 | 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 on the Armbian image from https://www.armbian.com for your Orange Pi computer.

Step 1:  Install OWFS and Python-OW

sudo apt-get install owfs python-ow

Step 2: 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-0

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 Orange 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 Orange Pi

sudo reboot

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