Raspberry Pi Multiple Temperature Measurements 1: Measuring
Since this post is a snapshot in time. I recommend that you download a copy of the book which is updated frequently to improve and expand the content.
This is the first of three posts working through a project looking at Measuring Recording and Exploring temperature measurements with the Raspberry Pi.
Multiple Temperature Measurements
- DS18B20 sensors (the waterproof version)
- 10k Ohm resister
- Jumper cables
modprobe w1-gpioregisters the new sensor connected to GPIO4 so that now the Raspberry Pi knows that there is a 1-Wire device connected to the GPIO connector (For more information on the
modprobecommand check out the Glossary).
modprobe w1-thermtells the Raspberry Pi to add the ability to measure temperature on the 1-Wire system.
w1_thermmodules to load automatically at boot we can edit the the
/etc/modulesfile and include both modules there where they will be started when the Pi boots up. To do this edit the
w1_thermmodules so that the file looks like the following;
# /etc/modules: kernel modules to load at boot time.
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.snd-bcm2835 w1-gpio w1-therm
/sys/bus/w1/devicesdirectory and list the contents using the following commands;
cdcommand check out the Glossary here. Or to find out more about the
lscommand go here)
/sys/bus/w1/deviceswhich should include a number of directories starting
28-. The number of directories should match the number of connected sensors. The portion of the name following the
28-is the unique serial number of each of the sensors.
73 01 4b 46 7f ff 0d 10 41 : crc=41 YES 73 01 4b 46 7f ff 0d 10 41 t=23187
YESfor a successful CRC check (CRC stands forCyclic Redundancy Check, a good sign that things are going well). If we get a response like
ERROR, it will be an indication that there is some kind of problem that needs addressing. Check the circuit connections and start troubleshooting.
t=23187is an indication that the temperature is 23.187 degrees Celsius (we need to divide the reported value by 1000).
To convert from degrees Celsius to degrees Fahrenheit, multiply by 9, then divide by 5, then add 32.
cdinto each of the
28-xxxxdirectories in turn and run the
cat w1_slavecommand to check that each is operating correctly. It may be useful at this stage to label the individual sensors with their unique serial numbers to make it easy to identify them correctly later.
The post above (and heaps of other stuff) is in the book ‘Raspberry Pi: Measure, Record, Explore‘ that can be downloaded for free (or donate if you really want to :-)).