ESPHome PIR False Positives cheap ESP32

Hey all,

I built a few ESP32 PIR sensors and I keep getting false positives. I’ve added ferrites to VCC and G and even changed to the uber expensive Panasonic PIR and I’m still getting false positives.

The one in the bathroom is the worst, but they all have them.

Im using the Alibaba cheap ESP32s

Could it be the board? Too cheap? Any recommendations?

You can if you made a backup of the addon when updating.

1 Like

I’m not sure why you moved it, I’m asking about the ESP32 board itself. Either way, can you please delete your post here, it will just confuse people.

Thanks

I merged the two posts because your topics were identical. Do not create a new topic.

The Panasonic PIRs are open collector types and therefore require a pull down resistor to function properly. How large is your pull down ? Did you follow the technical specifications for the sensor in order keep the internal MOSFET drain current under 100µA ?

From the specs (emphasis mine):

The output signal for the digital output type is from inside FET drain, therefore pull-down resistors are necessary. Please select an output resistor (pull-down concept) in accor-
dance with VOUT so that the output current is maximum 100μA. If the output current is more than 100μA, this may cause false alarms.

You can use the internal ESP pulldown if the current doesn’t exceed 100µA (but you need to be sure of that). Without pulldown, or if the current is too high, you will get false alarms and/or permanently damage the sensor.

If the sensor is powered by the same power rail as the ESP, you will need two filter caps over vcc (normally a 100nF and a 100µF in parallel). The ESP is a very noisy chip in terms of EMI and it will pollute the power rail with all kinds of nasty noise.

Hey Alex,

Thanks for that, I’ve been trying to figure out what all that means LOL

I don’t come from an electronics background, so I pretty much followed guides I found, that didn’t mention any resistors.

Here is the wiring diagram I used

So what you’re saying is that I need to limit the output back to 100uA by putting in normally a 100nF and a 100µF caps in parallel?

image

Is that what that means? Can you provide a link to the caps you used?

Also

No, no, the pull down resistor and the caps are two separate things. The former is a necessary part of the way this PIR sensor (the Panasonic one) operates. The caps are to stabilize the noise created by the ESP on the power lines.

The PIR sends its output signal over what is called an open drain mosfet. That’s the symbol with the S/G/D letters on your schematic above. When the PIR triggers, a signal runs from the +3.3V into the source (S), through the mosfet, out of the drain (D) and into the out pin of the PIR. But it stops there. You need to provide a way for it to flow to ground from there, so that the circuit is closed. That’s where the resistor comes in. It ‘pulls’ the signal to the ground, hence the pull-down name. So you need a resistor from out to ground, in addition to the ESP pin. The PIR is not able to provide more than 100µA on this path, or the internal mosfet can be damaged. So the resistor needs the right size. At 3.3V and 100µA, this means that the resistor may not be smaller than 33kΩ, preferably more to give some headroom.

Now most microcontrollers, including the ESP, provide internal pull-down resistors that can be enabled or disabled. If these internal pull down resistors are at least 33kΩ, then you can use them instead of adding an external one. For that to work, the internal resistor needs to be enabled in the firmware. I don’t use ESPHome myself, so I don’t know how that works (but there’s most likely a way). But you also need to make sure (and that is very important !) that the resistor is not smaller than 33kΩ, or you will damage the PIR. I don’t know the size of the pulldowns on ESPs (I don’t use ESPs myself). A quick Google search gives this result. It says:

The values of the pull-down and pull-up resistors vary from chip-to-chip and pin-to-pin and for the ESP32 are typically in the range of Rup = 30 …​ 80 kΩ and Rdn = 17 kΩ (pull-down).

That’s not good. 17kΩ is going to generate constant false positives or worst case kill the PIR. So you will have to add an external pulldown resistor instead and make 100% sure that the internal pull down is disabled.

Next the caps. They are set in parallel to the +3.3V and the GND line. There’s an example in the PIR specs:

The reason for these is to suppress fluctuations and noise on the power lines. We call these decoupling capacitors. The ESP is a chip that generates a very large amount of wideband electrical noise (EMI). Due to inadequate noise suppression techniques in the ESP chip (because you know, cheap cheap cheap…), that noise back-propagates into the power lines and contaminates all other devices directly connected to it. The decoupling caps can absorb and short-circuit part of that noise, cleaning up the power at least to some extent.

2 Likes

Thanks for that! That info was super helpful.

I was thinking about it and decided to redesign the case, the PIR was really close to the wifi antenna on the ESP and it seems to have done the trick.

So far last night and today, not a single false positive, complete game changer

image

You can see how much it was flapping, then about 6pm I separated the PIR from the ESP, lots of improvement. Then added it to the new case and its been awesome ( the rest has been proper identifications)

So thank you for your time, really big help :slight_smile:

1 Like

hi, could you share more on where you get your guides to do this?