i2c connected 1-wire masters

OWFS the 1-Wire filesystem allows the use of i2c connected bus masters.

RaspberryPi conveniently provide i2c connectivity. However non of the images supplied provide i2c drivers. Fortunately at this point the community with its diverse range of members step in, within a few days an i2c driver is available. A few more days pass, more development takes place and the driver is now a loadable kernel module.

You can view the details of the driver development on this forum thread.

Along with OWFS working on RaspberryPi all the pieces are in place to begin testing of i2c 1-wire bus masters.

Pictured above is a breakout board containing 2 such bus masters, a DS2482-100 (8 pin chip) and DS2482-800 (16 pin chip)

Connections to the RaspberryPi are +3v3, 0v, SCA, SCL , the DS2482-100 has an address of 0x18, the DS2482-800  0x1C addresses are set by address pins on both chips, 2 for the DS2482-100 allowing 4 such devices to exist on the bus, 3 on the DS2482-800 allowing 8 devices to exist on the i2c bus.

Time to power up the RaspberryPi and see what happens, lets take a look in the bootlog first to see if the i2c interfaces have been detected

root@berry:~# dmesg | grep i2c
[ 2.934503] i2c-core: driver [dummy] registered
[ 7.576459] i2c i2c-0: adapter [i2c-gpio0] registered
[ 7.576514] i2c-gpio i2c-gpio.0: using pins 0 (SDA) and 1 (SCL)
[ 7.585273] i2c i2c-1: adapter [i2c-gpio1] registered
[ 7.585321] i2c-gpio i2c-gpio.1: using pins 2 (SDA) and 3 (SCL)

Great so far so good, now lets load the i2c-dev module

root@berry:~# modprobe i2c-dev
root@berry:~# lsmod
Module Size Used by
i2c_dev 4568 0
i2c_gpio 1328 0
i2c_algo_bit 5692 1 i2c_gpio

Checking dmesg again, you’ll see that the device entries have been created

[ 72.230015] i2c /dev entries driver
[ 72.234342] i2c-dev: adapter [i2c-gpio0] registered as minor 0
[ 72.238430] i2c-dev: adapter [i2c-gpio1] registered as minor 1

This can be verified by additions to the entries in devfs, and also by the use of i2c tools

root@berry:~# ls -l /dev/i2c*
crw-rw---- 1 root i2c 89, 0 May 17 19:50 /dev/i2c-0
crw-rw---- 1 root i2c 89, 1 May 17 19:50 /dev/i2c-1
root@berry:~# i2cdetect -l
i2c-0 i2c i2c-gpio0 I2C adapter
i2c-1 i2c i2c-gpio1 I2C adapter

We’ve already got the i2c breakout board connected, so re-run i2cdetect to probe the i2c bus
root@berry:~# i2cdetect -y 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- 18 -- -- -- 1c -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Great, detected addresses match those that we set on the breakout board.
Lets see if owserver can connect to the devices.

root@berry:~# /opt/owfs/bin/owserver --i2c=/dev/i2c-0:ALL
root@berry:~# /opt/owfs/bin/owdir
/bus.8
/bus.7
/bus.6
/bus.5
/bus.4
/bus.3
/bus.2
/bus.1
/bus.0
/uncached
/settings
/system
/statistics
/structure

It appears that OWServer has found 9 1-wire busses, exactly what we’re expecting to happen.
Lets see if we can get some more details.
Which chip on the breakout board is bus.0

root@berry:~# /opt/owfs/bin/owread /bus.0/interface/settings/name
DS2482-100

Which means that bus[1..8] are on the DS2482-800

root@berry:~# /opt/owfs/bin/owread /bus.1/interface/settings/name
DS2482-800(0)
root@berry:~# /opt/owfs/bin/owread /bus.8/interface/settings/name
DS2482-800(7)

How about the i2c addresses of each bus entry.

bus.0
root@berry:~# /opt/owfs/bin/owread /bus.0/interface/settings/address
/dev/i2c-0:18

bus.1 to bus.8

root@berry:~# /opt/owfs/bin/owread /bus.1/interface/settings/address
/dev/i2c-0:1C
root@berry:~# /opt/owfs/bin/owread /bus.8/interface/settings/address
/dev/i2c-0:1C

So now that we’ve established that i2c interfaces work for 1-wire on RaspberryPi we’ll be continuing development of our 1-wire breakout board

Update: Now tested with DS18B20 sensors, and also running with 2 USB adaptors

root@berry:~# /opt/owfs/bin/owdir
/81.A6B821000000
/28.52DE99000000
/81.BA4124000000
/28.5B8A57030000
/28.BF8757030000
/bus.11
/bus.9
/bus.8
/bus.7
/bus.6
/bus.5
/bus.4
/bus.3
/bus.2
/bus.1
/bus.0
/uncached
/settings
/system
/statistics
/structure
/simultaneous
/alarm

Leave a Reply

Your email address will not be published. Required fields are marked *