OWFS with i2c support on Raspberry Pi (English version)

Från Temperatur.nu
Hoppa till navigeringHoppa till sök

This guide will help you to get OWFS working on Raspberry Pi's i2c GPIO port.

Goal

To get full OWFS support using the i2c bus the Raspberry Pi.

Software

Hardware

Prerequisites

This guide is written based on a clean install of Raspbian Wheezy (2012-10-28).

Modules

Make sure that the i2c-bus module is not included in the blacklist file.

sudo nano /etc/modprobe.d/raspi-blacklist.conf

Add "#" before

blacklist i2c-bcm2708

The row will look like this:

#blacklist i2c-bcm2708

Make sure that the i2c-dev module is included in /etc/modules

sudo nano /etc/modules

Add "i2c-dev" on it's own row in the file.

i2c-dev

Installation of OWFS

First you'll have to install som neccecary and usefull packages.

sudo apt-get update
sudo apt-get install automake autoconf autotools-dev gcc-4.7 libtool libusb-dev libfuse-dev swig python2.6-dev tcl8.4-dev php5-dev i2c-tools

Answer Yes on any question during the install.

Download the latest version of OWFS (currently 2.8p20)

cd /usr/src
sudo wget  -O owfs-latest.tgz http://sourceforge.net/projects/owfs/files/latest/download

Unpack OWFS

 sudo tar xzvf owfs-latest.tgz

Configure OWFS

cd owfs-2.8pXX
sudo ./configure

If everything goes as planned you'll get a result like this:

Current configuration:

   Deployment location: /opt/owfs

Compile-time options:
                  Caching is enabled
                      USB is DISABLED
                      I2C is enabled
                   HA7Net is enabled
                       W1 is enabled
           Multithreading is enabled
    Parallel port DS1410E is enabled
        TAI8570 barometer is enabled
             Thermocouple is enabled
         Zeroconf/Bonjour is enabled
             Debug-output is enabled
                Profiling is DISABLED
Tracing memory allocation is DISABLED
1wire bus traffic reports is DISABLED

Module configuration:
                    owlib is enabled
                  owshell is enabled
                     owfs is enabled
                  owhttpd is enabled
                   owftpd is enabled
                 owserver is enabled
               owexternal is enabled
                    ownet is enabled
                 ownetlib is enabled
                    owtap is enabled
                    owmon is enabled
                   owcapi is enabled
                     swig is enabled
                   owperl is enabled
                    owphp is DISABLED
                 owpython is DISABLED
                    owtcl is enabled

Compile OWFS, it will take approx 30 minutes

sudo make

Install OWFS, it will take a couple of minutes

sudo make install 

Create a mountpoint for the 1wire folder.

sudo mkdir /mnt/1wire

To make it possible to access the 1wire devices without root privileges you'll have to modify the FUSE settings. Open the fuse configuration file:

sudo nano /etc/fuse.conf

Change

#user_allow_other

to

user_allow_other

Now you can start OWFS!

sudo /opt/owfs/bin/owfs --i2c=ALL:ALL --allow_other /mnt/1wire/

If you're using the USB adapter (DS9490R), just replace "--i2c=ALL:ALL" with "-u"

Make sure everything works as it should by checking the contents of the 1wire folder or by reading a sensor: (Change path according to your sensor id)

cat /mnt/1wire/10.F6877C010800/temperature

You should get the current temperature as result.

Example of how the output of "ls" in the 1wire folder can look like.

Make sure OWFS is started automatically at boot

Create the startup script in /etc/init.d/

cd /etc/init.d
sudo nano start1wire.sh

Add the folowing to the file (remove the first space on each row):

#!/bin/bash

### BEGIN INIT INFO
# Provides:          start1wire
# Required-Start:    $local_fs $syslog
# Required-Stop:     $local_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start OWFS at boot time
# Description:       Start OWFS at boot time
### END INIT INFO

# Starts OWFS
/opt/owfs/bin/owfs --i2c=ALL:ALL --allow_other /mnt/1wire

If you're using the USB adapter (DS9490R), just replace "--i2c=ALL:ALL" with "-u"

To make the script executable, run the following command:

sudo chmod +x start1wire.sh

Add the script to the default runlevel.

sudo update-rc.d start1wire.sh defaults

Congratulations, if you've made it this far you've installed OWFS with i2c support and made sure that it starts automatically when the Raspberry Pi boots.

Sources