Home Raspberry Pi Sensors Infrared 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 in style with crypto-currency

SATA HAT

Add an SSD to Raspberry Pi 4 and turn it into a super-cooled NAS drive.

More HATs

Argon One

Enclose Raspberry Pi 4 inside this great case with custom I/O, cooling and GPIO

More cases on

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.

Free wireless doorbell (Amazon Dash button hack)

0
The most terrifying situation I can imagine* is missing a parcel

Raspberry Pi NAS: (NAS-pi) Modding like a boss #part2

0
Plex and RAID1 NAS drive build log

MagPi – auto-downloader

0
Grab each edition of Mag Pi as soon as possible!

HOW TO...

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!

How to use Join App in NodeRED

0
The day finally comes where Join app is almost everywhere!

Driving LCD with Arduino and Raspberry Pi

0
Displaying things on an LCD screen is as easy as going through a cup of jellybeans while writing this tutorial!