Wiki

Clone wiki

DS18B20 / Home

DS18B20

The DS18B20 is a temperature sensor from Dallas Semiconductor that uses the 1-wire protocol. This library allows for the use of a DS18B20 with a Raspberry Pi.

Additional Packages

The 1-wire protocol requires a kernel module to work. Occidentalis includes this module by default. I am unsure at this point of how to get the module working under other distributions.

Setup

Clone the library using GIT.

$ git clone https://bitbucket.org/lancesc/ds18b20.git

Install the python egg.

sudo python setup.py install

Wiring

The sensor must be attached to GPIO 4 at this time.

Example Script

#!python

import temperature.ds18b20 as ds18b20

temperature = ds18b20.DS18B20()

print temperature.celsius()

Where to get one

Adafruit sells a waterproof DS18B20.

Known Issues

The performance of the library is slow. Profiling the library shows almost all time reading from the filesys object associated with the device.

The package name "temperature" seems awkward and may change in a future release.

Updated