How to use a Panasonic PIR Motion sensor (EKMC1601112)

I'm trying to get this sensor to work with no luck. According to the documentation http://www.mouser.com/ds/2/316/papirs-ekmc-catalog-23517.pdf, I connected Vdd to 5v, GND to GND, output to digital pin 7. I tried the PIRsense example in Arduino playground, as well as a simple sketch as following:

void setup(){
  Serial.begin(9600);
  pinMode(7,INPUT);
  digitalWrite(7,LOW);
}
void loop(){
  Serial.println(digitalRead(7));
  delay(50);
}

The former get stuck from the beginning. The later keeps giving random output, like alternating 1/0 with serials of 1 sometimes. If I move in front of the sensor, it seems to turn 1. Since the output is not stable at all, I can't tell if the movement is really detected or not. Does anybody know what is wrong with my approach? Thanks!

Are you sure that your sensor is the digital output type? There are also analog output types in that product line, which wouldn’t work for your sketch.

The output terminal is open(Hi-Z) when not detecting, so the terminal must be pulled down with a 10k or a 100k resistor to prevent random output.

PIRout --+------------ arduiono input |---100k --- arduino GND

@ jremington I tried both digitalRead and analogRead, the results have a similar pattern. It's likely an analogue device, but you should be able to use it for digital input as well, right?

@tasasaki Thanks I'll try it again... I've tried it once but the result was not much different, could there be other issues?

Dirty power supply can cause a problem. The best way is driving your system by batteries. NOTES on the spec sheet say:

8) Please use a stabilized power supply. Power supply noise can cause operating errors. Noise resistance: ±20V or less (Square waves with a width of 50ns or 1?s) To reduce the effect of power supply noise, install a capacitor on the sensor’s power supply pin.

And also note that the sensor needs "Circuit stability time" about 25sec typ. 210sec max.

Thank you Tasasaki! I tried to use battery only and it's much more stable now.

Another question, is it supposed to have around 2 seconds of unstable readings each time it detects something?

Another question, is it supposed to have around 2 seconds of unstable readings each time it detects something?

No. Unstable outputs occur just after powering on the sensor for several tens of seconds(maximum). After the sensor goes into stable driving state, you can believe the outputs as detecting signals.

I have the same problem with this panasonic sensor. I’ve tried:

  1. power it from arduino, 5V or 3,3V
  2. power it from external 5V
  3. pull down resistor on sensor pin, 10k or 100K
  4. 0,1uF cap between power pins
  5. analogRead() and digitalRead()
  6. wait 30 sec to settle
  7. tested everything on another sensor

no matter what i do, i always receive HIGH on sensor pin.
With analogRead() i get a value around 1000

here’s my code:

#define PIR 7
int waitInterval=250;
int calibrationTime = 30;

void setup() {
  Serial.begin(9600);
  pinMode(PIR,INPUT);
  Serial.print("Waiting for PIR to settle ");
  for(int i = 0; i < calibrationTime; i++){
    Serial.print(".");
    delay(1000);
  }
  Serial.println(" DONE!");
}

void loop() {
  
  if (digitalRead(PIR) == HIGH) {
    Serial.println("HIGH");
    delay(waitInterval); 
  } else {
    Serial.println("LOW");
    delay(waitInterval);  
  }
  
  //Serial.println(analogRead(PIR));
  //delay(waitInterval);

}