• Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

    Data point with non-linear output?

    Mango General
    2
    6
    50
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      tomatopi last edited by

      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.
      I managed to create a global script to interpret the data using five different formulas. Similar to this:

      function mapMoisture( voltage ) {
       if ( voltage < 1 ) {
        return 34 * voltage - 5;
       }
       else if ( voltage < 2 ) {
        return 56 * voltage - 15;
       }
       ...
      }
      

      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.

      Is there another solution to interpreting non-linear data points other than creating a corresponding meta data point like I have done?

      Thanks

      MattFox 1 Reply Last reply Reply Quote 0
      • MattFox
        MattFox @tomatopi last edited by MattFox

        @tomatopi are you trying to display the modified values or do you need to store them??
        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.

        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...

        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.

        Means you'd natively fix your data before pushing it into mango..

        Fox

        Do not follow where the path may lead; go instead where there is no path.
        And leave a trail - Muriel Strode

        T 1 Reply Last reply Reply Quote 0
        • T
          tomatopi @MattFox last edited by

          @MattFox 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.

          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.

          Thanks for the help.

          MattFox 1 Reply Last reply Reply Quote 0
          • MattFox
            MattFox @tomatopi last edited by

            @tomatopi stick to raw, especially if you find you need to amend your values again later.

            You'll need to understand angularJS if you want to extend the dashboard for your own benefit.
            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.

            -Fox

            Do not follow where the path may lead; go instead where there is no path.
            And leave a trail - Muriel Strode

            T 1 Reply Last reply Reply Quote 0
            • T
              tomatopi @MattFox last edited by

              @MattFox 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.

              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.

              My code to translate the raw voltage from the sensor to a %VWC is:

              function percentMoisture( voltage )
              {
                  if( voltage < 1.1 ) {
                      return ( 10 * voltage ) - 1;
                  }
                  else if ( voltage < 1.3 ) {
                      return ( 25 * voltage ) - 17.5;
                  }
                  else if ( voltage < 1.85 ) {
                      return ( 48.08 * voltage ) - 47.5;
                  }
                  else if ( voltage < 2.2 ) {
                      return ( 26.32 * voltage ) - 7.89;
                  }
                  else if ( voltage < 3 ) {
                      return ( 62.5 * voltage ) - 87.5;
                  }
                  else {
                      return 100;
                  }
              }
              

              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?

              Thanks

              MattFox 1 Reply Last reply Reply Quote 0
              • MattFox
                MattFox @tomatopi last edited by

                @tomatopi 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....

                Thanks for the logic, can show you something basic to get you started

                Fox

                Do not follow where the path may lead; go instead where there is no path.
                And leave a trail - Muriel Strode

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post