• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

ESP32 with PIR Motion Sensor – Interrupts and Timers

Q&A Forum › ESP32 with PIR Motion Sensor – Interrupts and Timers
0 Vote Up Vote Down
John Crawford asked 7 years ago

The circuit for this, shows the PIR unit connected to 3.3v, which I did. When I ran the program I received constant false movement detection. I looked at the information for the PIR modules on Banggood.com and noted that the operations voltage range is 4.5V to 20V, so the 3.3 volts shown in your drawing is out of range. I connected the power for the PIR to VIN (5V) and all is working very well

11 Answers
0 Vote Up Vote Down
Rui Santos Staff answered 7 years ago

Thanks for bringing that up, but are you using the Mini HC-SR505 PIR Motion Sensor? Or the normal size PIR sensor HC-SR501?

0 Vote Up Vote Down
John Crawford answered 7 years ago

Hi Rui,
      I am using  the normal size PIR HC-SR501 that I have had for some time but have not used. My version only has one set of three pins, for VCC, GND and OUT, where as the one shown in your reference above has two sets of three pins one that has a jumper across two of the pins. I guess that I will have to get a new version, which would you recommend?
Regards
John

0 Vote Up Vote Down
Rui Santos Staff answered 7 years ago

You are right. The PIR HC-SR501 that you’re using operates at 5V (by the way you can make it work at 3.3V, if you follow this tutorial: Modifying Cheap PIR Motion Sensor to Work at 3.3V).

In the course, I’m using the Mini HC-SR505 PIR Motion sensor that operates at 3.3V, so that’s why my sensor is connected to 3.3V. The sensor used in the course also only has 3 pins (VCC OUT GND). You can keep using the PIR HC-SR501 sensor, there’s not need to upgrade, but if you want a smaller sensor I recommend the Mini HC-SR505 PIR Motion Sensor. I also think this mini sensor is more reliable.

I hope that helps!

0 Vote Up Vote Down
John Crawford answered 7 years ago

 Thanks again Rui, I have made the modification as per your tutorial, and HC-SR501 is now working at 3.3V. I have also ordered some HC-SR505 for comparison.
 
Regards
John

0 Vote Up Vote Down
Rui Santos Staff answered 7 years ago

You’re welcome, let me know your results with the new sensor!

0 Vote Up Vote Down
Thomas Perillo answered 7 years ago

My PIR (using SR505 Mini Sensor) Interrupt sketch seems to generate an interrupt (“motion detected”message) consistently every 7 sec. whether there is motion or not.  The serial monitor almost never prints a “Motion Stopped” message.  I’ve covered the PIC with Aluminum foil and get the same readings.I have tested the SR505 using just a battery (3.6V) and LED. Motion will activate the LED for about 10 sec and then turn off.  I am using a Node MCU 36 Pin esp32 Board.  The PIR is connected to pin 12 and the LED to pin27

0 Vote Up Vote Down
Rui Santos Staff answered 7 years ago

If you remove your PIR motion sensor from the ESP32 pin and you connect that pin to GND, does the interrupt still keep triggering?

0 Vote Up Vote Down
Thomas Perillo answered 7 years ago

The interrupt does not trigger.  The serial monitor prints “motion stopped”.  I am guessing this indicates a faulty signal from the PIR and that the ESP32 is OK.  I would have thought my test of the PIR with just batteries ( 3.6v – I have the PIR connected to the VIN 3.3 v port) and an LED ruled out a faulty PIR.  So now I am anticipating learning what your test indicates.

0 Vote Up Vote Down
Rui Santos Staff answered 7 years ago

Exactly, it sounds like the code is running OK and the ESP32 is also OK. It can be noise wireless noise that is causing those false positives to trigger the PIR or a faulty sensor… If you could test with another PIR sensor that would help us debug that problem (it can be the normal sized PIR sensor powered at 5V).

0 Vote Up Vote Down
Thomas Perillo answered 7 years ago

Will find/buy a 5V PIR to test for noise.

0 Vote Up Vote Down
Rui Santos Staff answered 7 years ago

Ok. Let me know your results! Otherwise, you might also want to try with a different ESP32 GPIO or in a different room in your home.

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.