Hardware Reference
In-Depth Information
QTY
Item
Description
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 elec-
tronics without having to solder parts together.
3, 5
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 8 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
You are going to be using the Raspberry Pi GPIO ports to interface with the sensors. GPIO
ports can be conigured for input or output. In this case you are going to use them for input
as you are collecting data from an external sensor. A GPIO port can have three diferent
states: high (positive), low (ground) or loating (either). For you to be able to accurately
determine the state of the GPIO pin, you need to tie it either to positive or negative (ground).
You do this using what is known as a pull-up or pull-down resistor. When the GPIO is con-
nected to a positive current the GPIO pin's value is high. When it is connect to ground it is
low. Figure 13-3 shows a pull-up resistor (10kΩ) that connects the GPIO to positive when
the switch is open. However, when the switch closes there is a lower resistance path to
ground, and the GPIO state will go low. Figure 13-4 shows a pull-down resistor (10kΩ) con-
necting the GPIO pin to ground, making it low. When the switch is pressed there is a lower
resistance to positive, which changes the GPIO state to high. he 1kΩ resistor is there to
protect the GPIO pin from a short circuit when the switch is pressed.
Always double-check your circuits before powering on the Raspberry Pi. You can very easily
damage the Raspberry Pi by not protecting the GPIO pins with resistors. Be especially careful
of the 5V pins, which if connected to a GPIO pin will cause permanent damage.
In your project you want a closed circuit (low state) when the door is closed or when there is
no motion and a high state when the door is opened or motion is detected, so you want a
pull-up resistor to set the GPIO high in an alarm state. You will therefore base your circuitry
on the diagram in Figure 13-3.
Search WWH ::




Custom Search