Thursday 3 July 2014

PIR motion sensor interfacing with microcontroller



Passive InRrared sensors:


This sensor senses the bodies that emitting IR radiation and are in motion. there are several types of PIR sensors are available in the market. most common types are these TWO..


TYPE.1: with one potentiometer                                                                                

  

 This Pot is used to set the time of out put signal  stays at logic high on object detection width. this  sensor's sensitivity can't be altered. It produces a     3.3V "logic high". 











TYPE.2: with two potentiometers  
The device has two variable resistors that you can adjust to tweak the performance of the module.
The first one (left-hand side on the photo) determines the sensitivity of the device. The default setting is usually 50%.
The second control (right-hand side on the photo and usually marked “time” on the PCB) allows you to adjust the amount of time the output pin stays at 3.3V (high) when it is triggered by movement. This can be set from a few seconds to 200 seconds. The default setting is usually a few seconds.
    WORKING:
But the operation of the both sensors is same. This PIR sensor doesn't respond for the stationary objects. Instead it senses the IR bodies in motions(hot materials and living objects). This sensor accepts DC voltage of 5V. 

NOTE:

Most of the time pin configuration will be printed on the sensor . But some sensors available with in in India are not describing pin configurations properly. But the standard notation of pin will be like all ways middle pin will be output. so if you identify the GROUND then remaining pin will be VCC.
It is very simple. Most of these sensors are made of using BISS0001(16 pin DIL package). 7th pin of this IC is GND. So take a multimeter and  check for short circuit test and beep sound. then it will be your sensor ground and opposite side pin will be VCC


As the sensor provides 3.3V signal it may be little difficult to interface with microcontrollers working at Vcc=5V(most 8 bit hobby controllers like AT89S51). At the same time it will be easy to interface with low powered microcontrollers like LPC2148. You better check your microcontroller Logic voltage levels.


Actually i interfaced this sensor to ATmega8 MCU which can detect even 3.3 volt logical signal. So i successfully connected this PIR sensor to the ATmega8 microcontroller.

Basic Program 

#include<avr/io.h>
void main()
{
  DDRC=0xfe; //configuring PortC pin 0 as input
 PORTC=0xff; //enabling internal pull-up resistors
DDRB=0xff;    // configuring PortB as output
PORTB=0x00; // buzzer off

while(1)
{
  if((PINC & 0x01)==0x01) // check for sensor pin PC.0 using bit       {                                            //masking (if sensor detects motion ) 
   PORTB=0xff;                   // buzzer on
   }
  else
  PORTB=0x00;                   // buzzer off
}

}
   

4 comments:

Unknown said...

I have enjoyed reading your post thanks for sharing this blogs Pir Motion Sensor|Pir Sensor|Motion Detector

Ecosens said...

Thank you for posting this excellent information..it is very useful to me..!
Click here:
PIR Sensor

Ener-jblog said...

Exclusive post. Thanks for sharing.

Wireless PIR Sensor

pradeep said...

sir can this sensor detect hand moment under 1-2 feet ?

Post a Comment