pir sensor

HI,

I am trying to use a passive infrared modul with arduino. I can't seem to register the output change. I.e. the out put is always 1 or 0. Do i need to some how calibrate/tune the sensor using reistors?

thanks

Tx

Hi:

You can put a resistor to ground from the signal wire.

Typically, PIR sensors take 45 seconds ~ 1 minute to calibrate. So as soon as power is sent to the PIR, leave the area for a minute so it can calibrate itself. Any humans within its reach will disrupt the calibration. PIR are active-low and will give you a PULSE of 1.

You can limit the scope of the PIR by constructing cylinders or cones around the lense, this will restrict its range. Typically, PIR sense 60 degrees from the radius out.

Other than that just experiment unti you get the perfect conditions for you.

-n

that sounds great
thanks for the advice!

Hve tried the above and still no luck. Just getting constant high or constant 0 with the resistor.

Device doesn't seem to stabalise. I have tried a sharp 2y0d02 37 proximity sensor too, but no luck. The sensor just gets very hot.

Any advice. I have double checked the circuit and all seems to be ok.

??
T

take a picture to show us how you have it connected, and we'll be able to figure out the probelm fast!

i did not have any problems using the PIR after reading the datasheet (http://www.parallax.com/dl/docs/prod/audiovis/PIRSensor-V1.1.pdf).
it should not be a problem at all to use it, if the sensor is not damaged. i did not even use a pullup resistor, setting the input pin LOW during setup should do the job.

the only little issue i ran into was the fact that even if ongoing motion is present the sensors soutput goes to LOW from time to time, which might give the impression that the detected motion is interrupted. i wrote a little program that deals with this issue.
for those who´d like to use the pir-sensor in a more advanced fashion i it might be quite handy:

/* 
 * //////////////////////////////////////////////////
 * //making sense of the Parallax PIR sensor's output
 * //////////////////////////////////////////////////
 *
 * Switches a LED according to the state of the sensors output pin.
 * Determines the beginning and end of continuous motion sequences.
 *
 * @author: Kristian Gohlke / krigo(_)web.de / http://filformat.net
 * @date:   3. September 2006 
 *
 * kr1 (cleft) 2006 
 * released under a creative commons "Attribution-NonCommercial-ShareAlike 2.0" license
 * http://creativecommons.org/licenses/by-nc-sa/2.0/de/
 *
 *
 * The Parallax PIR Sensor is an easy to use digital infrared motion sensor module. 
 * (http://www.parallax.com/detail.asp?product_id=555-28027)
 *
 * The sensor´s output pin goes to HIGH if motion is present.
 * However, even if motion is present it goes to LOW from time to time, 
 * which might give the impression no motion is present. 
 * This program deals with this issue by ignoring LOW-phases shorter than a given time, 
 * assuming continuous motion is present during these phases.
 *  
 */

/////////////////////////////
//VARS
int calibrationTime = 30;        //the time we give the sensor to calibrate itself (10-60 secs according to the datasheet)
long unsigned int lowIn;         //the time when the sensor outputs a low impulse
long unsigned int pause = 5000;  //the amount of milliseconds the sensor has to be low before we assume all motion has stopped

boolean lockLow = true;
boolean takeLowTime;  

int pirPin = 3;    //the digital pin connected to the PIR sensor's output
int ledPin = 13;


/////////////////////////////
//SETUP
void setup(){
  Serial.begin(9600);
  pinMode(pirPin, INPUT);
  pinMode(ledPin, OUTPUT);
  digitalWrite(pirPin, LOW);
  
  //give the sensor some time to calibrate
  Serial.print("calibrating sensor ");
    for(int i = 0; i < calibrationTime; i++){
      Serial.print(".");
      delay(1000);
      }
    Serial.println(" done");
    Serial.println("SENSOR ACTIVE");
    delay(50);
  }

////////////////////////////
//LOOP
void loop(){
     
     if(digitalRead(pirPin) == HIGH){
       digitalWrite(ledPin, HIGH);   //the led visualizes the sensors output pin state
       if(lockLow){  
         lockLow = false;            //make sure we wait for a transition to LOW before any further output is made
         Serial.println("---");
         Serial.print("motion detected at ");
         Serial.print(millis()/1000);
         Serial.println(" sec"); 
         delay(50);
         }         
         takeLowTime = true;
       }
     
     if(digitalRead(pirPin) == LOW){       
       digitalWrite(ledPin, LOW);  //the led visualizes the sensors output pin state
       
       if(takeLowTime){
        lowIn = millis();          //save the time of the transition from high to LOW
        takeLowTime = false;       //make sure this is only done at the start of a LOW phase
        }
       
       if(!lockLow && millis() - lowIn > pause){  //if the sensor is low for more than the given pause, we assume that no more motion is going to happen
           lockLow = true;                        //makes sure this block of code is only executed again after a new motion sequence has been detected
           Serial.print("motion ended at ");      //output
           Serial.print((millis() - pause)/1000);
           Serial.println(" sec");
           delay(50);
           }
       }
  }

check this for up to date version of the program:

http://www.arduino.cc/playground/Code/PIRsense

Kristian,

Just wanted to thank you for the code. I've used your code to build a motion activated LED light system for my dog stairs. Yes, I built dog stairs so my dogs didn't have to jump up so far to get in bed....now they have stairs that have motion activated lights and I've used a photocell to ensure the PIR sensor is only turned on at night...

Hi all,

I just bought a PIR sensor from Maplin, would it be possible to have your view of it?

The sensor is a MQ1510 from IFSAC. Here want I have:

12+ - N/C TT LED-
| | | | | | |
| | | | | | |

and the some pins I can switch to set the pulse and enable the led ( I think ).

I'm not sure if I have to use the N/C or TT. I believe that the sensor output 1 for movement and 0 for none.

I just don't want to damage my arduino board by doing something foolish. I think I can calibrate and test it without the arduino as a I presume the LED turn on for movement.

ant advices?

cheers

Hi all, Im just starting this geeky hobby and have just bought a motion sensor(The sensor is a MQ1510 from IFSAC), opened it up, just to find 7 ports; 12+/-, 2x N/C, 2x TT, LED- that I dont know where to plug what. Im using it with a arduino. 'LED goes OFF when motion is detected' is my goal.

anyone? cause i find no datasheet online for this motion sensor. I just need to know what the N/C and the TT pots do..

The N/C's are easy. N as in not, c as in connected.

Hi, I'm looking at the PIR sensor code above. Does anyone know offhand what the difference is between a long unsigned int and an unsigned long?

I would imagine nothing.

The long allows you to store more data, but also sucks up sketch space.

Unsigned Integer:
http://www.arduino.cc/en/Reference/UnsignedInt

Long with the variable:
http://arduino.cc/en/Reference/UnsignedLong

I never come close to using up all of my sketch size so I normally throw long in with my sensor integer values just because I'm a lazy coder.