PIR & RF interference
Posted: Fri Mar 20, 2015 12:43 pm
My goal for this project was to make an ESP module that just monitors for presence using the PIR sensor - when it senses someone it will log an mqtt message to my Mosquitto server, to be processed & acted upon with Node Red.
Put them all around the house, sense movement, use time of day and other info to turn on lights, predict movement, check that movement is happening to the places that I expect, maybe some kind of alarm if movement is in unexpected directions - there are lots of possibilities here.
But I couldn't get the PIRs to work reliably with the ESPs. I tried -12, -201, & -01. All of them got RF into the PIR that made false triggers.
By using the repeating GPIO read function in Lua Loader I was able to determine that my PIR sensor would report intermittent triggers when the ESP radio was turned on.
Reliable - with the radio disconnected the PIR worked as expected, connect the radio to my AP and the PIR will trigger on its own.
I tried capacitors, shielded very short connections - nothing I tried was able to get rid of the RF messing with the PIR.
So the solution was this:
1. turn the radio off
2. turn interrupt on for the PIR gpio
3. when the PIR interrupts:
a. turn PIR interrupt off
b. start a timer alarm to ignore any more PIR activity for n minutes
c. turn radio on - connect to AP
d. when the radio connects publish the mqtt message
e. when the mqtt message is sent
1) turn the radio off
2) turn the PIR interrupt back on
all with alarms to repeat the process over and over
I was surprised that it worked early on - and I'm able to watch it with my new ESP-oled mqtt message center!
Now I can collect movement information and start figuring out fun ways to process it!
good times!
Put them all around the house, sense movement, use time of day and other info to turn on lights, predict movement, check that movement is happening to the places that I expect, maybe some kind of alarm if movement is in unexpected directions - there are lots of possibilities here.
But I couldn't get the PIRs to work reliably with the ESPs. I tried -12, -201, & -01. All of them got RF into the PIR that made false triggers.
By using the repeating GPIO read function in Lua Loader I was able to determine that my PIR sensor would report intermittent triggers when the ESP radio was turned on.
Reliable - with the radio disconnected the PIR worked as expected, connect the radio to my AP and the PIR will trigger on its own.
I tried capacitors, shielded very short connections - nothing I tried was able to get rid of the RF messing with the PIR.
So the solution was this:
1. turn the radio off
2. turn interrupt on for the PIR gpio
3. when the PIR interrupts:
a. turn PIR interrupt off
b. start a timer alarm to ignore any more PIR activity for n minutes
c. turn radio on - connect to AP
d. when the radio connects publish the mqtt message
e. when the mqtt message is sent
1) turn the radio off
2) turn the PIR interrupt back on
all with alarms to repeat the process over and over
I was surprised that it worked early on - and I'm able to watch it with my new ESP-oled mqtt message center!
Now I can collect movement information and start figuring out fun ways to process it!
good times!