HomeRaspberry Pi SensorsInfrared Sensor HC-SR501 PIR Motion Sensor for a Raspberry PI and...

Infrared Sensor HC-SR501 PIR Motion Sensor for a Raspberry PI and Arduino

How to use PIR sensor with your Raspberry PI.

Tech details:

  • Voltage: 5V – 20V
  • Power Consumption: 65mA
  • TTL output: 3.3V, 0V
  • Adjustable delay time (0.3-300sec)
  • Lock time: 0.2 sec
  • Trigger methods: L – disable repeat trigger, H enable repeat trigger
  • Sensing range: less than 120 degrees, within 7 meters
  • Temperature: – 15 ~ +70
  • Dimension: 32*24 mm, distance between screw 28mm, M2, Lens dimension in diameter: 23mm

Connectivity:

3 pin connector, pins as follows:

  • GND: 0V Ground
  • OUT: PIR output (max 3,3v)
  • VCC: 5V Supply (max 20v)

What does it do?

HC-SR501 PIR Motion Sensor is one of the more common types of sensors out there. Infrared light detection allows to track changes in the desired area and respond to the rapid changes. This allows us to detect movement. The sensor produces binary output (0=LOW, 1=HIGH). Sensor requires few moments to set the ambient reading before correct reading can be provided. The dials available on the sensor allow finer control over the sensitivity and the delay timing. Adjust incrementally as changes are rapid.

How to use it?

untitled-sketch_bb


Connecting HC-SR501 PIR Motion Sensor is very simple. The first pin belongs to ground (black) and it is linked to any ground pin on RPI.

Middle (blue) is an output connection and it delivers 0/1 values to the RPI. There is no need for stepping down as the voltage at HIGH is 3.3V. It is powered by 5V input which can be drawn from the RPI (red) .

hc-sr501

Also, present on the board are 2 dials to adjust your sensitivity distance (3-7m) and delay timer (0.3-300sec) turn clockwise to increase the value.

On this particular sensor, you can also notice 3 additional pins, with a jumper connector.  This allows to pick retrigger setting:

  • (pins L) unrepeatable trigger
  • (pins H) repeatable trigger

Sample code:

You can test the sonar using Python2 code from here

Project Download

Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

M5Paper

Programable, ESP32 based awesome dev platform with 4.7 e-ink display by M5Stack

More HATs

client-image
client-image

Argon One M.2

Enclose Raspberry Pi 4 inside this great case with custom I/O, cooling and GPIO and M.2 SSD support

More cases on

client-image
client-image

Best Raspberry Pi Projects

How to use Raspberry PI as WOL (wake on lan) server

0
While you could wake up your PC from a mobile directly, having a dedicated server capable of doing so is the best solution. The reason is simple. You can hook up as many devices as you wish with a single endpoint. This is why Raspberry Pi is perfect for this.

How fast Raspberry Pi NAS is?

0
Let's see how fast Raspberry Pi NAS really is?

Argon18: Argon ONE SSD modification

0
Argon One case just got better - now you can boot it from USB without ruining the design thanks to Argon 18: Argon One SSD modification

The most pointless upgrade to my NAS – Raspberry Pi 3B+

0
This upgrade is almost pointless!

HOW TO...

C/C++ and MicroPython SDK for Raspberry Pi Pico on Windows

0
A guide to SDK toolchain for Raspberry Pi Pico and C/C++ , Micropython on Windows.

A comprehensive guide to Grafana & InfluxDB

0
How to use Grafana and InfluxDB on Raspberry Pi for IoT sensors in home automation

How to boot Raspberry Pi 4 from USB

0
How to set up and boot Raspberry Pi 4 from USB drive - headless guide.

Raspberry Pi Zero, Raspberry Pi 3A+ WiFi without keyboard or cables

0
Getting Raspberry Pi boards connected in seconds

Everything you need to start using JSON

0
It's JSON not Jason, just saying!