Initial Setup of Thermal
Hardware and Software
2.x, as the referenced libraries have
not been revved to Python 3.x yet. The
first library needed is the Python GPIO
library. From the command line
prompt, simply type:
Our temperature monitoring system
uses a Maxim DS18B20 thermal sensor.
The DS18B20 digital thermometer
provides nine-bit to 12-bit Celsius
temperature measurements. It has an
operating temperature range of
- 55°C to +125°C, and is accurate to
±0.5°C from - 10°C to +85°C (see the
datasheet for more details).
pi@raspberrpi:~$ sudo apt-get
The sudo part allows you to
access the superuser status to run the
apt package manager for Linux (if you
omit sudo, you will get a permission
denied response). After installation is
complete, verify the installation by
testing under python. Open the
Python interpreter by typing sudo
python at any command prompt.
Note: You need to have superuser
permissions to run the GPIO library in
Python. You will see a new command
prompt (>>>) once the interpreter is active. Type import
RPi.GPIO as GPIO. If the interpreter does not kick out any
errors, we are good to go.
Modifying Python scripts (text files) is easily done
using a simple text editor called nano. For the project to
work, you should store all the files in the same folder.
The first script is the most basic way for the Pi to get
our attention: illuminating an LED. Connect high efficiency
LEDs as shown in Figure 3. GPIO pins on the Pi can be
confusing, depending on your hardware version.
Regardless of what Pi model you have, connect LED
anodes to physical pins 11 and 13 using a series 470 ohm
resistor for each LED; connect the cathodes to ground. For
the Model A, these will be GPIO 17 and GPIO 21; for the
Model B, these will be GPIO 17 and either GPIO 21 or
GPIO 27 — please make sure your code reflects this or the
green LED won’t work.
The actual physical pin connections are identical; the
GPIO “pin” the software uses varies based on the
hardware model as described above (you may end up
blinking an Ethernet status light instead). Write up the
following python script and make sure both your LEDs
Create a new file using nano by typing the following
command: nano led.py. Once in the editor, enter the
import RPi.GPIO as GPIO
RED = 17
GRN = 27
Figure 3. Schematic
def set_LED(color, state):