I use a digital pressure sensor in my irrigation system. Unfortunately, its measurement results are not linear. I have to adjust the values mathematically. I can't get any further with the "range node". Is there maybe another node that I could use.
The problem, the correction factors are not linear either. In the list you can see the comparison series of measurements.
The red values are at the input of the node. The green values should then be output at the output.
You can work with a normal function node and put in a switch case function, but this makes maybe only sense, if that are all values:
var value = msg.payload;
switch (value) {
case (0):
value = 0.6;
break;
case (0.6):
value = 2.69;
break;
case (1):
value = 2.83;
break;
…
default:
return null; // or errorhandling
break;
}
If you do not want to work with a function node you can use a switch function to differentiate and change function to change the value, but this means more effort.
Hello,
thank you very much first of all. A good approach.
I explained that badly. The correction should be made in one area. e.g. 0 - 2.3 = 0 or 2.4 - 2.7 = 0.6 etc.
My digital sensor is showing values that are too high.
If I have understood that correctly, an area should be defined in the function node. Is that possible and what about the syntax?
I wanted to set the accuracy in 0.4 steps. It doesn't have to be so accurate, as I only evaluate the pressure as a security. If the pressure falls below a certain value, the pump should be switched off.
If it doesn't need to be extremely accurate what problem did you have with the Range node? This should do what you want
So an input of 2.3 or below will give you 0, an input of 6.18 or above will give 6.2, and it will be scaled linearly in between. That gives a max error of 0.17 in the output compared to the table.
I can't get this thing to work Sorry I'm missing something.
I have two Incjet.Nodes at the entrance with 1 and 2.5. The node is currently doing nothing. It comes out 1 or 2.5 at the end.
The fault is definitely mine.
Why don't you like the range node technique, which will give you the correct value which you can then easily compare with your limit? Also it saves writing javascript, which is easy to get wrong.
you're right. I just tested the Rangenode with your settings and it works great. I don't understand the exact logic behind the node, but it doesn't matter. Absolutely sufficient for my purpose.
Thanks for your support!!!!
It does matter, you should never use a node unless you basically understand what it does.
The settings I posted tell it to expect a message payload input between 2.3 and 6.18. It says if it is 2.3 then send 0 and if it is 6,18 then send 6.2 for values in between it does a simple linear interpolation, so for example if the input were half way between 2.3 and 6.18 then the output would be half way between 0 and 6.2
Hello,
brilliant so exactly what i was looking for.
With this node I can compensate the deviations of the digital pressure sensor. I am rounding the values through another node. Now the analog and digital pressure sensors show almost the same values.
Thanks anyway to Ranki. Here, too, I've learned something new.
Your explanation is super understandable.