How to Use Passive Infrared Motion (PIR) Sensors on the Arduino - Ultimate Guide to the Arduino #35

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
foreign [Music] we're going to learn about passive infrared motion sensors these sensors are common in home security systems to detect Intruders or to turn on the light when a person enters a room they can also be used to start a video camera when a person or animal gets near the sensor passive infrared sensors or PIR sensors for short to check the infrared radiation created by worm objects the PIR sensor we're going to use in this video is the HC Sr 501 this plastic Dome here is actually a lens it widens the sensor's field of view so it can detect motion from a wider angle the lens extends the sensing area to a 110 degree cone in front of the sensor underneath the lens is the infrared sensing element the sensing element is a pyroelectric infrared sensor we'll get a closer look at how it works in a minute the HC Sr 501 only has three pins there's a pin for VCC a pin for ground and a pin for output when the sensor detects motion it outputs a high signal the duration of the high output can be adjusted by turning this potentiometer this potentiometer adjusts the sensor sensitivity the range can be adjusted from about 2 meters up to 7 meters this is the control chip for the module the biss-0001 it takes the analog output from the sensing element and converts it into a digital signal let's get a better understanding of how the sensor detects motion PIR sensors like the HC sr501 detect motion by measuring changes in infrared radiation across the sensor the sensor element actually has two separate sensing elements the two sensing elements allow the sensor to differentiate between static sources of IR light like sunlight and moving sources like humans and animals when an ire emitting object crosses the path of the sensor the first element measures the IR light and generates a high signal when the object crosses the path of the second element it generates a low signal when the biss-0001 detects a large difference between the signals from the two sensing elements it outputs a high signal now let's take a look at how the sensor behaves when it detects motion to do that we can connect an LED to the sensor's output pin you actually don't need an Arduino for this I'm just using the Arduino as a power source the output pin of the PIR sensor is connected to the anode of the LED the cathode of the LED is connected to a current limiting resistor providing a path to ground the PIR sensor takes about a full minute to initialize during the initialization period the sensor will output false readings once the device is initialized it's ready to detect motion when I wave my hand in front of the sensor you can see the LED light up and stay lit up for about three seconds so the output signal remains high for a period of time after motion is detected even when the motion is no longer present the duration of the output signal is called the time delay and it can be adjusted by turning the TX potentiometer the shortest time delay is about 3 seconds and the longest is about 5 minutes turning the potentiometer clockwise increases the delay and turning it counterclockwise decreases the delay the sensitivity or range of the sensor is adjusted with the SX potentiometer turning it clockwise decreases the range and turning it counterclockwise increases the range one useful application of PIR sensors is using it to turn on lights when someone enters a room 5 volt relays let you control high voltage devices like lights and appliances with sensors like this one in this next example we're going to use the output of a PIR sensor to control a 5 volt relay I won't go into detail about how 5 volt relays work right now I just want to show you how to use them with a PR sensor this is the 5 volt relay and here's the PIR sensor both the PIR sensor and the 5 volt relay need a 5 volt power supply modules also need a ground connection the output of the PIR sensor connects to Arduino pin 10. the input pin of the 5 volt relay connects to Arduino pin 12. the terminals over here are where we connect the high voltage Supply the relay is going to act as a switch between these terminals okay now let's look at the Arduino sketch first we declare a pin variable for the PIR sensor's output and set it equal to digital pin 10. then we declare a pin variable for the 5 volt relays input pin and set it equal to pin 12. in the setup section we set the pin mode of the sensor pin to input and the pin mode of the relay pin to Output then in the loop we take a digital read of the sensor pin and store the result in a local variable called value then we digital write the relay pin with the value stored in the relay pin variable so when the output of the PIR sensor is high which means that motion is detected the relay pin will be written high as well that will activate the relay and turn on whatever is connected to it let's upload this and see if it works so here's the relay and here's the PIR sensor I don't have anything connected to the high voltage terminals of the relay but you can see when it's activated by this led here so when I wave my hand over the PIR sensor the relay is activated it stays activated for the length of the time delay as for a motion activated light you want to use a longer time delay that way the PIR sensor will keep getting triggered while people are in the room so the light will stay on the whole time in the next video we're going to look at another infrared sensor but these IR sensors are used to detect solid objects like walls which makes them perfect for obstacle avoidance systems and remote controlled vehicles [Music] the three in one smart car and iot learning kit from Sun founder is a Hands-On all included Electronics kit that is perfect for anyone who wants to learn how to master the Arduino the kit comes with an Arduino 22 different sensors and modules breadboards jumper wires and everything else you need to build a bunch of fun and interesting projects learn about robotics by building a remote controlled smart car that can be controlled with an infrared remote controller or drive on its own and avoid obstacles or fall on the line learn about the internet of things with a project that lets you monitor the temperature humidity and light level of a room from an app on your smartphone [Music] and build a plant monitor that tracks the temperature humidity light intensity and soil moisture displays it on your smartphone so you can keep your plants water remotely it's a super cool kit and I have lots of fun building all the projects in it so click the link in the description below to order the kit from some founder
Info
Channel: Circuit Basics
Views: 28,577
Rating: undefined out of 5
Keywords: arduino, raspberry pi, circuit projects, electronics projects, circuits, circuit basics, arduino projects, raspberry pi projects, IOT, robotics
Id: hNmacZoweqY
Channel Id: undefined
Length: 9min 7sec (547 seconds)
Published: Fri Jun 16 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.