Go Down

Topic: Problems with SE-10 PIR Motion Sensor (Read 3551 times) previous topic - next topic


Hey guys.
I'm developing a project that concerns the detection of Human presence inside a room.
For this I am using an Arduino with a SE-10 PIR Motion Sensor http://www.sparkfun.com/products/8630.
Although the easy way to put all the stuff working,the results obtained are not the expected.
For example this morning I made a test, where I put the PIR sensor inside a box, to not detect any kind of motion.
Unexpectedly the results were the following:
In 1275 iterations, it had detected motion for 140 times, what represents in the end an error % of 10%!!!

To let you know I am using an open collector scheme with a pullup resistor of 10kohms (http://bildr.org/2011/06/pir_arduino/),  that sends the values to an arduino (supplies the sensor with 5V).

Because I am thinking to use both sensors in my master thesis project, this problem is really worrying.

Thus can somebody help me?


have you accounted for the 1-2 seconds it takes the pir to "warm up" in your code? (like adding a delay in void setup?) also, in my experience with a PIR (mine is a different model, but perhaps this is still your problem), the pin is pulled low for several seconds, so if your code loops several times in a second, the int that is are counting the times the alarm was tripped could be going up more than you intend it to (perhaps the pir was only tripped once, but your code looped 140 times before the pir pin returned to high).


Apr 27, 2012, 10:51 pm Last Edit: Apr 28, 2012, 11:24 am by xaral Reason: 1
This is my code (sorry for some names in portuguese :) )
I put some lines to know about the error produced...

Code: [Select]
int calibrationTime = 60;        

int pirPin1 = 2; //digital 2

int LED1 = 4;
int n_detecoes=0;
int n_iteracoes=0;
int per_detecoes=0;

void setup()



 //give the sensor some time to calibrate
 Serial.println("Sensor Calibration in Progress");
 for(int i = 0; i < calibrationTime; i++){
   digitalWrite(LED1, HIGH);
   digitalWrite(LED1, LOW);

 Serial.println("Sensor Calibration Completed");
 Serial.println("Sensor Reading Active");

void loop()
 int pirVal1 = digitalRead(pirPin1);
 if(pirVal1 == LOW)
   //was motion detected

   n_iteracoes +=1;
   per_detecoes =(n_detecoes*100)/n_iteracoes;


aha! i am a rather inexperienced coder, but think i have found a problem. if i am not mistaken the first line inside your loop "int pirVal1 = digitalRead(pirPin1);" should be "pirVal1 = digitalRead(pirPin1);" and you should add "int pirVal1 = 0;" to where you have defined the rest of your variables at the top.  i'm not sure if this is causing your "big" problem, but I've done the same thing before, and it does mess everything up


please modify your post, select the code  and press the # button (looks so much better).

I'm developing a project that concerns the detection of Human presence inside a room.

PIR sensors in the first place detect movement, not presence (although these two are tightly coupled.

Once visited a company who had PIR in meeting rooms and if we just sat on the tables it took 2 minutes before lights went out. (immediately people started waving :)
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)


Hey Rob! Your totally right. I made the mistake using the word presence, but I know that this sensor just capt movement... Sorry for the mistake ;)

About the code Teddy I'm not sure if the position of the definition of int variable ca affect the final result...
I will try on Monday to use your suggestion on my work

Muito Obrigado  :D


yeah, i have no idea why it seems to mess it up, but in my experience, EVERYTHING has been messed up when i've done that.


Apr 30, 2012, 05:12 am Last Edit: Apr 30, 2012, 11:00 pm by TeslaIaint Reason: 1
As far as motion sensor go, I have a couple parallax motion sensors, and I've beat myself up trying to find a way to make them accurate let alone precise. If you want to spend the money there are industrial grade motion sensors out there that are very reliable. The question is: Do you want to spend the money, and can you adapt them to arduino?


Apr 30, 2012, 05:23 am Last Edit: Apr 30, 2012, 11:01 pm by TeslaIaint Reason: 1
But you could also use a simple filter in your program like a mode/median filter similar to how people use them for ultra sonic detectors.
Average the readings.


Unhappily I don't have more money to spend on material, so I must work with the stuff I already bought :)

Concerning master thesis and arduinos just google it and you will find a lot of thesis that use arduino as microcontroller over the world. Of course this PIR sensor's don't have the best quality, but as far as sparkfun sell them I thought they had the minimum quality acceptable...

At this moment I'm thinking to use something like mode/median filter, the question is: will this filter erase also the true values, when somebody is moving? How the code will know wich values are true and false? Thanks for you help Tesla ;)


Happily a colleague suggest me to put the sensor in a dark room, instead of put it in a box. Seems that it sensibility isn't good for small spaces...

There's another problem now. Some of my movements in front of the sensor was not detected...

$)  $)


Yes, they are not reliable. You could average the readings or you could use two, average those readings, etc.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131