• 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

Problem with PIR motion sensor

Q&A Forum › Category: Home Automation › Problem with PIR motion sensor
0 Vote Up Vote Down
Peter Eriksson asked 6 years ago

Hello.
I am using “Build a Home Automation System for $100” and have some problem to get motion sensor work.
I dont get any motion detected, the sensor is tested Ok with Arduino.
The sensor is connected to 5v and all other as described in course.
I can arm and disarm, all works fine except motion detecting.
Any ideas?

Question Tags: PIR ESP12E
9 Answers
0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

Hello Peter, thank you for taking the time to post your question.

  • Can you tell me which ESP8266 development board version are you using?
  • How are you powering your ESP8266 board?
  • Which GPIO are you connecting the PIR motion sensor to?
  • Which PIR motion sensor are you using? HC-SR501 or AM312?

Note: The sensor should only be triggered while armed. Thanks!

0 Vote Up Vote Down
Peter Eriksson answered 6 years ago

Hello Rui
I am using a ESP12-E NodeMCU 1.0.
Powered via USB
Connected to GPIO D2 (pin 4)
PIR is HC-SR501
I have tries two different ESP12-E with same result.
 

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

Hello Peter, these errors are quite frustrating. It looks like you’re doing everything right.

I would probably test just one more thing: I would power the ESP with an external power supply that can supply more current…

To be honest I don’t know what’s missing to make it work based on those details. If the ESP8266 was not being armed, if the DHT sensor was crashing for example, or if the PIR sensor didn’t work with an Arduino that would be easier to understand…

0 Vote Up Vote Down
Peter Eriksson answered 6 years ago

Hi Rui
Ok, I will test with external power this weekend and be back with results.

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

You can use a power adapter from a smartphone (it needs to supply 5V). Then, you need to arm the sensor through the Node-RED Dashboard. Also double-check the PIR sensor is well connected. Let me know your results!

0 Vote Up Vote Down
Peter Eriksson answered 6 years ago

Hello
I have tried with a power adapter 5v 2.0A and it is the same problem. I can arm and disarm from Node-RED, led lights up when armed. But no motion detected.
DHT sensor works fine also.
I have loaded original mqtt_esp8266_final from github and tried with same result.
Is there a sketch or way to test only PIR with esp8266?

0 Vote Up Vote Down
David Kosewick answered 6 years ago

Hi Peter,
The PIR should work with only 5V and ground all by itself. To test, you could add about a 330 ohm resistor to a LED and put it on the output of the PIR to ground. It doesn’t matter which lead the resistor is attached to, but the anode of the LED should connect to the output pin on the PIR, (longer lead of a new LED is the anode), and the cathode toward ground. Then apply power and wait about 60 seconds before providing the motion. If it doesn’t work, try turning the LED around just to be sure. Connecting it backwards won’t hurt it, but connecting it without a 220-100 ohm resistor will hurt either the LED, or the PIR. It also may only light dimly, depending on the PIR’s output current abilities.

0 Vote Up Vote Down
Peter Eriksson answered 6 years ago

Hi David
Ok.I can test it that way, but PIR works fine when connected to a Arduino Uno.
But when connected with ESP-12E it´s not detect any motion.

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

To be honest, I don’t know what it can be. Did you try with multiple PIR motion sensors (just to double-check)? Can you try with a different GPIO in your ESP-12E? For example:

  • GPIO 5 (D1)
  • GPIO 14 (D5)
  • GPIO 12 (D6)

Can you test the following code? Just change the variable inputPin with different GPIO pins to test (in that example, it’s using GPIO 14 (D5): http://bit.ly/2X1EugS

Note: please try with GPIO 4 (D2) too.

It should read LOW, then when motion is detected it should read HIGH.

Regards,
Rui

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.