Hardware Reference
In-Depth Information
Project 3: How to Make a Temperature Gauge
In this project you are going to be using a DS18B20 sensor to detect the temperature and
display it on the screen. You will also write some Python code to monitor temperature and
send an e-mail alert if the temperature exceeds a predeined threshold. he sensor returns a
Celsius value, so you will also have some optional Python code to do a Fahrenheit conversion
if that is your preference. Table 13-5 shows what you will need.
Table 13-5 What You W ill Need
QTY
Item
Description
1
DS18B20
his sensor looks like a transistor but is actually a highly accurate
1 wire temperature sensor.
1
4.7kΩ resistor
A pull-up resistor.
1
Solderless breadboard
A prototyping board for which parts and wires can be connected by
clipping them into the board. It is used for prototyping electronics
without having to solder parts together.
3, 3
Jumper wires
Male to male for breadboard connections, male to female for con-
necting the breadboard to the GPIO pins. Jumper wires usually
come in packs of various quantities, colours and sizes. Although
you need only 6 for this project, having 20 to 30 of each should see
you through most projects. Any size will do for this project, but
shorter male to male (10 cm) and longer male to female (20 cm)
are best.
Construction
he circuitry for this sensor is very easy to build. Besides the power and ground connections
all you need to do is connect the 4.7Ωk pull-up resistor between the signal and power as
shown in Figures 13-8 and 13-9. It is important to use pin 7 for the sensor connection. he
software you will use to interface with the DS18B20 is hard-coded for pin 7, so you cannot
use another pin for this sensor.
Software
Luckily the software required to interface with the DS18B20 has already been written and is
built into your Raspberry Pi kernel. You will be using an application called Modprobe to
retrieve the temperature value.
At the Raspberry Pi command prompt type the following two commands:
sudo modprobe w1-gpio
sudo modprobe w1-therm
Search WWH ::




Custom Search