PIR bewegingssensor voor het detecteren van beweging, met instelbare tijd en detectieafstand.
SKU: OT704-C87 Número do artigo: AB039 EAN: 8029313760373 Localização: C08.07
Alternativa
Sensor de movimento com radar de micro-ondas RCWL-051
€ 2,45
Ver esta alternativa
Como ligar o Sensor PIR HC-SR501 Sensor de movimento a um Arduino UNO ou ESP32, com um sketch de exemplo que podes carregar já.
This project detects human motion using the HC-SR501 PIR sensor. When motion is detected, the sensor's output pin goes HIGH, lighting up the onboard LED and printing an alert to the Serial Monitor. Open the Serial Monitor at 115200 baud to view real-time motion status.
/*
* ==================================================================
* Generated by Codey.online — https://www.codey.online
* ==================================================================
* Project : HC-SR501 Motion Detection with Arduino Uno
* Board : Arduino UNO (arduino:avr:uno)
* Parts : HC-SR501 PIR Motion Sensor
* Libraries : none (built-in)
*
* Codey Online is an AI-powered browser IDE for Arduino and ESP32.
* Describe your project and Codey writes the code, draws the wiring
* diagram and uploads it to your board, straight from the browser.
* This code is free to use, modify and share, without warranty.
* ==================================================================
*/
// HC-SR501 PIR Motion Sensor Demo
const int PIR_PIN = 2;
const int LED_PIN = 13;
int lastState = LOW;
void setup() {
pinMode(PIR_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
Serial.begin(115200);
Serial.println(F("HC-SR501 PIR Motion Sensor Initialized"));
Serial.println(F("Warming up sensor (approx. 30-60 seconds)..."));
}
void loop() {
int motionState = digitalRead(PIR_PIN);
if (motionState != lastState) {
if (motionState == HIGH) {
digitalWrite(LED_PIN, HIGH);
Serial.println(F("Motion detected!"));
} else {
digitalWrite(LED_PIN, LOW);
Serial.println(F("Motion ended."));
}
lastState = motionState;
}
delay(100);
}
Wiring diagram and example code generated by Codey.online — https://www.codey.online
This project detects motion using an HC-SR501 PIR sensor. The sensor is powered from the 5V VIN pin, and a 1kΩ/2kΩ resistor voltage divider safely interfaces the sensor output with the ESP32 3.3V input. When motion is detected, the onboard LED illuminates and a notification is sent to the Serial Monitor.
/*
* ==================================================================
* Generated by Codey.online — https://www.codey.online
* ==================================================================
* Project : Motion Detection with HC-SR501 and ESP32
* Board : ESP32 DEVKIT V1 (esp32:esp32:esp32doit-devkit-v1)
* Parts : HC-SR501 PIR Motion Sensor
* Libraries : none (built-in)
*
* Codey Online is an AI-powered browser IDE for Arduino and ESP32.
* Describe your project and Codey writes the code, draws the wiring
* diagram and uploads it to your board, straight from the browser.
* This code is free to use, modify and share, without warranty.
* ==================================================================
*/
// HC-SR501 PIR Motion Sensor Demo
const int PIR_PIN = 13; // Connected to HC-SR501 OUT via divider
const int LED_PIN = 2; // Onboard LED
int lastState = LOW;
void setup() {
Serial.begin(115200);
pinMode(PIR_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
Serial.println("HC-SR501 Sensor warming up (approx. 30-60s)...");
delay(2000);
Serial.println("Ready to detect motion.");
}
void loop() {
int motion = digitalRead(PIR_PIN);
if (motion != lastState) {
if (motion == HIGH) {
digitalWrite(LED_PIN, HIGH);
Serial.println("Motion detected!");
} else {
digitalWrite(LED_PIN, LOW);
Serial.println("Motion ended.");
}
lastState = motion;
}
delay(50);
}
Wiring diagram and example code generated by Codey.online — https://www.codey.online
O sensor de movimento PIR HC-SR501 é um sensor de movimento infravermelho com as seguintes especificações:
– Distância de deteção: 3-7m.
– Atraso: 5-200s
– Tensão de saída: 3.3V
- Funciona com: 4.5-20V
– Ângulo de deteção: <140°.
O sensor de movimento PIR HC-SR501 infravermelho deteta movimento. Quando o movimento é detetado, ele fornece um sinal de 3.3v no pino de saída; o tempo é ajustável através do potenciómetro VR1. A distância de deteção é ajustável de 3-7 metros através do potenciómetro VR2.
| Tensão de saída | 3.3 V |
|---|---|
| Distância de deteção | 3-7 m |
| Atraso | 5-200 s |
Funciona perfeitamente e fica fantástico numa montagem.
esta versão infelizmente não vem com os jumpers para escolher a posição de H e L. mas, de resto, funciona perfeitamente.
Não ficas satisfeito? Tens 30 dias após a receção para devolver o produto.
Tudo sobre devoluções
Sensor PIR HC-SR501 Sensor de movimento