1-wire

Introduction

Unfortunately, the use of 1-wire over GPIO pins relies on kernel modules, rather than the userspace implementation of OWFS. If you want to use OWFS, which is arguably more flexible, then it's advised that you do it via a USB->serial adapter. This explanation is only for simple temperature sensing devices which already have kernel support in 2.6.30.5

Dallas DS1822P

The DS1822P device is a simple temperature sensor accessed via the Dallas 1-wire protocol. We will use this for this demonstration.

Connection to the Bifferboard

Connection is really simple. You can remove (cut) the Vdd pin because we'll use 'parasitic' power. All that's needed is a 1.5K resistor between 3.3v and the DQ pin. In this example, we'll connect GND to GND on the Bifferboard (J1 pin 6), and pin DQ to GPIO 12 (J1 pin 5).

Kernel modules

The kernel module loading is similar to that required for i2c, with one important exception. Here we load the w1-gpio-custom module before the w1-gpio module:

root@darkstar:/# modprobe rdc321x_gpio

root@darkstar:/# modprobe wire

root@darkstar:/# modprobe w1-gpio-custom bus0=0,12,0

root@darkstar:/# modprobe w1-gpio

As I explained previously, 1-wire device support is implemented in the kernel, so we also need a module for our temperature sensor. The generic w1-therm module supports the DS1822 along with a bunch of other temperature-sensing devices.

root@darkstar:/# modprobe w1-therm

Getting the temperature

There are no userland utilities for reading the temperature, assuming sysfs is mounted on /sys (it is for Slackware), then you simply look for your device under:

/sys/bus/w1/drivers/w1_slave_driver

Read the device by examining the w1_slave file:

root@darkstar:/# cat sys/bus/w1/drivers/w1_slave_driver/22-0000001ac632/w1_slave

61 01 4b 46 7f ff 0f 10 02 : crc=02 YES

61 01 4b 46 7f ff 0f 10 02 t=22062

The temperature here is given in 1/1000ths of a degree centigrade, e.g. 22 degrees. Below is a rather scrappy photo of an even more scrappily put together circuit.