I recently got hold of a Raspberry Pi along with a starter kit. My starter kit came with a couple of sensors and components.

The temperature sensor is the DS18B20


Getting this up and running was pretty straightforward following various instructions on the internet - the most useful being the one from Adafruit

My sensor already comes with a resistor on it’s circuit board so the wiring was just a case of plugging the red wire to the 3.3v supply, the black wire to ground, and the white wire to Pin 7 on my breakout board.

wiring disagram

To load up support for the device follow these steps:

sudo modprobe w1-gpio
sudo modprobe w1-therm
cd /sys/bus/w1/devices
28-0000057cc14e  w1_bus_master1
cd 28-0000057cc14e
cat w1_slave
68 01 4b 46 7f ff 08 10 05 : crc=05 YES
68 01 4b 46 7f ff 08 10 05 t=22500

The second line of text is the temperature.

If you want to change the pin that w1 devices can connect to then you need to edit /boot/cmdline.txt and add this parameter:

bcm2708.w1_gpio_pin=<GPIO_pin_number> (for examplebcm2708.w1_gpio_pin=17).
Blog Logo

Chris Greening



Chris Greening

Blogging about random stuff

View All Posts