[SOLVED]PIR motion sensor problem

Hello!

I am doing my first project on an arduino uno board, it is a motion sensor that uses the PIR sensor, I did the simulation and everything went well, but when I assemble the components the sensor seems to always be sensing movement, so the power never turns off indication led, when trying to find the problem, I decided to disconnect the sensor from the board and accidentally realized that the pin 2 cable, which is where the PIR sensor signal enters, is very sensitive, so much so that if I pass my hand near to it (4 or 5 cm away) the circuit is activated, I don't even need to touch that cable to activate the led and the buzzer... this problem seems very strange to me because I have seen several videos with this same assembly and they never have that problem, I changed the Arduino board (I have two) and the same thing happens on both boards, obviously I also changed the cable and the pins where I can connect it, I have the same problem on all of them, what can I do? I leave my code so you can see it and I will be very attentive to your answers!

int pinsensor = 2; // Definimos como variable el pin donde se conecta el sensor PIR
	int pinLed = 3; // Definimos como variable el pin donde se conecta el Led
	int pinBuzzer = 4; // Definimos como variable el pin donde se conecta el sensor PIR
  int move = 0;
	
	void setup() // configuración inicial del Arduino
	{
    Serial.begin(9600);
	  pinMode(pinsensor, INPUT); // Configuramos el pin del sensor PIR como entrada 
	  pinMode(pinLed, OUTPUT); // Configuramos el pin del Led como salida 
	  pinMode(pinBuzzer, OUTPUT); // Configuramos el pin del Buzzer como salida
	}
	
	void loop() // Instrucciones que se repetirán mientras el Arduino este en funcionamiento
  
	{
    move = digitalRead(pinsensor);
    delay(50);
	  if(move == HIGH) // Condicional para cuando el sensor PIR detecte movimiento
	  {
      Serial.print(move);
      Serial.print(" : ");
      Serial.print("Movimiento Detectado");
	    digitalWrite(pinLed, HIGH); // Encendido del Led
      tone(pinBuzzer, 80000, 1000); // Se emite una señal tipo tomo al Buzzer, con una frecuencia de 80Khz y una duración de 10 segundos
      move = 0;
      delay(300);
	  }
	  else // Instrucciones para cuando no se cumpla la condición
	  {
      Serial.print(move);
      Serial.print(" : ");
      Serial.print("Movimiento Detectado");
      delay(100);
      digitalWrite(pinLed, LOW); // apagado del Led
	    digitalWrite(pinBuzzer, LOW); // apagado del Buzzer
	  }
	}

Can you, please, post a wiring diagram and a data sheet for the PIR sensor?

Of course, here I leave what you ask me:

I wired a PIR sensor like yours to my Uno and with your code the PIR sensor works OK. The LED lights when there is movement detected.

You print "Movimiento Detectado" whether there is movement or not.

Did you adjust the pots on the sensor for sensitivity and delay?

Could you actually hear an 80KHz tone if it were possible to generate that frequency?

An input that is disconnected is said to be "floating". A floating input is, as you have seen, very sensitive to noise. Your body acts as an antenna for noise.

Thanks for answering!

This was my mistake, I already corrected it

That's right, I tried several settings and it didn't work

As for the frequency, I need it to be 80 Khz, the idea is to scare away bats, I'm still looking for a buzzer that can generate that frequency.

Here you are right, my body works as an antenna, I already configured pin 2 as pull down with the help of a 1K ohm resistor, and the active signal disappears, but I can't activate it again, without the 1K resistor when i connect the cable to the PIR sensor the problem gets worse and it is as if the sensor is always detecting movement, i start to believe that the problem is that the sensor is damaged

Not a buzzer. a speaker. you would need a high frequency amplifier to drive these.

a buzzer will not generate much signal at 80kHz. Ideally you need a loudspeaker tuned to that frequency for maximum efficiency.

You CAN get ultrasound speakers - like this ($1200)

alternatively you could use an array of these ultrasound piezo senders

but bat calls are VERY loud - so you would need a powerful output.

That PIR sensor has a "stay on timer" potentiometer, with a range between 3 seconds and 7 minutes. Turn the pot fully anticlockwise for the shortest time, otherwise you have to sit still for several minutes for the PIR to turn off. Use this sketch with only the LED and PIR sensor for testing.
Leo..

const byte sensorPin = 2;
const byte ledPin = 3;

void setup() {
  pinMode(ledPin, OUTPUT);
}

void loop() {
  digitalWrite(ledPin, digitalRead(sensorPin));
}

Thank you very much everyone for the comments, I'm going to investigate the issue of the speakers more to achieve the expected frequency.

Thanks for this information, I already made the required adjustments, but it didn't work either, I think the problem is in the sensor, I'm going to buy another one.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.