HC-SR501 PIR - stop false positives?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
cherowley
Normal user
Posts: 125
Joined: 14 Jan 2016, 09:39

HC-SR501 PIR - stop false positives?

#1 Post by cherowley » 14 Jan 2016, 09:45

Hiya!

I'm trying to use one of these pir sensors but keep getting false triggers every few minutes or sometimes several times per minute...

I've tried different psu, separate psu, moving the sensor away from the esp and wrapping the sensor in foil...

Anyone have any other ideas?

I'm now using a flashed commercial H801 dimmer as I hoped that would have better results being with good pcb and decoupling caps etc...

Thanks!

PS Due to all the false triggers it eventually causes domoticz to stop running on a synology box after a period of 12 -36 hours :(

rtenklooster
Normal user
Posts: 320
Joined: 15 Apr 2015, 14:17

Re: HC-SR501 PIR - stop false positives?

#2 Post by rtenklooster » 14 Jan 2016, 10:11

I also have a amount of false positives, but not that much. More like one / two a night. Because that's not acceptable to me, i have ordered radar modules, they can see trough wall's are not sensitive to heat and sun etc.

Have no idea if i get it working, but for as far as i have seen, it's quite a nice module.
http://www.ebay.com/itm/1-HB100-Microwa ... Swa39UwLcH
Image
The youtube movies i've seen are pretty impressive, detecting motion, and the quantity of motion through wall's..
The problem with pir sensors for me are the false positives, but also false negatives, i can't use them to turn of the lights in the living room, because when i'm sitting on the couch watching tv, i don't want it to shut down, the pir is in that case not sensitive enough. I hope those modules will fill the gap between false positives and negatives.

Planning on mounting one in my wooden jar, so i can see "trhough" the wall if someone enters my back garden ;)

The modules need a small op-amp circuit, so i ordered those parts as well.
Image
Richard - Groningen (NL) - Image

BerndJ
Normal user
Posts: 86
Joined: 28 Sep 2015, 06:57

Re: HC-SR501 PIR - stop false positives?

#3 Post by BerndJ » 14 Jan 2016, 11:20

Hi Richard,

if u could realize it to count the frequency then y´re be able to calculate the speed of the objekt. In this case round about max. 150 Hz.

Problem is: u don´t know it is coming or going with this speed, because the offset of the frequency to the carrier is 0.

Best solution: use two of it.

BTW: frequence counter would be very nice as module. I would like to read the speed of the exhausted fans of my pellet stoves.

What are the max. Frequence of the Pulse counter Module?, and is it possible to use this?

best wishes and thanks for your great project

Bernd

cherowley
Normal user
Posts: 125
Joined: 14 Jan 2016, 09:39

Re: HC-SR501 PIR - stop false positives?

#4 Post by cherowley » 19 Jan 2016, 16:53

Interesting stuff!

I've since managed to get the one in the ceiling light working- connected the metal of the lamp to ground..

DeNB3rt
Normal user
Posts: 120
Joined: 15 Dec 2015, 14:07

Re: HC-SR501 PIR - stop false positives?

#5 Post by DeNB3rt » 20 Jan 2016, 22:00

rtenklooster wrote:
Planning on mounting one in my wooden jar, so i can see "trhough" the wall if someone enters my back garden ;)

Can you let us know when you tested this? :)
I'm also having pir issues :roll:
Located in Belgium, Bruges. Working on a full DIY domoticz setup with ESPEasy.

DeNB3rt
Normal user
Posts: 120
Joined: 15 Dec 2015, 14:07

Re: HC-SR501 PIR - stop false positives?

#6 Post by DeNB3rt » 27 Jan 2016, 20:49

nobody tips/tricks for the SR501 and it's false positives when used as switch in esp easy?
tyyyy :)
Located in Belgium, Bruges. Working on a full DIY domoticz setup with ESPEasy.

rtenklooster
Normal user
Posts: 320
Joined: 15 Apr 2015, 14:17

Re: HC-SR501 PIR - stop false positives?

#7 Post by rtenklooster » 27 Jan 2016, 23:05

DeNB3rt wrote:
rtenklooster wrote:
Planning on mounting one in my wooden jar, so i can see "trhough" the wall if someone enters my back garden ;)

Can you let us know when you tested this? :)
I'm also having pir issues :roll:
Received the sensors today. Waiting for some parts to complete the amplifier.
DeNB3rt wrote:nobody tips/tricks for the SR501 and it's false positives when used as switch in esp easy?
tyyyy :)
Nope.
Richard - Groningen (NL) - Image

cherowley
Normal user
Posts: 125
Joined: 14 Jan 2016, 09:39

Re: HC-SR501 PIR - stop false positives?

#8 Post by cherowley » 28 Jan 2016, 11:38

Got mine working by grounding the metal of the light fitting and covering the pir sensor in foil and making sure the foil touches the metal of the light fitting.

edautz
Normal user
Posts: 13
Joined: 10 Apr 2016, 07:16

Re: HC-SR501 PIR - stop false positives?

#9 Post by edautz » 10 Apr 2016, 07:40

I faced exact the same issue.

After deploying a HC-SR501 Pir in combination with an NodeMcu 1.0 ESP8266 module, i got tons of false positives. I tried also a V3 Nodemcu ESP8266 module, same issue.

Pir directly connected to the 5v of the Nodemcu pin.

I build a webserver in the ESP8266 and programmed some code to periodically check the status of the Wifi ap and autoreset the ESP8266 if the wifi or the tcp connection to my homodomotica system is failing.

If the jumper location is on H position, mostly of the time the trigger duration of the false positives was around 2800ms. A real trigger was around 5000ms or more. I noticed a pattern of the false positives, mostly it occurs after roughy with a interval of 45 seconds.

I noticed 2 sources of evil of the false positives.
1: Power supply interference, I tried 5 different usb adapters ranging from 500mA to 2A. I run now stable on a 500mA USB power from Ebay.
2: Rf interference. Wifi is 2,4 Ghz ( in my case) RF. I tried two different HC-SR501 and both were triggerd bij RF.

I tried also shielding. In my case it didn't help. My pir is only 5 cm away from the ESP.


I solved this with the next solutions:
A: Used a 47uF and 102pF power decompling consensator soldered over the pir power connections at the ESP8266 side.
B: Put the ESP in 802.11G mode instead of 802.11N mode. I think the Rf spectrum will be less in G mode.
C: Put the ESP in wifi STA mode only.
D: Lower the ESP wifi output power to 10dBm.

I noticed I had to apply ALL the countermeasures together to mitigate the false positives.
Last edited by edautz on 19 Apr 2016, 22:18, edited 1 time in total.

DeNB3rt
Normal user
Posts: 120
Joined: 15 Dec 2015, 14:07

Re: HC-SR501 PIR - stop false positives?

#10 Post by DeNB3rt » 10 Apr 2016, 11:49

:shock: wow nice one :-)
how 'stable' is it now?

@rtenklooster, did you test with the HB100 sensor?
Located in Belgium, Bruges. Working on a full DIY domoticz setup with ESPEasy.

edautz
Normal user
Posts: 13
Joined: 10 Apr 2016, 07:16

Re: HC-SR501 PIR - stop false positives?

#11 Post by edautz » 11 Apr 2016, 00:12

Right now. I am running two days stable with the Nodemcu 1.0 Pir setup. On the Nodemcu V3 I had to lower the output level to 8. Running one day stable now.

Fingers crossed.

5ko
Normal user
Posts: 33
Joined: 03 Jan 2016, 17:58
Contact:

Re: HC-SR501 PIR - stop false positives?

#12 Post by 5ko » 11 Apr 2016, 19:03

B: Put the ESP in 802.11G mode instead of 802.11N mode. I think the Rf spectrum will be less in G mode.
C: Put the ESP in wifi STA mode only.
D: Lower the ESP wifi output power to 10dBm.
Where these settings?
Thanks

edautz
Normal user
Posts: 13
Joined: 10 Apr 2016, 07:16

Re: HC-SR501 PIR - stop false positives?

#13 Post by edautz » 12 Apr 2016, 22:12

I use the Arduino IDE 1.6.8 with board manager v 2.0.0 to program the ESP8266

Using the following commands to set the requested wifi settings:

wifi_set_phy_mode(PHY_MODE_11G);
system_phy_set_max_tpw(powervalue max 82); divide by 4 for dBm value
WiFi.mode(WIFI_STA);
Last edited by edautz on 25 Apr 2016, 21:32, edited 1 time in total.

DeNB3rt
Normal user
Posts: 120
Joined: 15 Dec 2015, 14:07

Re: HC-SR501 PIR - stop false positives?

#14 Post by DeNB3rt » 13 Apr 2016, 10:38

great sir!
Located in Belgium, Bruges. Working on a full DIY domoticz setup with ESPEasy.

5ko
Normal user
Posts: 33
Joined: 03 Jan 2016, 17:58
Contact:

Re: HC-SR501 PIR - stop false positives?

#15 Post by 5ko » 13 Apr 2016, 15:45

I use the Arduino IDE 1.6.8 with board manager v 2.0.0 to program the ESP8266

Using the following commands to set the requested wifi settings:

wifi_set_phy_mode(PHY_MODE_11G);
system_phy_set_max_tpw(powervalue max 20.5);
WiFi.mode(WIFI_STA);
Thanks :)
It's just that I have used for encryption 2.1.0 not 2.0.0 ... I guess not a condition ... could this be included in the feature wish list, because this need already heard several times in the forum and in terms of RF / EMI / interference / stability would be interestingly in the testing phase and later ...

edautz
Normal user
Posts: 13
Joined: 10 Apr 2016, 07:16

Re: HC-SR501 PIR - stop false positives?

#16 Post by edautz » 13 Apr 2016, 16:54

The first two commands come from the SDK as part of 2.0.0.
I guess all those commands are also present in the new 2.1.0 version of the board manager.

I have first to solve a base64 issue of 2.1.0. After fixing that I also switch to version 2.1.0 or 2.2.x. Whatever is available.

5ko
Normal user
Posts: 33
Joined: 03 Jan 2016, 17:58
Contact:

Re: HC-SR501 PIR - stop false positives?

#17 Post by 5ko » 13 Apr 2016, 19:34

Thanks for the prompt reply. I hope that you will succeed in doing so. I have the experience that high output RF emissions very often tends to be a big problem and can affect the selectivity of the receiving part, especially if ESP is not far from the AP or other devices or when the crowd in the air with a lot of devices that emit in the same RF spectrum ... Many times help was to reduce the output RF stage ....

edautz
Normal user
Posts: 13
Joined: 10 Apr 2016, 07:16

Re: HC-SR501 PIR - stop false positives?

#18 Post by edautz » 15 Apr 2016, 15:02

Due the fact i faced watchdog reboots (approx one a day).

I upgraded one of my PIR ESP8266 sensors to 2.1.0 board package. I had to remove the base64 files of this package and use another base64 library to solve my base64 problem.

The SDK is also upgraded from 1.3.0 to 1.5.1 with this new package.

Now the use of the SDK commands can be omitted and replaced by:

WiFi.setPhyMode(WIFI_PHY_MODE_11G);
WiFi.setOutputPower(value);

edautz
Normal user
Posts: 13
Joined: 10 Apr 2016, 07:16

Re: HC-SR501 PIR - stop false positives?

#19 Post by edautz » 24 Apr 2016, 19:37

Update after trying board manager 2.1.0 with SDK 1.5.1 and boardmanger 2.2.0 with SDK 1.5.2.

I noticed several things: Boardmanager 2.1.0 and 2.2.0 based sketched are producing false positives. Even with a Wifi power setting of 0dBm the ESP8266 is transmitting normally and still getting false positives.

I cannot measure the wifi output, but I guess there is a bug in the SDK above 1.3 or in the boardmanager above 2.0.0 so the transmit power is not reduced anymore.

I tried two NodeMCU 1.0 (Amica) ESP12E boards with board manager 2.0.0 and a powersetting of 10dBM and they proving to be stable without false positives. One now running for 10 days without false positives. Other recieved yesterday and running 24 hours now.

However a NodeMCU V3 ( Lolin) ESP12E board with the same sketch will also produce false positives. I think maybe a problem with the powerregulator on the Lolin board .

EDIT. My assumption that 0dBm means no power at all is not correct.
https://en.m.wikipedia.org/wiki/DBm.
And I discovered that when using the system_phy_set_max_tpw(val) command the value needs to be divided by 4 to get the actual dBm value while using the WiFi.setOutputPower(float dBm) command you use the actual dBm value. So in practice I tested a working situation with a value of 2,5 dBm. I will retest with a nodemcu 1.0 board with a dBm setting of 2,5 with the latest boardmanager.

edautz
Normal user
Posts: 13
Joined: 10 Apr 2016, 07:16

Re: HC-SR501 PIR - stop false positives?

#20 Post by edautz » 27 Apr 2016, 23:44

When using 2.1.0 or 2.2.0 compiled sketches I still got lots of false positives on my Nodemcu 1.0 board.

I raised an issue on the esp8266 aruino github. There comes sugesstions to used a new SDK 1.5.3. in combination with 2.2.0, but before take that effort:

I found some software that supports displaying the dBm levels of other wifi stations on my laptop. But my build-in wifi card of the laptop is not compatible. I orderred a wifi usb reciever who should support the display of the recieved dBm levels.

With this tool I can determine if the powerlevels in 2.1.0 and 2.2.0 cannot be modified or there another source of interference is.

UPDATE 8-5-2016: I managed to measure the wifi output levels and noticed that the Wifi output levels decreased when using the SDK command system_phy_set_max_tpw(val). I didn't test the WiFi.setOutputPower(val) command to avoid the chance that there are bugs in this code. But even with a outputlevel of 0dBm and using a Nodemcu 1.0 board I still get false positives. Approx 1/hour.

So there must be another source of interference. After studing the SDK I put SDK commands in my sketch to turn of all the unused wifi functions, but this doesn't resolve the problem. I supect that the interference maybe is caused by a raised wifi powerlevel at a retransmit of the ip packets, but cannot measure that.

I reverted my setup to 2.0.0 and using a two unit Esp8266 pir setup with a powerlevel of 2dBM, without any false positives for about two weeks.

the cosmic gate
Normal user
Posts: 102
Joined: 14 Nov 2015, 20:17

Re: HC-SR501 PIR - stop false positives?

#21 Post by the cosmic gate » 07 Jun 2016, 12:39

I've got also issues : http://www.esp8266.nu/forum/viewtopic.php?f=5&t=1628 , are these the same as discribed in this topic ?

edautz
Normal user
Posts: 13
Joined: 10 Apr 2016, 07:16

Re: HC-SR501 PIR - stop false positives?

#22 Post by edautz » 30 Jul 2016, 08:28

Sorry for the late respons, but it seems the same problem.

I am running stable for a few months now, using pir as an alarm sensor.

I upgraded my powersupply to 1 amp type. I also notices when the pir is exposed to the sun, sudden changes in sunlight triggers the pir. I am not able to solve that, you can only solve this in software.

the cosmic gate
Normal user
Posts: 102
Joined: 14 Nov 2015, 20:17

Re: HC-SR501 PIR - stop false positives?

#23 Post by the cosmic gate » 03 Aug 2016, 12:23

edautz wrote:Sorry for the late respons, but it seems the same problem.

I am running stable for a few months now, using pir as an alarm sensor.

I upgraded my powersupply to 1 amp type. I also notices when the pir is exposed to the sun, sudden changes in sunlight triggers the pir. I am not able to solve that, you can only solve this in software.
The pir I used is build in a lamp using the sonoff piece of hardware (and power) so sunlight wouldn't be a problem :)

chunter1
Normal user
Posts: 82
Joined: 22 Jan 2016, 22:40

Re: HC-SR501 PIR - stop false positives?

#24 Post by chunter1 » 06 Mar 2017, 09:31

Although this is an old thread - i guess some people might still be interested how to definately solfe the RF-induced false triggering problem.

You simple need to solder a 220nF ceramic capacitor across pin12 und pin13 of the chip (BISS0001) so that the high-frequency interference coming from the ESP8266 don't influece the gain stage anymore.

That's it!
Have fun! ;)

DeNB3rt
Normal user
Posts: 120
Joined: 15 Dec 2015, 14:07

Re: HC-SR501 PIR - stop false positives?

#25 Post by DeNB3rt » 06 Mar 2017, 15:47

chunter1 wrote: 06 Mar 2017, 09:31 Although this is an old thread - i guess some people might still be interested how to definately solfe the RF-induced false triggering problem.

You simple need to solder a 220nF ceramic capacitor across pin12 und pin13 of the chip (BISS0001) so that the high-frequency interference coming from the ESP8266 don't influece the gain stage anymore.
How long do you have this running without issues? Thanks for the tip!
Located in Belgium, Bruges. Working on a full DIY domoticz setup with ESPEasy.

bobbybeans
Normal user
Posts: 119
Joined: 26 Feb 2017, 17:30

Re: HC-SR501 PIR - stop false positives?

#26 Post by bobbybeans » 15 Mar 2017, 15:18

DeNB3rt wrote: 06 Mar 2017, 15:47
chunter1 wrote: 06 Mar 2017, 09:31 Although this is an old thread - i guess some people might still be interested how to definately solfe the RF-induced false triggering problem.

You simple need to solder a 220nF ceramic capacitor across pin12 und pin13 of the chip (BISS0001) so that the high-frequency interference coming from the ESP8266 don't influece the gain stage anymore.
How long do you have this running without issues? Thanks for the tip!

this is great shall be ordering some now :)

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: HC-SR501 PIR - stop false positives?

#27 Post by Shardan » 15 Mar 2017, 15:46

chunter1 wrote: 06 Mar 2017, 09:31 Although this is an old thread - i guess some people might still be interested how to definately solfe the RF-induced false triggering problem.

You simple need to solder a 220nF ceramic capacitor across pin12 und pin13 of the chip (BISS0001) so that the high-frequency interference coming from the ESP8266 don't influece the gain stage anymore.

That's it!
Have fun! ;)
Great, thanks.

Just an idea - there should be a "Solutions" category in the wiki or the forum and such solutions should be collected there.
Maybe within a more or les fixed scheme of "Issue" (Symptoms shown), "Analyse" (What causes the issue) and "Solution".
I'd be happy to help with that.
Regards
Shardan

chunter1
Normal user
Posts: 82
Joined: 22 Jan 2016, 22:40

Re: HC-SR501 PIR - stop false positives?

#28 Post by chunter1 » 02 May 2017, 12:40

Unfortunately, when sunlight is shining on the sensor, it still triggers permanently.

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: HC-SR501 PIR - stop false positives?

#29 Post by toffel969 » 03 May 2017, 00:47

chunter1 wrote: 02 May 2017, 12:40 Unfortunately, when sunlight is shining on the sensor, it still triggers permanently.
In think this is immanent to PIR type devices (passive infrared) . if the ir intensity changes it will trigger.
Leaves it too indoor use case or if you only want to use it when its dark...
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

chunter1
Normal user
Posts: 82
Joined: 22 Jan 2016, 22:40

Re: HC-SR501 PIR - stop false positives?

#30 Post by chunter1 » 06 May 2017, 00:13

toffel969 wrote: 03 May 2017, 00:47
chunter1 wrote: 02 May 2017, 12:40 Unfortunately, when sunlight is shining on the sensor, it still triggers permanently.
In think this is immanent to PIR type devices (passive infrared) . if the ir intensity changes it will trigger.
Leaves it too indoor use case or if you only want to use it when its dark...
To me it seems more like bad design and some kind of saturation effect since other PIR sensors don't false trigger under sunlight.

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: HC-SR501 PIR - stop false positives?

#31 Post by toffel969 » 06 May 2017, 12:42

chunter1 wrote: 06 May 2017, 00:13
toffel969 wrote: 03 May 2017, 00:47
chunter1 wrote: 02 May 2017, 12:40 Unfortunately, when sunlight is shining on the sensor, it still triggers permanently.
In think this is immanent to PIR type devices (passive infrared) . if the ir intensity changes it will trigger.
Leaves it too indoor use case or if you only want to use it when its dark...
To me it seems more like bad design and some kind of saturation effect since other PIR sensors don't false trigger under sunlight.
To me it seems like good design can avoid the triggering through light. However the PIR sensor itself just triggers on differences in the infrared lighting level. The sun undoubtedly is an IR-Source (so was the barbecue fire on my terasse that kept on triggering my PIR). Be it as it may, I don't see how this can be avoided other than buying different PIR that have measures to mitigate the effect we can change this. It is definitly not the same problem that causes the random triggering
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: HC-SR501 PIR - stop false positives?

#32 Post by Shardan » 06 May 2017, 15:28

Hello all,

some weeks agon i've designed a clean PCB layout for the HC-SR501 and some more sensors,
(HC-SR04 ultrasonic distance, door contact and humidity + temperature)
I want to use it as a server room surveillance device.
The prototype PCB's arrived some days ago and one device was assembled some days ago.
.
USIR-Sensor Frontside.jpg
USIR-Sensor Frontside.jpg (84.1 KiB) Viewed 70384 times
.
USIR-Sensor-Backside.jpg
USIR-Sensor-Backside.jpg (46.26 KiB) Viewed 70384 times
.
And a miracle happened......

There is no pull up resistor or capacitor added to the circuits.
It's test running for a week now and did not give false positives up to now.

For my curiosity i tested two other PIR's. A mini sensor and a
bigger one for 230VAC mains. The small one works similliar to the HC-SR501,
but it can't be adjusted on runtime and sensivity, but works.
The bigger one works too but is made for placing in the ceiling, not suitable for ESP-circuits.
.
DSCF0139cut.JPG
DSCF0139cut.JPG (101.87 KiB) Viewed 70384 times
.
As far as a can say atm all three show false positives with direct sunlight.
I agree with toffel that the sun is a massive IR source. The outside sensors i know
are made for lighting. They have an additional daylight sensor and switch off over the day.
Even the cheap 230V sensor i tested is able to deactivate over daylight time.
We use PIR's for the alarm system in our company. They are not allowed to be placed
in direct sunlight due to possible false positives.
There might be PIRs that are compensated against sunlight. Hoenstly i've never
seen one or could test one. I doubt if you can get it for a dollar at your dealer anyways :)

Regards
Shardan
Regards
Shardan

chunter1
Normal user
Posts: 82
Joined: 22 Jan 2016, 22:40

Re: HC-SR501 PIR - stop false positives?

#33 Post by chunter1 » 24 May 2017, 15:38

@Shardan
You should have spent your antenna keep-out region a bit more size - except ruining the RF performance was intended :D
At least it might help avoiding false triggering by RF.

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: HC-SR501 PIR - stop false positives?

#34 Post by Shardan » 24 May 2017, 16:49

Intrestingly i just used a ready made footprint for the ESP-12/E/F from my layout program...
and this is one of the strongest signals i get even on distance through walls.

Don't ask me why - high frequencies have their very own rules.
Regards
Shardan

JohnJoe
New user
Posts: 1
Joined: 23 Jul 2017, 14:56

Re: HC-SR501 PIR - stop false positives?

#35 Post by JohnJoe » 23 Jul 2017, 14:58

The solution I found to this problem is use a 10k resistor between the PIR sensor output and the input pin of the ESP8266.

I tried all of the suggestions above (caps, switching off the wifi etc) but only the resistor worked.

Another benefit is that Wifi can now be connected at the start (and disconnected at the end) of the program rather than for each message, as this can be slow.

Not sure if 10K is the best value, someone else may find a better value, but for now, for me its working great.

John

DeNB3rt
Normal user
Posts: 120
Joined: 15 Dec 2015, 14:07

Re: HC-SR501 PIR - stop false positives?

#36 Post by DeNB3rt » 26 Jul 2017, 09:07

JohnJoe wrote: 23 Jul 2017, 14:58 The solution I found to this problem is use a 10k resistor between the PIR sensor output and the input pin of the ESP8266.
Hi JohnJoe, 10k to ground?
I have positive experience with that.
Combined with keeping direct sunlight away from the sensor. :)
Located in Belgium, Bruges. Working on a full DIY domoticz setup with ESPEasy.

User avatar
rajbadri
Normal user
Posts: 56
Joined: 21 Dec 2015, 21:38
Location: India

Re: HC-SR501 PIR - stop false positives?

#37 Post by rajbadri » 30 Jul 2017, 06:23

chunter1 wrote: 06 Mar 2017, 09:31 Although this is an old thread - i guess some people might still be interested how to definately solfe the RF-induced false triggering problem.

You simple need to solder a 220nF ceramic capacitor across pin12 und pin13 of the chip (BISS0001) so that the high-frequency interference coming from the ESP8266 don't influece the gain stage anymore.

That's it!
Have fun! ;)
This Tip Solved my Problem. Thanks

riker1
Normal user
Posts: 344
Joined: 26 Dec 2017, 18:02

Re: HC-SR501 PIR - stop false positives?

#38 Post by riker1 » 24 Mar 2018, 10:15

Hi
could you paste a picture of the soldering solution? thanks

fmuntean
New user
Posts: 6
Joined: 24 Apr 2018, 02:04

Re: HC-SR501 PIR - stop false positives?

#39 Post by fmuntean » 24 Apr 2018, 02:49

I have been having the same issue with the false positives given by the HC-SR501 PIR sensor board.
I have searched and tried almost everything I could find about fixing this issue but nothing helped.

I know that my post is long but I like to describe the reasoning behind the changes and not just give people a short solution. if you look for that stop here and just try to solder a wire across the 18K resistor that is on top of the sensitivity potentiometer. Also make sure you let us know if it worked for you.


Then I start learning how it works and found this AN4368 Application note from ST (http://www.st.com/resource/en/applicati ... 096551.pdf) This helped me understand how any PIR circuit should work.
The two BISS0001 datasheets I found useful are: https://www.mpja.com/download/31227sc.pdf and https://cdn-learn.adafruit.com/assets/a ... SS0001.pdf

Maybe somebody that knows more can correct me if I am wrong here but my understanding is as follow:
When moving in front of the sensor because of the two windows the signal should go low then high or high then low these two peaks should count as a single movement.

There is not much info about the BISS001 IC but found that I could tap at both the Vout1 and Vout2 aka the two stages of the analog side of the circuit.
So I got the signal from the stage2 out pin 12 and created my own simple circuit using two comparators so I can see the output signal.(this is just trying to mimic their circuit inside the IC)
What this BISS001 IC is doing based on the schematics is that uses the two comparators and an OR logic to transform the small negative and positive peaks into digital peaks and enable the output when detecting such peaks. Now even if they would count every two peaks as one still there is no way to differentiate between the one negative and one positive or two positive peaks thus noise on the positive side could introduce more positive peaks and trigger the output with no negative peaks present.

The datasheet shows the VH=0.7VDD and VL=0.3VDD So using 10x 4K7 resistors in series between 3.3V and ground I have created my own reference ladder for the comparators and used 2 LEDs to see the output signal (actually hookup an old oscilloscope too on the input to my comparator to see the raw signal too).

This is what I found: It seems that the VH is not really 0.7VDD but more toward 0.6VDD thus triggering much easier. (positive noise could make it trigger much easier).
With this circuit I found that there is a lot of noise on the positive side of the comparator (that LED blinks much more even when not moving and seems to be correlated as many people pointed out with the ESP8266 WiFi activity).
If the BISS001 would have more logic inside to look for both peaks negative and positive and account them as a single peak then this IC would have been immune to the noise on the positive side.
From experimenting for few hours with it found that the negative peak had much less noise so I start comparing the different schematics I could find on the internet and using the App Note mentioned above calculated Gain and filter frequencies for the first stage. After redrawing the diagram I found that there is a 18K resistor between the PIR sensor and the input1 (hmm some schematics use it others are not).
So I thought why attenuating the signal before the amplifier ?And I said to myself if I can raise the signal level up I could make the system think that there are no positive peaks and I could trick the BISS0001 to only count the negative peaks and did solder a wire across the 18K resistor. The signal level raised slightly and became less noisy (now I would love to have a better DSO oscilloscope to actually capture the signal, with my analog scope I could only see the signal live) system started to behave better and the LED on the high side even at 0.6VDD will not trigger anymore even when moving in front of the sensor while the low side would still trigger when moving my hand in front.

It would be good if somebody with more experience and better equipment can reproduce this experiment and get better measurements or simply explain to me that I am doing something wrong.


PS: In the end I am not really sure if the BISS001 has an OR GATE or an AND GATE to combine the comparators signals. From my experiments seems that is an AND GATE.

riker1
Normal user
Posts: 344
Joined: 26 Dec 2017, 18:02

Re: HC-SR501 PIR - stop false positives?

#40 Post by riker1 » 24 Apr 2018, 07:25

edautz wrote: 10 Apr 2016, 07:40 ----
I solved this with the next solutions:
A: Used a 47uF and 102pF power decompling consensator soldered over the pir power connections at the ESP8266 side.
B: Put the ESP in 802.11G mode instead of 802.11N mode. I think the Rf spectrum will be less in G mode.
C: Put the ESP in wifi STA mode only.
D: Lower the ESP wifi output power to 10dBm.

I noticed I had to apply ALL the countermeasures together to mitigate the false positives.
Hi
having the same problem.
soldered a capacitator on the pir pin 12-13

could you show a picture for your solution A.

how and where did you set solution for B,C,D?

Thanks Thomas

edautz
Normal user
Posts: 13
Joined: 10 Apr 2016, 07:16

Re: HC-SR501 PIR - stop false positives?

#41 Post by edautz » 24 Apr 2018, 21:08

Hallo riker1,

I don't have a picture for solution A, but if you use a nodemcu or another board with a esp8266 installed, soldering the two capacitors on the ESP8266 board to stabilize the power of the pir shouldn't be a problem.

I program my ESP8266/ESP32's from scratch, not using EASYESP or other code.

Solution B has proven to have no effect, so you can use WIFI in 802.11G mode.

Solution C & D if you van program the ESP yourself.

My snippets of code to accomplish this:

Using board manager 2.0.0/higher version and a ESP8266 board:

Enabling low level SDK commands (for boardmanager 2.0.0):

extern "C" {
#include "user_interface.h"

}

wifi_set_phy_mode(PHY_MODE_11G); // SDK command boardmanager 2.0.0 enables WIFI 802.11G mode.
// WiFi.setPhyMode(PHY_MODE_11G); // Command boardmanager > 2.0.0 (tested 2.2.0) same as above.
system_phy_set_max_tpw(value); // // SDK boardmanager 2.0.0 Value max 81 (dB = value/4) max Wifi send power.
// WiFi.setOutputPower(wifioutputvermogen);// Command boardmanager > 2.0.0 Value max 81 (dB = value/4) (tested 2.2.0) same as above.
WiFi.mode(WIFI_STA); // Force ESP in STA(tion) only mode.
WiFi.begin(ssid, password);

The are new board manager out, but I didn't use them, perhaps in the future.

After appling those measuresI noticed still false positives, but far less :

Direct expose to bright sunlight will trigger false alarm, solved to install 2 pir on different places, but working together, triggering alarm at daytime when triggerd together two times in short time. No problem at night, that they work indepently.

Sometimes the pir's produce a series of false positives, all with a pulse time <2800 ms. Those pulses filtered out in the ESP code.
After powerup the ESP with Pir, sometimes a false positive occur, In code suppressed the pir output for 30 seconds.


After all this measures I got 1 a 2 false alarms for my system in a year. Alarm is activated every night and when we are not at home.

Hope this helps,

Kind regards,

Edautz

riker1
Normal user
Posts: 344
Joined: 26 Dec 2017, 18:02

Re: HC-SR501 PIR - stop false positives?

#42 Post by riker1 » 25 Apr 2018, 07:24

Hi Edautz,

thanks.

A: Used a 47uF and 102pF power decompling consensator soldered over the pir power connections at the ESP8266 side.
which pins did you use? I am not an expert so?

Thanks Thomas

edautz
Normal user
Posts: 13
Joined: 10 Apr 2016, 07:16

Re: HC-SR501 PIR - stop false positives?

#43 Post by edautz » 25 Apr 2018, 15:51

If you look to this picture:

https://www.elektor.nl/nodemcu-microcon ... gI0hvD_BwE

(assuming you use a nodemcu 1.0 ESP8266 board) You see Vin and GND pin. Vin is also 5V.

You can solder both capacitors to this pins. Be aware of the polarisation of the electrolytic capacitor.

Then connect the HC-SR501 power pins to this pins on the ESP board.

riker1
Normal user
Posts: 344
Joined: 26 Dec 2017, 18:02

Re: HC-SR501 PIR - stop false positives?

#44 Post by riker1 » 25 Apr 2018, 16:45

ok, thanks
will try

olleman
Normal user
Posts: 53
Joined: 27 Aug 2017, 08:10

Re: HC-SR501 PIR - stop false positives?

#45 Post by olleman » 16 Aug 2018, 16:20

I'm having big problems with my PIR sensors as well - to the extent that they aren't really usable. Is there a working solution that actually works? I'd like to continue using ESPEasy so programing the 8266 by myself isn't really a solution for me.

Andre BUHART
New user
Posts: 3
Joined: 04 Nov 2018, 18:41

Re: HC-SR501 PIR - stop false positives?

#46 Post by Andre BUHART » 04 Nov 2018, 19:00

One solution I have tested with success is to put a ferrite core close to the PIR sensor. When the ESPeasy is too close (few cm) from the PIR, the WIFI HF is detected and generates false positives. Power and signal cables act as HF antenna.
IMG_20181104_183249.jpg
IMG_20181104_183249.jpg (25.62 KiB) Viewed 64360 times
Pass the 2 power cables and the PIR signal cable through the ferrite. If you can, you can make additional turns to improve the efficiency.
You can buy cheap ferrite core on Ebay.

Regards

André

Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

Re: HC-SR501 PIR - stop false positives?

#47 Post by Domosapiens » 04 Nov 2018, 19:51

André,
do you have a triple-screen presentation for this?
Regards
Domosapiens
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

rvdhorst
New user
Posts: 1
Joined: 16 Jun 2019, 19:39

Re: HC-SR501 PIR - stop false positives?

#48 Post by rvdhorst » 16 Jun 2019, 19:42

edautz wrote: 12 Apr 2016, 22:12 I use the Arduino IDE 1.6.8 with board manager v 2.0.0 to program the ESP8266

Using the following commands to set the requested wifi settings:

wifi_set_phy_mode(PHY_MODE_11G);
system_phy_set_max_tpw(powervalue max 82); divide by 4 for dBm value
WiFi.mode(WIFI_STA);
This helped me with the SR505 on my ESP-01s from getting false positives! Tx!

Post Reply

Who is online

Users browsing this forum: No registered users and 32 guests