So I’ve been reading up on PIR sensors and I have mostly read that the HC-SR501 is to be avoided since it gives a lot of false positives. Since that’s the only sensor I’ve got lying around atm I tried it out anyway and hooked one up to a ESP01. Result: constant false positives. Nightmare.
So which PIR sensor is generally recommended i.c.w. ESPHome?
Panasonic EKMB or EKMC series. They have a large choice of variants for shapes, sensitivity and lenses. They’re hands down some of the best PIR sensors you can find on the market. They’re so far ahead of this SR501 garbage, it’s a different planet.
Thanks. I’ll have a look at those and see if I can make them work with an ESP01.
It’s interesting though. A simple SR501 suffices just fine as a motion sensor for WLED projects, which also uses ESP boards. But for a ESPHome project like automatic lights the sensor suddenly gives a ton of false positives.
It’s an extremely low quality sensor that is prone to all kind of interference and noise, has very limited signal processing capabilities and only uses two pyroelectric elements for detection (compared to 4 in the Panasonic ones). Its only ‘advantage’ is its very cheap price. But you get what you pay for.
Oh, it is. I’ve been running several WLED projects for a couple of years now and I can’t remember ever experiencing a false positive.
I thought about what was different in both situations and initially thought it was because the ESPHome version has to send data from the PIR constantly to hassio. But can that really be it? When I connect to the ESP boards that are running WLED to play with the settings it’s also basically sending data back and forth without triggering a false positive.
So what’s different? Libraries? The frequency in which ESPHome sends and receives data? I just can’t figure it out.
Could be interference. ESPs are known to be really dirty RF-wise, they spew out RF everywhere around them and backscatter into Vcc too (if your PIR is powered by the same rail as the ESP, which is likely). RF comes both from the wifi chip (so it could be from more intense communication of ESPHome compared to WLED) and from the clock oscillators. The latter can create really random problems when dealing with devices poorly protected from EMI (like these trash-pirs), as oscillator noise can change depending on what the code running on the MCU actually does at a certain point in time. Maybe WLED sleeps a lot more or uses less tight loops.
Or it’s just a placement issue. Maybe the PIR was not placed in the exact same location and angle when doing the WLED experiments compared to the ESPHome ones. Or the distance between the ESP and the PIR was different (different EMI exposure). There are endless possibilities when dealing with unreliable devices like that PIR. Especially combined with heavy EMI offenders like ESP chips.
The Panasonic PIRs should solve that. They have built-in EMI shielding.
That is very interesting. I also read an article about soldering a 220nf capacitor between pins 13 and 14 on the chip. That’s supposed to stop the false positives. I’m going to try that when I get home tonight and if that doesn’t work I’ll be trying a EKMC1601111 (although I am a bit worried about coverage so I’ll have to pick a good location since 2 of those sensors per area will become quite costly).
Eh. If a 1 cent capacitor would magically turn a crap PIR into a perfectly working device, then it would already be on the PCB (hint - there already are decoupling caps on it). Things like that are mostly placebo in practice. Removing RF noise is hard and needs well designed LC filters, well designed RF aware PCB tracing, shielding and error tolerant signal processing. Neither the ESP nor the Hc501 have any of that.
About multiple PIRs, that’s the way to go, regardless of the brand. Key tag here is sensor fusion. All PIRs are subject to false positives from time to time, even the best ones. That’s just the nature of the physics they use. But this can be significantly mitigated by using multie sensors and combining their signals. For example, use two PIRs looking into the same room from different angles and only trigger things when both PIRs fire within a predetermined time window (like 5 seconds max, maybe). You’ll see your reliability increase a lot with setups like that.
Sure, it’s more expensive. But like always, you get what you pay for. You can’t expect perfect quality from components that are basically from the bottom of the quality scrap barrel, so to speak (they’re mostly QA rejects from commercial orders that didn’t make the compliance tests).
I get what you are saying and I agree 99%. I am always on the side of balance. A good price to performance ratio is key. That is why DIY is so important, even in the home automation scene. But if a DIY sensor setup costs about as much as a fully fleshed out Zigbee sensor from a reputable brand…
There are far too many factors to consider. Such as a reliable, long-lasting power supply (18650’s are my go-to), coverage, size (big, bulky 3D printed cases might not look very appealing) etc.
That is why I always check what I have at home first and see if I can make it work. Does wrapping the PIR sensor in aluminium foil work like some people suggest? No → move on to the next tip. Does soldering a 220nf capacitor work like some people suggest? No -< move on to the next tip. No more tips? Other method. Etc.
It’s probably professional bias on my side. I do software and hardware engineering for a living, and I’m a perfectionist, so I want my DIY stuff to be production quality too. I’m not a big fan of tinkering with tinfoil around sensors and adding caps into spots I know won’t do anything Visual aesthetics is also very important to me. If it goes into a cabinet somewhere hidden in a junction box, or into the network rack, then all good with DIY. If it’s a PIR being in a super visible spot in my living room ? No way I’m gonna DIY that, I’ll pick up a nice off the shelf device instead.
Ymmv of course, sometimes these contraptions actually work (kinda). It’s all about managing expectations in the end.
Do you know if there are any 12v PIRs with enclosure that use these Panasonic sensors? One of these packaged up in something that could be neatly mounted to the ceiling and connected to a 12v supply (in my case a PLC) would be perfect for my application.
Yeah, just got that reading the Panasonic FAQs about sensors. Idk why but I was thinking about more complex sensors, which were passing every data and made the possibility to adjust sensitivity from HA.
I think that can be done via a DAC, but I’ll make a test with a digital first
Get the digital ones. The analog ones are for scenarios where you will do the signal processing on the raw data yourself. A DAC is not sufficient, you need an opamp to amplify the weak signal and getting the digital signal processing part right is hard. They don’t just give an analog voltage linear to detection distance or something like that. This is the raw data from the pyroelectric element array and it will need extensive data processing to become useable, including things like noise filtering, spike detection, lens correction, etc. The digital versions have all that already included and use proven algorithms for detection.
I’ll go with the digital ones: my long-term goal is to build up some esp32 multi sensor (temperature, humidity, presence, etc…) so I prefer the single component (like Panasonic ones) instead of pre-built sensors.