Pages: [1]   Go Down
Author Topic: pir sensor  (Read 8465 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
I Love YaBB 2!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 40
I love YaBB 1G - SP1!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
I Love YaBB 2!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

that sounds great
thanks for the advice!
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
I Love YaBB 2!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Bremen, Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

Code:
/*
 * //////////////////////////////////////////////////
 * //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);
           }
       }
  }
« Last Edit: September 04, 2006, 07:06:39 am by kr1 » Logged

Bremen, Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

check this for up to date version of the program:

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...

« Last Edit: July 27, 2009, 12:52:30 pm by JayCollett » Logged

UK
Offline Offline
Jr. Member
**
Karma: 0
Posts: 76
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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..
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 642
Posts: 50366
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?  
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 635
Posts: 34574
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I would imagine nothing.
Logged

California
Offline Offline
Full Member
***
Karma: 0
Posts: 129
That's me, the boy with the broken halo.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: November 10, 2010, 12:08:44 pm by Schmidtn » Logged

Pages: [1]   Go Up
Jump to: