Adjusting the PIR

The PIR sold at Adafruit has a few adjustable components: retriggering, time and sensitivity.

Retriggering

No idea. Even the Adafruit page is cryptic about what this setting does…

Sensitivity

The sensitivity potentiometer can’t really be quantified, but it reacts intuitively. The higher the potentiometer, the more sensitive the sensor will be. Adjust depending on your application. I have mine cranked to 11 ;-)

Time

The time potentiometer sets the amount of time the sensor will stay “ON” after a trigger by mouvement. This is designed to go from 2.5 seconds to 4 minutes, but my PIR can only go as low as 6 seconds.

I have previously implied that there was a frequency adjustment possible on the PIR, but that is not exactly the case. You can adjust the length of time the trigger stays ON (as explained above), and you can adjust the length of time the trigged will stay OFF after that but for this you need to change a resistor that is soldered on the sensor’s board.

Introduction to Passive Infrared Sensor

I just received a PIR sensor in my latest Adafruit delivery. I quickly scanned the web and found 2 projects that I don’t want to do with infrared: Send email and a Walmart greeter… But I’ll use these projects to learn how to wire the PIR and how to read it’s input.

The PIR is very simple to wire up. Black and red to ground and +5v, the middle yellow wire goes into an input pin on the Arduino.  To keep things simple, I’m using a digitalWrite() so the motion sensor will either output HIGH when motion is detected and LOW when no movement is sensed.

Here’s the code. It’s light a LED on pin 11 when the sensor is triggered:


/**
* Simple example of reading from a Passive IR Sensor
*/

// Connect PIR miidle pin to A1
const int inPirSensorPin = 7;
const int redLedPin = 11;

void setup() {
  // initialize serial com
  Serial.begin(9600);
  // PIR will be a digital input
  pinMode(inPirSensorPin, INPUT);
  // Red LED is an output
  pinMode(redLedPin, OUTPUT);
}

void loop() {
  // read the sensor:
  //int pirSensorValue = analogRead(pirSensorPin);
  int pirSensorValue = digitalRead(inPirSensorPin);
  if (pirSensorValue == HIGH) {
    analogWrite(redLedPin, 255);
  }
  else {
    analogWrite(redLedPin, 0);
  }
  // print out to serial
  //Serial.print("PIR value:"); Serial.println(pirSensorValue);
  // wait 100 ms
  delay(100);
}

My first surprise is that the signal is very low frequency. You can read it every 100 milliseconds if you like (as in the example), but the signal only changes about every 10 seconds. I noticed there are 2 pots on the side of the PIR sensor unit. I will look into and report on a following post.