Skillnad mellan versioner av "OWFS with i2c support on Raspberry Pi (English version)"

Från wiki.m.nu
Hoppa till: navigering, sök
(Installation of OWFS)
(Installation of OWFS)
Rad 60: Rad 60:
 
First you'll have to install som neccecary and usefull packages.
 
First you'll have to install som neccecary and usefull packages.
 
  sudo apt-get update
 
  sudo apt-get update
  sudo apt-get install automake autoconf autotools-dev gcc-4.7 libtool libusb-1.0-0-dev libfuse-dev swig python2.7-dev tcl8.5-dev php5-dev i2c-tools
+
  sudo apt-get install automake autoconf autotools-dev gcc-4.7 libavahi-client-dev libtool libusb-1.0-0-dev libfuse-dev swig python2.7-dev tcl8.5-dev php5-dev i2c-tools
 
Answer Yes on any question during the install.
 
Answer Yes on any question during the install.
  

Versionen från 14 maj 2015 kl. 07.47

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 installed via Noobs 1.3.12 (2015-02-02).

Modules

Add i2c-bcm2708 and i2c-dev in /etc/modules

sudo nano /etc/modules

Add them on separate lines in the file.

i2c-bcm2708
i2c-dev

Open /boot/configt.txt

sudo nano /boot/config.txt

Add the following lines at the bottom

dtparam=i2c1=on
dtparam=i2c_arm=on

Reboot:

sudo reboot


Verify that the i2c to 1wire module is found

Run

sudo i2cdetect -y 1

Which should give an output like this:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- 1b -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

If you see 1b, the i2c to 1wire module is found.

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 libavahi-client-dev libtool libusb-1.0-0-dev libfuse-dev swig python2.7-dev tcl8.5-dev php5-dev i2c-tools

Answer Yes on any question during the install.

Download the latest version of OWFS (currently 3.0p0)

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-3.0p0
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 on A/B/A+/B+ and approx 5 minutes on Pi 2 A/B/A+/B+

sudo make

Pi 2 (-j 4 makes sure all four cores is used)

sudo make -j 4

Install OWFS, it will take a minute or two

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.

Fil:Owfs ls example.png
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