GPIO read float switch fluctuations during transition

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
tgear
Normal user
Posts: 4
Joined: 30 Aug 2019, 09:24

GPIO read float switch fluctuations during transition

#1 Post by tgear » 30 Aug 2019, 09:33

Hi!

I have built a simple water tank level notification project using 4 water float switches.
Also, when the level is low it turns off my water pump so the automatic watering stops and I can water manually whatever has the most needs.

My problem is that as the water is not still, the float switch sends open/close very frequently during the transition of the water level (you can see below).

I want to verify 3 readings of the same state with a 30" second delay between the readings and then send the reading to domoticz.
Is it possible?

Thank you!
2019-08-29 08:06:09 Off
2019-08-29 08:06:01 On
2019-08-29 08:05:37 Off
2019-08-29 08:05:27 Off
2019-08-29 08:05:27 On
2019-08-29 08:05:20 On
2019-08-29 08:05:01 Off
2019-08-29 08:04:46 On
2019-08-29 08:04:43 Off

User avatar
grovkillen
Core team member
Posts: 3262
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: GPIO read float switch fluctuations during transition

#2 Post by grovkillen » 30 Aug 2019, 11:45

Yep using rules you may create a filter function. Read more here:
https://espeasy.readthedocs.io/en/lates ... Rules.html
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

tgear
Normal user
Posts: 4
Joined: 30 Aug 2019, 09:24

Re: GPIO read float switch fluctuations during transition

#3 Post by tgear » 18 Sep 2019, 11:50

Hi again!

I started trying to implement it through rules as you suggested.

I have set Data Acquisition Interval: 30 seconds
So each VAR will have the state value with 30 seconds delay right?

On level90#state Do
Let,4,[VAR#903]
Let,3,[VAR#902]
Let,2,[VAR#901]
Let,1,[state#Value]
if [VAR#901]=[VAR#902] and [VAR#902]=[VAR#903]
TaskValueSet,5,4,[VAR#901]
endif
EndOn



So the Dummy device 5 value 4 will only be set to current state if the last three states for the last 1:30 minute are equal.
If the last three states are not the same will not change.

Is the above right?
You could add it to the example page of the wiki!
Thank you,
Theodoros

User avatar
grovkillen
Core team member
Posts: 3262
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: GPIO read float switch fluctuations during transition

#4 Post by grovkillen » 18 Sep 2019, 13:12

You shouldn't use custom variables (i.e. 901...). Only 1..16 is allowed.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

tgear
Normal user
Posts: 4
Joined: 30 Aug 2019, 09:24

Re: GPIO read float switch fluctuations during transition

#5 Post by tgear » 18 Sep 2019, 15:29

Ok so I have the following rules set.

Does it look OK?
The Data Acquisition Interval does it override state change?
So if it's set to 30 seconds and i toggle manually the gpio input to open/close does it ignore my input and only counts the every 30 seconds state?

Code: Select all

On level90#state Do
 Let,3,[VAR#2]
 Let,2,[VAR#1]
 Let,1,[level90#state]
if [VAR#1]=[VAR#2] and [VAR#2]=[VAR#3] 
   TaskValueSet,5,4,[VAR#1]
endif
EndOn

On level60#state Do
 Let,6,[VAR#5]
 Let,5,[VAR#4]
 Let,4,[level60#state]
if [VAR#4]=[VAR#5] and [VAR#5]=[VAR#6] 
   TaskValueSet,5,3,[VAR#4]
endif
EndOn

On level40#state Do
 Let,9,[VAR#8]
 Let,8,[VAR#7]
 Let,7,[level40#state]
if [VAR#7]=[VAR#8] and [VAR#8]=[VAR#9] 
   TaskValueSet,5,2,[VAR#7]
endif
EndOn

On level20#state Do
 Let,12,[VAR#11]
 Let,11,[VAR#10]
 Let,10,[level20#state]
if [VAR#10]=[VAR#11] and [VAR#11]=[VAR#12] 
   TaskValueSet,5,1,[VAR#10]
endif
EndOn

User avatar
grovkillen
Core team member
Posts: 3262
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: GPIO read float switch fluctuations during transition

#6 Post by grovkillen » 18 Sep 2019, 16:23

I'm not entirely sure what you want to do but;

TaskValueSet only sets the value.
TaskValueSetAndRun will set and execute the task = if a controller has been set in the task settings it will report to that controller.
A switch plugin will report as soon as a change has been detected, but it's also possible to have it report on given intervals. In that case it will report on change + on interval.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

tgear
Normal user
Posts: 4
Joined: 30 Aug 2019, 09:24

Re: GPIO read float switch fluctuations during transition

#7 Post by tgear » 18 Sep 2019, 21:09

grovkillen wrote:
18 Sep 2019, 16:23
I'm not entirely sure what you want to do but;

TaskValueSet only sets the value.
TaskValueSetAndRun will set and execute the task = if a controller has been set in the task settings it will report to that controller.
A switch plugin will report as soon as a change has been detected, but it's also possible to have it report on given intervals. In that case it will report on change + on interval.
I want to report to controller only if the state remains the same for 1-2 minutes.
I could use a timer which I don't know how, or use data acquisition interval.

If you have another suggestion I would be grateful!

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests