Hw-416-b Pir Sensor Datasheet
The following sketch initializes the HW-416-B, monitors the digital output, and prints the motion status to the Serial Monitor while lighting up the built-in LED on pin 13 when motion is detected.
PIR sensors can sometimes behave unpredictably if environmental factors are overlooked. If you experience erratic readings, check the following points:
pir = Pin(2, Pin.IN) # Replace '2' with the GPIO pin you're using led = Pin(25, Pin.OUT)
void setup() pinMode(motionPin, INPUT); pinMode(ledPin, OUTPUT); Serial.begin(9600);
The HW-416-B features a simple 3-pin interface, making it compatible with almost any microcontroller (Arduino, ESP32, Raspberry Pi). Power input (4.5V to 20V). hw-416-b pir sensor datasheet
The white dome is a Fresnel lens . It focuses infrared light from multiple angles onto the tiny pyroelectric sensor inside. PIR Motion Sensor HW416B - Tayda Electronics
try: while True: if GPIO.input(PIR_PIN): print("Motion detected!") time.sleep(1) except KeyboardInterrupt: print("Quit") GPIO.cleanup()
else digitalWrite(ledPin, LOW); if (pirState == HIGH) Serial.println("Motion ended!"); pirState = LOW;
What are you trying to trigger (a relay, a buzzer, an LED strip)? The following sketch initializes the HW-416-B, monitors the
Every detected motion during the output High period resets the delay timer, keeping the output High continuously as long as motion persists. 3. Working Principle
If you are developing a specific project, please share how you plan to deploy the so I can provide customized hardware recommendations or code modifications. AI responses may include mistakes. Learn more Share public link
// Define Pins const int pirPin = 2; // HW-416-B OUT pin connected to Digital Pin 2 const int ledPin = 13; // Built-in Arduino LED // Variables to track sensor state int pirState = LOW; // Start assuming no motion detected int val = 0; // Variable for reading the pin status void setup() pinMode(ledPin, OUTPUT); // Declare LED as output pinMode(pirPin, INPUT); // Declare PIR sensor OUT as input Serial.begin(9600); Serial.println("Warm-up sequence initiated. Waiting for sensor stabilization..."); // PIR sensors require a brief warm-up period (30-60 seconds) to stabilize delay(30000); Serial.println("Sensor active. Monitoring area..."); void loop() val = digitalRead(pirPin); // Read input value from HW-416-B if (val == HIGH) // Check if the input is HIGH digitalWrite(ledPin, HIGH); // Turn LED ON if (pirState == LOW) // Motion just detected Serial.println("--> ALERT: Motion detected!"); pirState = HIGH; else digitalWrite(ledPin, LOW); // Turn LED OFF if (pirState == HIGH) // Motion just ended Serial.println("--> Notice: Motion ended / Area clear."); pirState = LOW; Use code with caution. Best Practices & Troubleshooting
If the signal passes a specific threshold, the IC forces the OUT pin to 3.3V. 💻 Arduino Integration Guide Power input (4
She imagined the makers: someone soldering tiny resistors, testing detection angles, verifying hold times. The datasheet’s diagrams sketched the connector: Vcc, GND, OUT. A recommended application diagram suggested powering the HW-416-B from a microcontroller’s 3.3V rail and reading the OUT pin through a pull-down resistor. There were cautions too—don’t stare into the Fresnel lens with a laser, avoid prolonged exposure to humidity, and allow thirty seconds of stabilization when powering up; the sensor needed a moment of calm to learn the background temperature before it could tell friend from phantom.
Clockwise rotation increases the duration the output pin stays "HIGH" after detecting motion. Counter-clockwise rotation decreases the time down to roughly 5 seconds. How the HW-416-B Works
L (non-repeatable) / H (repeatable, default) Operating Temperature: -15°C to +70°C PCB Dimensions: Approx. 32mm x 24mm 🔌 Pinout Configuration