Hello, I am running into an issue with my PiR sensor constantly going into an ON and OFF state.
Hardware:
D1 mini
AHT20
PiR motion sensor (bought a while ago and do not have the specs/details found spec info online. rated for 5-9v.)
Issue:
PiR constantly switches from ON and OFF.
[16:07:15][D][binary_sensor:036]: ‘PIR Sensor’: Sending state ON
[16:07:20][D][binary_sensor:036]: ‘PIR Sensor’: Sending state OFF
[16:07:43][D][binary_sensor:036]: ‘PIR Sensor’: Sending state ON
[16:07:45][D][binary_sensor:036]: ‘PIR Sensor’: Sending state OFF
esphome:
name: "temp-master-bedroom"
platform: ESP8266
board: d1_mini
sensor:
- platform: aht10
temperature:
name: "Master Bedroom Temperature"
humidity:
name: "Master Bedroom Humidity"
update_interval: 60s
i2c:
sda: D2
scl: D1
scan: True
id: bus_a
binary_sensor:
- platform: gpio
pin:
number: D7
inverted: True (tried enabling and disabling this to no avail)
mode: INPUT_PULLUP (tried adding and removing to no avail)
name: "PIR Sensor"
device_class: motion
The AHT20 is working as intended, but the PiR just keeps logging ON and OFF state.
Edit: Forgot to mention that I’m sharing the ground between the AHT20 and the PiR.
Thanks for the link zoogara. I’ve already looked at that one and many more trying to fix this constant ON/OFF state. I’ve also tried some of the solutions others have tried in this community and still having the same issue.
Continuing from last night’s investigation, I was able to find another PIR of the same type in my storage. After hooking up the new one, the PIR works as intended. Seems the initial one I tried was a dud. (Note to self, test all items when buying bulk online)…
Thanks @marc-graham for the direction about swapping out. If not for your comment, I wouldn’t have gotten off my lazy butt to try and find one.
It’s not uncommon for PIR sensors to be defective right out of the bag, I’ve had it happen on multiple occasions. The symptom your having, its the PIR isn’t defective then i’d focus your attention on making sure your connections are solid and you might turn the pullup back On. You normally don’t need to use the internal pullup but when it bounces from ON/OFF like that, that’s a common indicator of a gpio that’s floating. Turning the pullup on likely wont fix it but turning it on while you troubleshoot will help you rule out a floating gpio. Those usually come in 3 or more packs so if you have a spare i’d try a spare to rule out a defective PIR. The GPIO your using is fine to use but just for the sake of process of elimination, i’d change gpio’s too. Can you post the model of the PIR or a picture of it?
I don’t think they’re horribly expensive on Amazon and after I quit going the cheapest possible route, I noticed that the number of DOA or defective components I received dropped significantly. When sellers have to conduct business under Amazons return policies they’re less likely to sell crap products because people will send that crap back. Who wants to pay the return shipping to China and wait another 30 days for 10$ worth of parts? no one does and they take the loss and buy it again. Thats why almost every single time you see faulty components or DOA components mentioned online and ask, they’re almost always from aliexpress. To each his own but, i’m happy paying a little extra to get my stuff the next day and having the peace of mind that if i get garbage, which rarely happens then I can send it back for free and get new stuff.