Introduction: Raspberry Pi With a Motion Sensor

How I made a Raspberry Pi with a motion sensor to capture security camera images.

Supplies

1) Raspberry Pi

2) 5V PIR motion sensor module (HC-SR501)

3) DC to DC converter (LM2596 is a good one)

4) 1K Resistor

5) Electrical box (2 gang)

6) 2.1mm barrel power connector

7) Wires with female Dupont connectors

8) 4-40 x 1" screws and nuts (or longer)

9) A plastic drinking straw.


HINT: The longer the 4-40 screws are, the easier it is to thread the nuts on. They stick up higher.

Step 1:

1) Take a metal electrical box and-

a) with a nibbler, nibble an opening for the USB and ethernet ports.

b) Drill mounting holes for the RPi and DC to DC converter. (big enough to fit a 4-40 screw)

c) Drill a mounting hole for the DC barrel connector.

d) Knock out the 3/4" knock-out for the motion sensor. HINT: Most of the knock-outs will be 1/2", the 3/4" will be the bigger one.

Step 2:

2) Plug three Female to female Dupont connector hook-up wires to the +5V (red), GND (black), and OUT (any color you want).

Glue the motion sensor into the 3/4" hole with silicone. Glue in with the wires down and the two adjustment pots up.

***LET DRY before proceeding!***

Step 3:

3) Cut a straw into small sections to act as spacers to keep the RPI and DCtoDC from touching the metal box.

Step 4:

4) Using 4-40 1" screws, mount the RPi in the box with the straw sections acting as stand-offs.

Step 5:

5) Solder wires onto the DC barrel connector and mount it.

Step 6:

6) Solder the wires from the DC connector to the inputs of the DC to DC converter.

Step 7:

7) Cut one end off of two Dupont connector hook up wires (red and black). Leave a connector at the other end.

a) Solder the end of the red wire to the OUT+ pad on the DCtoDC module.

b) Solder the end of the black wire to the OUT- pad on the DCtoDC module.

c) Apply 12V to the barrel connector and set the DC to DC module for 5.1V with a volt meter.

d) Mount the DC to DC module in the box with 4-40 screws and straw stand-offs.

e) Plug the red wire into the RPI Pin 2 (+5V)

f) Plug the black wire into RPI Pin 6 (GND)

Step 8:

8) Connect the three wires from the motion sensor to the RPi as follows:

MS +5V ---> RPi pin 4 (+5V)

MS OUT ---> 1K Resistor ---> RPi Pin 29 (GPIO5)

MS GND ---> RPi Pin 30 (GND)


NOTE: The 1K resistor is needed because the GPIO input is 3.3V but the IR module's output is 5V. It's not the perfect solution but, it works.

Step 9:

9) Write whatever script you want to do something when it senses motion.

Google "How to read a RPi GPIO pin in BASH"


My script grabs a image from my security cameras when it senses motion.