pir motion sensor interface with pic16f877a
Posts: 6,843
Threads: 4
Joined: Mar 2015
Introduction
This project describes a motion sensor alarm based on a Passive Infra-Red (PIR) sensor module. There are many vendors that manufacture the PIR sensor modules and almost all of them are pretty much the same in function. They have a single output that goes high (or low, based on specification) when the motion is detected. In this project, a PIC12F635 microcontroller continuously monitors the output from the sensor module and turns a buzzer on when it goes active.
Theory
Certain crystalline materials have the property to generate a surface electric charge when exposed to thermal infrared radiation. This phenomenon is known as pyroelectricity. The Passive Infra-Red (PIR) sensor module works on the same principle. The human body radiates heat in the form of infrared radiation which is maximum at about 9.4 um. The presence of human body creates a sudden change in the IR profile of the surrounding that is sensed by the pyroelectric sensor. The PIR sensor module has an instrumentation circuit on board that amplifies this signal to appropriate voltage level to indicate the detection of motion.
The PIR sensor requires an initial stabilization time of about 10 to 60 seconds in order to function properly. During this time, the sensor gets familiar with the surrounding environment, and any motion in its field of view should be avoided. The PIR sensor has a typical range of 20 feet, and is designed to adjust to slowly changing conditions such as the gradual change in the thermal profile of the surrounding as the day passes. However, any sudden change in the profile (e.g. human body motion) is responded by the sensor. That’s why the PIR sensor module should not be placed near a heater, AC outlet or anything that could create a rapid change in the surrounding environment.
PIR sensor modules usually have a 3-pin connection: Vcc, Output, and Ground. The pinout may vary, so I recommend to check the manufacturer’s datasheet to confirm the pins. Sometime, they do have labels on the board next to the pins. The one I have got does so, and it can be powered through 5-12 V supply as it has its own voltage regulator on board. The output goes high when the motion is sensed.
Besides it also has a 3-pin jumper selection for single or continuous trigger output mode. The two positions have labels H and L. When the jumper is at H position, the output remains high when the sensor is re-triggered repeatedly. In position L, the output goes high and low every time the sensor is triggered. So a continuous motion will give repeated high/low pulses in this mode. The front part of the sensor module has a Fresnel lens to focus the infrared light on to the sensor element.