Can rules solve this ?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
costo
Normal user
Posts: 500
Joined: 21 Nov 2015, 15:03
Location: NL, zw-NB

Can rules solve this ?

#1 Post by costo » 12 Oct 2023, 16:22

I measure 2 currents with 2 ACS712 boards.
ADS1115 converts the outputs of the ACS712 to I2C, I also measure the 5Volt line.
In a formula I have to subtract halve of the 5Volt from the ACS712 results to get the real values/currents.

The 5Volt line has some variation which has a effect on the results/accuracy.
If I could put the 5Volt in the formula I hope to get a more accurate result.
I try %value%-(0.5*5Volt) in the formula instead of %value%-2.5 but this does not work, I hope to solve this with a rule.

Unfortunately I do not understand rules good enough to solve this problem myself.
Can anyone help me a little bit on the way with a working rules example to subtract one variable from 2 other variables?

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

Re: Can rules solve this ?

#2 Post by Ath » 12 Oct 2023, 17:28

Including the word 'Volt' in the Formula field will cause issues, using the variable for your Voltage task should help:

Code: Select all

%value%-(0.5*[Voltage#value])
NB: Better not name that task 5Volt, that'll be very confusing for the rules parser :?
/Ton (PayPal.me)

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

Re: Can rules solve this ?

#3 Post by Ath » 12 Oct 2023, 22:22

costo wrote: 12 Oct 2023, 16:22 The 5Volt line has some variation which has a effect on the results/accuracy.
That's a good start for improvement, as a proper power supply for your unit is also helpful in avoiding issues with WiFi connectivity.

costo wrote: 12 Oct 2023, 16:22 Unfortunately I do not understand rules good enough to solve this problem myself.
Can anyone help me a little bit on the way with a working rules example to subtract one variable from 2 other variables?
This paragraph in the documentation seems like a good start (though that entire (huge) page is an interesting read when starting with rules)
/Ton (PayPal.me)

User avatar
costo
Normal user
Posts: 500
Joined: 21 Nov 2015, 15:03
Location: NL, zw-NB

Re: Can rules solve this ?

#4 Post by costo » 13 Oct 2023, 11:18

Wonderfull, this simple line in the formula field solved it.
Ath wrote: 12 Oct 2023, 17:28

Code: Select all

%value%-(0.5*[Voltage#value])

User avatar
costo
Normal user
Posts: 500
Joined: 21 Nov 2015, 15:03
Location: NL, zw-NB

Re: Can rules solve this ?

#5 Post by costo » 13 Oct 2023, 11:26

Ath wrote: 12 Oct 2023, 22:22
That's a good start for improvement, as a proper power supply for your unit is also helpful in avoiding issues with WiFi connectivity.
I'm still working on that, the peak currents of the ESP8266 gives some tens of mV variation on the 5 Volt line.
I will try a big capacitor of 3300uF/10V and a microchoke in the power line to the ESP.
Probably that will suppress the influence of peak currents.

There are also some slow long time variations depending on temperature and the state of the 12V battery that is charged by a solar panel, from where the 5Volt is derived.
The formula that subtracts halve the 5Volt solves these variations for the greater part.

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

Re: Can rules solve this ?

#6 Post by TD-er » 13 Oct 2023, 12:58

Not sure if a large 3300 uF capacitor will help here.
It will more likely cause issues as it will draw a rather large current when powering on.
A discharged capacitor will act like a short circuit when initially connected to a voltage and a large capacitor will thus act like a short circuit for quite some time.

Also large capacitors cannot help filtering short-term noise signals.
For those you need a small capacitor like 100 nF, mounted as close as possible to the analog input pin.

Post Reply

Who is online

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