<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Data point with non-linear output?]]></title><description><![CDATA[<p dir="auto">I have a sensor that's designed to measure volume water content in the soil. However, it's output is non-linear so it's value needs to be calculated by a series formulas or a non-linear mapping.<br />
I managed to create a global script to interpret the data using five different formulas. Similar to this:</p>
<pre><code>function mapMoisture( voltage ) {
 if ( voltage &lt; 1 ) {
  return 34 * voltage - 5;
 }
 else if ( voltage &lt; 2 ) {
  return 56 * voltage - 15;
 }
 ...
}
</code></pre>
<p dir="auto">So far, the only way I found to apply this to my sensor reading (modbus data point) is to create a meta point relating to the modbus point and use the global script against it. If I need to add 100+ sensors, that would use up 2 data points per sensor effectively doubling my data point usage.</p>
<p dir="auto">Is there another solution to interpreting non-linear data points other than creating a corresponding meta data point like I have done?</p>
<p dir="auto">Thanks</p>
]]></description><link>https://forum.mango-os.com/topic/5608/data-point-with-non-linear-output</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Jul 2026 22:15:47 GMT</lastBuildDate><atom:link href="https://forum.mango-os.com/topic/5608.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 20 Jan 2023 20:35:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Data point with non-linear output? on Tue, 14 Feb 2023 16:43:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joeamiraglia" aria-label="Profile: joeamiraglia">@<bdi>joeamiraglia</bdi></a> That is exactly what I have running now on a test point and it does work.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mattfox" aria-label="Profile: MattFox">@<bdi>MattFox</bdi></a> Your solution would work, but as <a class="plugin-mentions-user plugin-mentions-a" href="/user/craigweb" aria-label="Profile: CraigWeb">@<bdi>CraigWeb</bdi></a> said, charting and displaying the data proved to be a little more difficult.</p>
<p dir="auto">I'm hoping to avoid re-programming my sensor units to pre-parse the data (I'm using custom make microcontrollers). That would make them less flexible if I add/remove/change sensors.</p>
<p dir="auto">I originally assumed I'd just need a parsed value to determine if it's moist or dry. Since then, I noticed the history chart was very useful. Since we're tracking soil moisture in a pot, displaying the values in a chart compared to sunlight, temperature, humidity, etc. is proving a lot more useful that I expected.</p>
<p dir="auto">It would be nice if the modbus datapoint (or others) were able to call a global script instead of just the multiplier/added function. That would be the bees knees.</p>
<p dir="auto">I'm not entirely sure the direction I will go, but I'm leaning to biting the bullet and using the two points per solution just to get the future flexibility to chart and trigger events.</p>
]]></description><link>https://forum.mango-os.com/post/27596</link><guid isPermaLink="true">https://forum.mango-os.com/post/27596</guid><dc:creator><![CDATA[tomatopi]]></dc:creator><pubDate>Tue, 14 Feb 2023 16:43:36 GMT</pubDate></item><item><title><![CDATA[Reply to Data point with non-linear output? on Fri, 10 Feb 2023 20:42:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tomatopi" aria-label="Profile: tomatopi">@<bdi>tomatopi</bdi></a><br />
For non-linear scaling, you will be best off using 2 data points.  If you do a front scaling like <a class="plugin-mentions-user plugin-mentions-a" href="/user/mattfox" aria-label="Profile: MattFox">@<bdi>MattFox</bdi></a> you will soon run into issues when you want to chart, alarm, or display the points with the built-in angularJS components.   Other options would be to scale the point at the edge with a PLC before you ingest into Mango.</p>
]]></description><link>https://forum.mango-os.com/post/27591</link><guid isPermaLink="true">https://forum.mango-os.com/post/27591</guid><dc:creator><![CDATA[CraigWeb]]></dc:creator><pubDate>Fri, 10 Feb 2023 20:42:57 GMT</pubDate></item><item><title><![CDATA[Reply to Data point with non-linear output? on Fri, 10 Feb 2023 19:29:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/joeamiraglia" aria-label="Profile: joeamiraglia">@<bdi>joeamiraglia</bdi></a> appreciate the input, but he wants to avoid using two datapoints for every individual sensor which is why i suggested showing the data parsed through a directive.</p>
<p dir="auto">Fox</p>
]]></description><link>https://forum.mango-os.com/post/27590</link><guid isPermaLink="true">https://forum.mango-os.com/post/27590</guid><dc:creator><![CDATA[MattFox]]></dc:creator><pubDate>Fri, 10 Feb 2023 19:29:28 GMT</pubDate></item><item><title><![CDATA[Reply to Data point with non-linear output? on Fri, 10 Feb 2023 18:48:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tomatopi" aria-label="Profile: tomatopi">@<bdi>tomatopi</bdi></a> Hello, one way to achieve what you are looking for is the create a Global Script such as the one shown below;<img src="https://camo.nodebb.org/e9ab597eef88443a114cdef297c72554672d9725?url=https%3A%2F%2Fi.imgur.com%2FjRMEvUP.png" alt="240847b7-2597-4036-ab0e-80bdbf8f31ac-image.png" class=" img-fluid img-markdown" /><br />
here is the text for the script for easy editing, (I just expanded what you had in your question);</p>
<pre><code>function mapMoisture(voltage) {
 print (voltage)
 if ( voltage &gt; 0 &amp;&amp; voltage &lt; 1 ) {
  return 34 * voltage - 5;
 }
 else if ( voltage &gt;= 1 &amp;&amp; voltage &lt; 2 ) {
  return 56 * voltage - 15;
 }
 else if ( voltage &gt;= 2 &amp;&amp; voltage &lt; 3 ) {
  return 78 * voltage - 22;
 }
 else if ( voltage &gt;= 3 &amp;&amp; voltage &lt; 4 ) {
  return 100 * voltage - 30;
 }
 else if ( voltage &gt;= 4 &amp;&amp; voltage &lt; 5 ) {
  return 135 * voltage - 36;
 }
return 0
}
</code></pre>
<p dir="auto">Once this is done you will be able to call the script from a meta point such as this;</p>
<p dir="auto"><img src="https://camo.nodebb.org/8a9f39feac00bc60704bfc74008c17645e2d95e6?url=https%3A%2F%2Fi.imgur.com%2FnYZa0jy.png" alt="1be41165-4046-47c0-b750-400e04eeb9c8-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.mango-os.com/post/27589</link><guid isPermaLink="true">https://forum.mango-os.com/post/27589</guid><dc:creator><![CDATA[joeamiraglia]]></dc:creator><pubDate>Fri, 10 Feb 2023 18:48:12 GMT</pubDate></item><item><title><![CDATA[Reply to Data point with non-linear output? on Tue, 24 Jan 2023 23:20:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tomatopi" aria-label="Profile: tomatopi">@<bdi>tomatopi</bdi></a> a lot of people have asked the same thing, nobody knows... I'm of the opinion they will stick with angular. I'm more of a Vue3 person myself....</p>
<p dir="auto">Thanks for the logic, can show you something basic to get you started</p>
<p dir="auto">Fox</p>
]]></description><link>https://forum.mango-os.com/post/27587</link><guid isPermaLink="true">https://forum.mango-os.com/post/27587</guid><dc:creator><![CDATA[MattFox]]></dc:creator><pubDate>Tue, 24 Jan 2023 23:20:33 GMT</pubDate></item><item><title><![CDATA[Reply to Data point with non-linear output? on Tue, 24 Jan 2023 14:24:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mattfox" aria-label="Profile: MattFox">@<bdi>MattFox</bdi></a> I usually program more server-side stuff in PHP so it will take me time to wrap my brain around AngularJS, but I'm starting to try getting familiar with it.</p>
<p dir="auto">I made that basic userModule based on the docs, but I don't see any good documentation beyond the basic scaffold. It would be cool to see a snippet or two of sample code.</p>
<p dir="auto">My code to translate the raw voltage from the sensor to a %VWC is:</p>
<pre><code>function percentMoisture( voltage )
{
    if( voltage &lt; 1.1 ) {
        return ( 10 * voltage ) - 1;
    }
    else if ( voltage &lt; 1.3 ) {
        return ( 25 * voltage ) - 17.5;
    }
    else if ( voltage &lt; 1.85 ) {
        return ( 48.08 * voltage ) - 47.5;
    }
    else if ( voltage &lt; 2.2 ) {
        return ( 26.32 * voltage ) - 7.89;
    }
    else if ( voltage &lt; 3 ) {
        return ( 62.5 * voltage ) - 87.5;
    }
    else {
        return 100;
    }
}
</code></pre>
<p dir="auto">This may be a silly question, but when I look up AngularJS, I keep getting notices that's depreciated in favour of the new Angular Framework. Do we know what this means for Mango down the road?</p>
<p dir="auto">Thanks</p>
]]></description><link>https://forum.mango-os.com/post/27585</link><guid isPermaLink="true">https://forum.mango-os.com/post/27585</guid><dc:creator><![CDATA[tomatopi]]></dc:creator><pubDate>Tue, 24 Jan 2023 14:24:35 GMT</pubDate></item><item><title><![CDATA[Reply to Data point with non-linear output? on Sun, 22 Jan 2023 10:10:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tomatopi" aria-label="Profile: tomatopi">@<bdi>tomatopi</bdi></a> stick to raw, especially if you find you need to amend your values again later.</p>
<p dir="auto">You'll need to understand angularJS if you want to extend the dashboard for your own benefit.<br />
Alternatively if you're in the position where you can share your conversion factors, learn about the mango userModule and read about angularJS directives and we can work together to enable you to create your first custom component.</p>
<p dir="auto">-Fox</p>
]]></description><link>https://forum.mango-os.com/post/27584</link><guid isPermaLink="true">https://forum.mango-os.com/post/27584</guid><dc:creator><![CDATA[MattFox]]></dc:creator><pubDate>Sun, 22 Jan 2023 10:10:43 GMT</pubDate></item><item><title><![CDATA[Reply to Data point with non-linear output? on Sat, 21 Jan 2023 15:37:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mattfox" aria-label="Profile: MattFox">@<bdi>MattFox</bdi></a> The AngularJS Directive may be an option. I haven't dove that deep into Mango yet so I'm rather clueless as to where to start. Are there any documentation links/examples/tutorials around that you know of? The v4 documentation gives some very basic information, but not enough for me to wrap my brain around pulling in a data point and applying a formula.</p>
<p dir="auto">Failing that, I could probably re-program all my sensor transmitters to a pre-parsed output format. I was hoping not to do that since it would tie each controller to a specific sensor requiring hardware flashing if the hardware changes down the line. That would have the advantage of storing historic values for reporting.</p>
<p dir="auto">Thanks for the help.</p>
]]></description><link>https://forum.mango-os.com/post/27583</link><guid isPermaLink="true">https://forum.mango-os.com/post/27583</guid><dc:creator><![CDATA[tomatopi]]></dc:creator><pubDate>Sat, 21 Jan 2023 15:37:36 GMT</pubDate></item><item><title><![CDATA[Reply to Data point with non-linear output? on Sat, 21 Jan 2023 03:11:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tomatopi" aria-label="Profile: tomatopi">@<bdi>tomatopi</bdi></a> are you trying to display the modified values or do you need to store them??<br />
If you only want to display, I'd advise writing an angularJS directive to manipulate the data for you then passing that into your chart.</p>
<p dir="auto">The alternative is storing the data in a separate database then using mango to parse the DB and use the data that has been modified in this other database...</p>
<p dir="auto">Find a way to take this data and store it in a csv file, then write a java class (there are examples here) to parse and modify the raw data into the format required.</p>
<p dir="auto">Means you'd natively fix your data before pushing it into mango..</p>
<p dir="auto">Fox</p>
]]></description><link>https://forum.mango-os.com/post/27581</link><guid isPermaLink="true">https://forum.mango-os.com/post/27581</guid><dc:creator><![CDATA[MattFox]]></dc:creator><pubDate>Sat, 21 Jan 2023 03:11:18 GMT</pubDate></item></channel></rss>