This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] Function Node Code to correct non-linear sensor ?
#1
I am reading my fuel/waste/fresh water tank levels using the original resistive senders (0-190 Ohm) configured in a voltage divider.
The output voltage is then read by an ADS1115 ADC connected to an ESP8226 wireless sender running ESPEasy firmware. The ESP8226 sends the data as MQTT over WiFi and is picked up in NodeRed for presentation on my dashboard on the Pi. (All shamelessly copied from others on here Smile

All works just great but I'd like to incorporate some correction for the non-linear nature of the sender.
In OP I know there is the option to do this for a directly connected ADC but not one sending data over MQTT
In the ESPEasy firmware there is the option for "2 point correction" but I need more plots in the curve than just "1024 = full and 0= empty".

I think that what I really need is some JSON code for a NodeRed function node that will take a raw ADC value range and convert it into a value in litres. 
I'd want a small table of 8 such conversions as the sender has 8 or maybe 10 steps.

for example
ADC in        value out
0-99           0
100-299      20
300-499      50
500-699      100
700-799      200
800-999      250
1020+        320

I have no clue how to write JSON code so Im hoping that someone may have addressed this issue before.
Thanks
Steve
Reply


Messages In This Thread
[SOLVED] Function Node Code to correct non-linear sensor ? - by affinite - 2018-02-25, 11:23 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)