RPI1 Software

The RPI1 is designed to work with the 1-Wire driver built into the Linux kernel.

To get it to work you need to ensure you have a kernel with the w1_gpio module 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 make an edit to /boot/config.txt before you load the modules. To do this add the following line to the end of the file: "dtoverlay=w1-gpio". Save the file and reboot.

To load the modules required do the following:
pi@raspi:~$ sudo modprobe w1_gpio
pi@raspi:~$ sudo modprobe w1_therm
pi@raspi:~$

You should then be able to do the following:
pi@raspi:~$ ls /sys/bus/w1/devices
28-000004184bfb 28-000004186eb3 w1_bus_master1
28-000004184dc3 28-000004193944
pi@raspi:~$

The four directories starting with 28- in this example are four DS18B20 temperature sensors. To read the temperature from one of the sensors you can do the following:
pi@raspi:~$ cat /sys/bus/w1/devices/28-000004193944/w1_slave
2d 01 4b 46 7f ff 03 10 39 : crc=39 YES
2d 01 4b 46 7f ff 03 10 39 t=18812
pi@raspi:~$

In this example the temperature being reported by that sensor is 18.812C.

When writing software to read this data it is recommended to check the crc gives a "YES" response or sanity check the value is within the expected range (or both) before accepting it as you do sometimes get readings that are way out.

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