Multiple average readings from sensors

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
manubis_sanchez
New user
Posts: 9
Joined: 02 Feb 2020, 15:32

Multiple average readings from sensors

#1 Post by manubis_sanchez » 19 Jul 2021, 17:47

Hello,

I found this page to do an average with one of my sensors with the rules feature. It works great.
However, I would like to do the same for 2 more of my sensors on the same ESP. I tried to create a new rule but the target value of the first rule is affected by the second rule.

Code: Select all

On Temp#Temperature Do
 Let,10,[VAR#9]
[...]
 Let,2,[VAR#1]
 Let,1,[Temp#Temperature]
 TaskValueSet,9,1,([VAR#1]+[VAR#2]+[VAR#3]+[VAR#4]+[VAR#5]+[VAR#6]+[VAR#7]+[VAR#8]+[VAR#9]+[VAR#10])/10
EndOn

Code: Select all

On pH#ph Do
 Let,10,[VAR#9]
[...]
 Let,2,[VAR#1]
 Let,1,[pH#ph]
 TaskValueSet,10,1,([VAR#1]+[VAR#2]+[VAR#3]+[VAR#4]+[VAR#5]+[VAR#6]+[VAR#7]+[VAR#8]+[VAR#9]+[VAR#10])/10
EndOn
I tried to replace VAR by PH to test but it does'nt work. I think I did not understand the lines of the system of variables (Let,x,[VAR#y]).

Someone can help me, please ?

Thanks.

Edit : I found how it works ! We only have 16 variables so for my 3 sensors I can just use 5 var MAX if I understand well.
Do you confirm we can't make for loop to incremente juste one variable ?

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Multiple average readings from sensors

#2 Post by Ath » 19 Jul 2021, 19:25

On a current build (2021-02 and newer IIRC) you can have [var#x] until memory runs out, so adding 10 to all the numerics in the second rule should fix that.
/Ton (PayPal.me)

manubis_sanchez
New user
Posts: 9
Joined: 02 Feb 2020, 15:32

Re: Multiple average readings from sensors

#3 Post by manubis_sanchez » 19 Jul 2021, 19:57

That's good to know ! Thank you.
My ESP8266 has rebooted several times, I think I ask it too much :s
I will work on that to find a good balance between precision of the values and load of the ESP.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Multiple average readings from sensors

#4 Post by TD-er » 19 Jul 2021, 19:57

Do you call "event" from your rules? Or "delay" ???

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 28 guests