RPI2 Software

The RPI2 is designed to work with the Linux kernel I2C drivers and is supported by OWFS.

To get it to work you need to ensure you have a kernel with the I2C drivers in it. Most of the kernels available for the Raspberry Pi have this support already built in.

If you have one of the newer Linux installs that use Device Tree (which as far as I can tell means anything with kernel 3.18 or newer - the command "uname -a" will tell you what kernel you are running) then you need to turn the I2C system on. You can either do this by manually editing /boot/config.txt and ensuring the line "dtparam=i2c_arm=on" is there and not commented out or by running "sudo raspi-config" and then selecting option 5 (Interfacing Options) followed by option P5 (I2C). On earlier versions of raspi-config the i2c option is in option 8 rather than option 5 at the main menu. Whatever way you turn i2c on you will need to reboot once this is done before you continue with the configuration.

To load the modules required do the following:
pi@raspi:~$ sudo modprobe i2c-bcm2708
pi@raspi:~$ sudo modprobe i2c-dev
pi@raspi:~$

If you want Linux to load these modules automatically at boot time, add the module names to the end of /etc/modules.

If this has worked you can probe the I2C bus as follows:
pi@raspi:~$ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- 18 -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
pi@raspi:~$

If you don't have i2cdetect installed you can get it by running:
"sudo apt-get install i2c-tools".
If you have an early RasPi you will have to "i2cdetect -y 0" as the I2C busses were swapped around between Rev1 and Rev2.
This is showing the DS2482-100 I2C device as device ID 0x18 which unless you have altered J1 or J2 is where it should be.

Next, if you've not got it already, install OWFS:
pi@raspi:~$ sudo apt-get install owfs ow-shell

Then you will need to edit /etc/owfs.conf to tell OWFS to use the i2c device on the RPI2.
To do this open the file with your favourite editor and comment out (by putting a # at the beginning) the line that says "server: FAKE = DS18S20,DS2405".
Then below it add the following line "server: device=/dev/i2c-1" (if you have an early Pi then you will need to put i2c-0 instead).

Now restart owserver:
pi@raspi:~$ sudo service owserver restart
Restarting 1-Wire TCP Server: owserver.
pi@raspi:~$

If this has worked you should now be able to:
pi@raspi:~$ owdir
/28.FC6711040000
/28.B26518040000
/28.3B6018040000
/26.57144F010000
/bus.0
/uncached
/settings
/system
/statistics
/structure
/simultaneous
/alarm
pi@raspi:~$

In this example there are three devices in class 28 (DS18B20 temperature sensors) and one device in class 26 (a DS2438Z, in this case it is one of our SWE3 humidity sensor modules).

Here we can see one of the DS18B20s and then the humidity sensor being read using owread:
pi@raspi:~$ owread /28.FC6711040000/temperature; echo
19.125
pi@raspi:~$ owread /26.57144F010000/humidity; echo
59.7425
pi@raspi:~$

In this example the DS18B20 is reading just over 19C and the SWE3 is showing a relative humidity reading of just under 60%.
The echo at the end is just to make the output easier to read as owread does not put a newline at the end of its output.

Back to RPI2 Shop Page
Quick Find
 
Use keywords to find the product you are looking for.
Advanced Search
0 items