🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    How do I invert a reading in UIFLow2?

    UiFlow 2.0
    2
    7
    2.2k
    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.
    • ajb2k3A
      ajb2k3
      last edited by

      Ok so my brain has totally failed today which leaves me with the following question.
      This is the code I have so far:

      0_1708766759351_Screenshot 2024-02-24 at 09.24.12.png

      When the soil level Moisture increases the reading goes down. For correct readings I need the level to work in the complete reverse and go up as the moisture increases.

      What do I need to change to invert the reading as numbers is hard for me to calculate today?

      UIFlow, so easy an adult can learn it!
      If I don't know it, be patient!
      I've ether not learned it or am too drunk to remember it!
      Author of the WIP UIFlow Handbook!
      M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

      teastainT 1 Reply Last reply Reply Quote 0
      • teastainT
        teastain @ajb2k3
        last edited by

        @ajb2k3 if greater than > the desired value?

        Cheers, Terry!

        100% M5Stack addict with several drawers full of product!

        1 Reply Last reply Reply Quote 1
        • ajb2k3A
          ajb2k3
          last edited by

          Sorry why I mean is that when the Moisture level in the soil increases, the ADC value goes down and after the percentage calculation the percentage value goes down.

          What I want is the percentage reading to go in the reverse but I cant seam to work out how.

          UIFlow, so easy an adult can learn it!
          If I don't know it, be patient!
          I've ether not learned it or am too drunk to remember it!
          Author of the WIP UIFlow Handbook!
          M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

          teastainT 1 Reply Last reply Reply Quote 0
          • teastainT
            teastain @ajb2k3
            last edited by

            @ajb2k3 I understood and I suggested turning on the water when the soil was dry, which is what you wanted.
            So change the <20 to > 'some value' that is too dry.
            I have a ENV Pro that I thought the gas reading was in a direction that was not logical (helpful to the Brain) so I reversed it to display an increase, instead of a decrease.

              VOC = (1 / gas_resistance) * 10000;
            

            So I guess you could do a reciprocal of the ADC reading and scale it to suit, but that seems like more work to me!
            I only jumped in because your UIFlow program reads like C!!!

            Cheers, Terry!

            100% M5Stack addict with several drawers full of product!

            ajb2k3A 1 Reply Last reply Reply Quote 1
            • ajb2k3A
              ajb2k3 @teastain
              last edited by

              @teastain Thanks you suggestion works I just did >50% to operate the pump and uploaded the code to the project zone.

              What do you mean reads like C, is that a good thing or a bad thing because I was following a Maths exam guide for the formula as I had forgotten it.

              UIFlow, so easy an adult can learn it!
              If I don't know it, be patient!
              I've ether not learned it or am too drunk to remember it!
              Author of the WIP UIFlow Handbook!
              M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

              teastainT 1 Reply Last reply Reply Quote 0
              • teastainT
                teastain @ajb2k3
                last edited by

                @ajb2k3
                This is Arduino C:
                It reads VERBALLY just like your UIFlow program!

                If ((ADC8 / 4096) * 100 < 20) {
                DigitalWrite(9 = HIGH)
                }
                else{
                DigitalWrite(9 = LOW)
                }
                

                But brackets and things.
                -Cheers

                Cheers, Terry!

                100% M5Stack addict with several drawers full of product!

                ajb2k3A 1 Reply Last reply Reply Quote 1
                • ajb2k3A
                  ajb2k3 @teastain
                  last edited by

                  @teastain Ah Ok thanks, I avoid arduino like the plague so didn't notice.

                  Hopefully that means that people can read the example and simply port to arduino.

                  UIFlow, so easy an adult can learn it!
                  If I don't know it, be patient!
                  I've ether not learned it or am too drunk to remember it!
                  Author of the WIP UIFlow Handbook!
                  M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

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