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.
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!
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.
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…
Ok, I will test with external power this weekend and be back with results.
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!
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?
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.
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.
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.