Learn how to use the PIR sensor to activate a piezoelectric buzzer and or an LED.
What You Will Learn:
- Basic Circuit Prototyping
- Basic Node-Red Programming
What You Need to Know:
- RPi Node-Red: PIR(motion) Sensor Tutorial
- RPi Node-Red: Piezoelectric Buzzer Tutorial
- RPi Node-Red: LED Tutorial
- One LED
- One PIR
- One Piezoelectric Buzzer
- One 1k ohm Resistor
- One 100 ohm Resistor
- Jumper Wires
Setting up the Hardware
This circuit utilizes a ground and power rail to simply the wiring. Other than that the PIR, LED, and buzzer are wired as they were in their basic tutorials. I would suggest using male-female jumper wires from the PIR to connect to the breadboard.
Setting up Node-Red
Start Node-Red and navigate to 127.0.0.1:1880. Drag one Raspberry Pi input node and two Raspberry Pi output nodes’ into the flow area.
Double click on the Raspberry Pi input node to open its configuration menu. Set the Pin to GPIO20. Name the node “PIR”.
Double click on one of the Raspberry Pi output nodes. Set Pin to GPIO12. Check the box to Initialise pin state? select low (0) from the drop down menu. Name the node “LED”.
Double click on the unmodified Raspberry Pi output node. Set Pin to GPIO16. Set Type to PWM output. Set Frequency to 100. Name the node “buzzer”.
Wire each output node to the single input node and deploy the flow.
If everything is working properly the LED should illuminate and the buzzer should activate for a short period of time after the PIR has detected movement. To deactivate either the buzzer or LED simply delete the wire in Node-Red connecting the associated node with the PIR node.
- What other combinations can you make with items in your kit?