Tag Archives: motion

HC-SR501 PIR motion sensor interface with Arduino

What is PIR sensor?

A passive infrared sensor (PIR sensor) is an electronic sensor that measures infrared (IR) light radiating from objects in its field of view. They are most often used in PIR-based motion detectors. HC-SR501 PIR sensors are commonly used in security alarms and automatic lighting applications. PIR sensors detect general movement, but do not give information on who or what moved. For that purpose, an active IR sensor is required. PIR sensors are commonly called simply “PIR”, or sometimes “PID”, for “passive infrared detector”. The term passive refers to the fact that PIR devices do not radiate energy for detection purposes. They work entirely by detecting infrared radiation (radiant heat) emitted by or reflected from objects.

PIR sensor parts

For a DC current, the PIR Sensor works from 3.3v to 5v DC and gives a TTL output which is directly given to a microcontroller or to relay through a transistor. The PIR sensor consists of a pyroelectric sensor and a Fresnel lens. This curved lens concentrates infrared radiation toward a detector’s sensor. The sensor output is inverted by the transistor. Collector of the transistor is connected to the input pin forms the latch circuit which is set when PIR output goes high to indicate the presence of a warm body. Output of the latch pin operates the relay driving circuit formed by transistors arranged in emitter follower mode.

How PIR sensor works?

HC-SR501 PIR sensor can detect changes in the amount of infrared radiation impinging upon it, which varies depending on the temperature and surface characteristics of the objects in front of the sensor. PIR Operation

When an object, such as a person, passes in front of the background, such as a wall, the temperature at that point in the sensor’s field of view will rise from room temperature to body temperature, and then back again. The sensor converts the resulting change in the incoming infrared radiation into a change in the output voltage, and this triggers the detection. Objects of similar temperature but different surface characteristics may also have a different infrared emission pattern, and thus moving them with respect to the background may trigger the detector as well.

PIR Module interface with Arduino

PIR Motion Arduino Interface

Compared to other sensors, this one is much easy to interface & use.

Arduino Code

You can download the above code from here.

Upload above code in your Arduino and check the motion detection output on Arduino LED on Pin 13 or serial monitor of Arduino IDE.

I hope you will learn to use PIR motion sensor by this tutorial & it will be helpful to add live object detection in your DIY stuff. In further of this tutorial, you can add some logical conditions in code to turn ON buzzer or send SMS/Email notification for human/animal detection; Notification to receive in phone, microcontroller, computer, cloud database i.e. Arduino based security system. In future such projects will be uploaded in #BeatYourBit website. If you like this tutorial, share it with your friends & any Arduino newbie you know. Give your feedback about this tutorial in Contact, Your feedback will be appreciated.

Like/Follow @beatyourbit on FacebookTwitterInstagram & Telegram for latest updates.