We are going to connect both sensors to the Raspberry Pi at the same time. Neither sensor requires any extra components. This tutorial works with all versions of Raspberry Pi (rev 1, 2, A, B, B+ and Zero) except the compute module which has no headers. 

40-Pin (A, B, B+ and Zero) Cobbler Plus Schematic

20-Pin (Rev 1 and Rev2) Cobbler Schematic

The PIR sensor comes with a socket and lead. Make sure that the socket is the right way around (use the picture below) and that the red lead goes to 5V, the black to GND and the yellow to 18 on the Cobbler.

Although the PIR sensor requires a 5V supply, its output is a Pi-friendly 3.3V, so it can be connected directly to a GPIO input.

The Door Switch, uses what is called a reed switch. These are two contacts inside a glass tube, that is then encased in plastic. When a magnet (the other white block) is placed near the reed switch, the contacts are drawn together and the switch closes. Since this is just a switch, the leads can be connected either way around.

We will use the Pi's ability to create an internal pull-up resistor on the reed-switch pin, so we don't need an external pull-up resistor.

This guide was first published on Feb 13, 2013. It was last updated on Feb 19, 2024.

This page (Hardware) was last updated on Feb 13, 2013.

Text editor powered by tinymce.