PIR sensor documentation

Passive InfraRed sensors (PIRs)

General Description
PIR sensors are passive electronic devices which detect motion by sensing infrared fluctuations. Once a motion is detected, a high is sent to the signal pin.

Because of the biological characteristic of organisms to emit heat, these sensors work well in detecting human motion and therefore are commonly implemented in security applications.

Sensor Operation
PIR sensors are composed of a solid-state pyroelectric chip. This chip is the heart of the device because it generates an electric charge when exposed to infrared radiation. This charge is then enhanced by an amplifier so the output voltage can be interfaced with other devices. The sensitivity of this device is enhanced by a translucent Fresnel Lens covering this chip.

Connecting a PIR sensor to an Arduino board
Connecting a PIR sensor to an Arduino board is a simple process. PIR sensors consist of 3 pins, Vcc (Positive Voltage), Vss (Ground), and Signal. Interfacing it to the Arduino board requires Vcc to be connected to the +5, Vss to be connected to ground, and the Signal pin to be connected to any digital input pin. That's is all!

Notes concerning PIR sensor operation
Calibration Time
PIR sensors need approximately 10-60 seconds to calibrate. During this time it is important to make sure that there is no motion in the sensors' visual range.

Sensitivity
PIR Sensors can only detect motion 20 feet away.

Sensing Restrictions
The Parallax PIR sensor goes high for a predetermined amount of time (approximately 2 seconds). During this time, it's sensing capabilities are disabled. This time period extends for a second after the signal pin goes low again. Presumably, the PIR sensor must recalibrate during this time.

Inverse Mode
The high and low of the signal pin can be reversed by simply changing the placement of the bridge on the back of the sensor.

Example code to get this sensor up and running in Arduino

int ledPin = 13; // led connected to control pin 13
int PIRSensor = 2; // the PIR sensor will be plugged at digital pin 2
int state = 0; // variable to store the value read from the sensor pin
int statePin = LOW; // variable used to store the last LED status, to toggle the light

void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as as OUTPUT
pinMode(PIRSensor, INPUT); // declare the PIRSensor as as OUTPUT
Serial.begin(9600); // use the serial port
}

void loop() {
state = digitalRead(PIRSensor); // read the sensor and store it in "state"

if (state != 0)
{
digitalWrite(LED1, HIGH);
Serial.println("Motion Detected!"); // send the string "Motion Detected!" back // to the computer
}
else
digitalWrite(LED1, LOW); // turns light off if motion is not detected

delay(100); // we have to make a delay to avoid overloading the serial port
}

Additional Resources
http://en.wikipedia.org/wiki/Passive_infrared_sensors
http://www.parallax.com/dl/docs/prod/audiovis/PIRSensor-V1.1.pdf