Interfacing PIR sensor to 8051
PIR sensors are widely used in motion detecting devices. This article is about interfacing a PIR sensor to 8051 microcontroller. A practical intruder alarm system using PIR sensor and 8051 microcontroller is also included at the end of this article. Before going in to the core of the article, let’s have a look at the PIR sensor and its working.
PIR sensor is the abbreviation of Passive Infrared Sensor. It measures the amount of infrared energy radiated by objects in front of it. They does not emit any kind of radiation but senses the infrared waves emitted or reflected by objects. The heart of a PIR sensor is a solid state sensor or an array of such sensors constructed from pyro-electric materials. Pyro-electric material is material by virtue of it generates energy when exposed to radiation.Gallium Nitride is the most common material used for constructing PIR sensors. Suitable lenses are mounted at the front of the sensor to focus the incoming radiation to the sensor face. When ever an object or a human passes across the sensor the intensity of the of the incoming radiation with respect to the background increases. As a result the energy generated by the sensor also increases. Suitable signal conditioning circuits convert the energy generated by the sensor to a suitable voltage output. In simple words the output of a PIR sensor module will be HIGH when there is motion in its field of view and the output will be LOW when there is no motion.
DSN-FIR800 is the PIR sensor module used in this project.Its image is shown above. It operates from 4.5 to 5V supply and the stand by current is less than 60uA. The output voltage will be 3.3V when the motion is detected and 0V when there is no motion. The sensing angle cone is 110° and the sensing range is 7 meters. The default delay time is 5 seconds. There are two preset resistor on the sensor module. One is used for adjusting the delay time and the other is used for adjusting the sensitivity. Refer the datasheet of DSN-FIR800 for knowing more.
Interfacing PIR sensor to 8051.
The 8051 considers any voltage between 2 and 5V at its port pin as HIGH and any voltage between 0 to 0.8V as LOW. Since the output of the PIR sensor module has only two stages (HIGH (3.3V) and LOW (0V)) , it can be directly interfaced to the 8051 microcontroller.
The circuit shown above will read the status of the output of the PIR sensor and switch ON the LED when there is a motion detected and switch OFF the LED when there is no motion detected. Output pin of the PIR sensor is connected to Port 3.5 pin of the 8051. Resistor R1, capacitor C1 and push button switch S1 forms the reset circuit. Capacitors C3,C4 and crystal X1 are associated with the oscillator circuit. C2 is just a decoupling capacitor. LED is connected through Port 2.0 of the microcontroller. Transistor Q1 is used for switching the LED. R2 limits the base current of the transistor and R3 limits the current through the LED. Program for interfacing PIR sensor to 8051 is shown below.
PIR EQU P3.5 LED EQU P2.0 ORG 00H CLR P2.0 SETB P3.5 HERE:JNB PIR, HERE SETB LED HERE1:JB PIR,HERE1 CLR LED SJMP HERE END
The status of the output of the PIR sensor is checked using JNB and JB instructions. Code “HERE:JNB PIR, HERE” loops there until the output of the PIR sensor is HIGH. When it becomes HIGH it means a motion detected and the program sets P2.O HIGH in order to make the LED ON. The output pin of the PIR sensor remains HIGH for 5 seconds after a motion is detected. Code”HERE1:JB PIR,HERE1″ loops there until the output of the PIR sensor becomes LOW. When it becomes LOW the loop is exited and Port 2.0 is made LOW for switching OFF the LED. Then the program jumps back to label “HERE” and the entire cycle is repeated.
For more detail: Interfacing PIR sensor to 8051
JLCPCB – Prototype 10 PCBs for $2 (For Any Color)
China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w
Current Project / Post can also be found using:
- 8051 microcontroller based human motion detection project using pir sensor
- pir sensor interfacing with 8051 microcontroller
- interfacing of pir sensor with 8051 microcontroller
- embedded c program for pir sensor