Problem with PIR SB312A Module

Thread Starter

Sommoh1

Joined Jul 26, 2017
3
Hello everyone;

I'm using the PIR SB312A Module with arduino for motion detecting purposes, but every time I connect it to the arduino analoginput pin I get the same random readings. I attached the output voltage diagram. Note that there was no motion in the room and it should have been 0, not like this.
Does anyone have any idea what is is wrong with it? Is it the module or am I doing something wrong? It's pretty simple, One VCC 5V, one output and one ground. I don't know why it doesn't work.
Thanks in advance:)


 

JohnInTX

Joined Jun 26, 2012
4,787
Does it work OK when not connected to the Arduino? If so, you need to look at how you have the input pin configured and whether it is being shared by some other module (that step in output voltage looks like output contention).
If all of that is OK, is the power supply clean and stable? Power lines decoupled?
 

Thread Starter

Sommoh1

Joined Jul 26, 2017
3
Does it work OK when not connected to the Arduino? If so, you need to look at how you have the input pin configured and whether it is being shared by some other module (that step in output voltage looks like output contention).
If all of that is OK, is the power supply clean and stable? Power lines decoupled?
First of all, thanks for the reply;)
I haven't tested any other way. Just Vcc to Arduino's 5V and then ground and get input from A0. should I use another power supply instead of the arduino? And this is the code if it helps:

Code:
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  pinMode(A0, INPUT);

}

float a;
float p;

void loop() {
  // put your main code here, to run repeatedly:
  a = analogRead(A0);
  p = a / 1023 * 5;

  Serial.print("PIR: ");
  Serial.println(p);

  delay(1000);
}
 

JohnInTX

Joined Jun 26, 2012
4,787
I don't know if it makes a difference but the PIR has a digital output. But since its only 3V, reading it with the ADC is not a bad approach. It should work OK, though.

I would first disconnect the PIR from the Arduino, put a cover over it and measure its output with a voltmeter. It should read solid logic levels, if it reads in between, its oscillating. Check it with your scope if you can. Remove the cover and see when and how it switches. You want to see how it works alone. That way you can get an idea of what effect the Arduino is having on it.

If it seems to work by itself, power it from the Arduino board but don't hook up the output. Repeat the tests. If it is now oscillating, you need to clean up the power supply. Get the PIR power right at the 5V regulator, not near the Arduino chip. Add decoupling right at the PIR, maybe 1uF tantalum || .1uf ceramic.

If it works OK then but not when its hooked to the analog pin, try a series resistor (a few hundred ohms) in series with the output.

Try reading it as digital pin.

Consider the fact that these are Chinese cheapos. It may be broken or they may have left off things that would make it more stable in use.
Other than that???

https://senba0128.en.ecplaza.net/products/sb312a-01-001-smart-and_3482033
 

Thread Starter

Sommoh1

Joined Jul 26, 2017
3
I don't know if it makes a difference but the PIR has a digital output. But since its only 3V, reading it with the ADC is not a bad approach. It should work OK, though.

I would first disconnect the PIR from the Arduino, put a cover over it and measure its output with a voltmeter. It should read solid logic levels, if it reads in between, its oscillating. Check it with your scope if you can. Remove the cover and see when and how it switches. You want to see how it works alone. That way you can get an idea of what effect the Arduino is having on it.

If it seems to work by itself, power it from the Arduino board but don't hook up the output. Repeat the tests. If it is now oscillating, you need to clean up the power supply. Get the PIR power right at the 5V regulator, not near the Arduino chip. Add decoupling right at the PIR, maybe 1uF tantalum || .1uf ceramic.

If it works OK then but not when its hooked to the analog pin, try a series resistor (a few hundred ohms) in series with the output.

Try reading it as digital pin.

Consider the fact that these are Chinese cheapos. It may be broken or they may have left off things that would make it more stable in use.
Other than that???

https://senba0128.en.ecplaza.net/products/sb312a-01-001-smart-and_3482033
Thank you very much. I will try all the steps above and report the results soon.
Thanks for your time :)
 
Top