Moisture Sensor Polarity

Discussion in 'General Discussion' started by ColinCamSmith, Jul 17, 2021.

  1. ColinCamSmith

    ColinCamSmith

    Joined:
    Nov 25, 2004
    Messages:
    84
    Likes Received:
    0
    Ashley / Brad.

    FYI Attached is a copy of the Homegate Log
     

    Attached Files:

    ColinCamSmith, Jul 20, 2021
    #41
  2. ColinCamSmith

    bmerrick

    Joined:
    Jun 13, 2007
    Messages:
    434
    Likes Received:
    34
    Location:
    Sydney
    Hi Colin,

    Looking at your log, it suggests to me that not much is happening on your input.

    Correct me if I am wrong, but the sensor or logger adapter that you are using is supposed to output a linear DC voltage between 0 and 2.8 volts DC between being wet and dry at the sensor. Have you checked this output with a voltmeter at the end of the run to ensure you are getting this voltage change between wet and dry?

    The output being logged suggests to me you are getting voltages approximating background radio noise induced DC or galvanic DC, rather than a signal. It is in milli-volts.

    From the loggers PDF you sent first post, it says you should be expecting an order of magnitude DC voltage above that. Unless I am missing something in how the product is supposed to be operating, If you can't see the swing with a voltmeter, it's not working properly.

    Can you measure and let us know,

    Brad



    :eek::cool::cool::cool::cool::cool::cool:
     
    bmerrick, Jul 21, 2021
    #42
  3. ColinCamSmith

    ColinCamSmith

    Joined:
    Nov 25, 2004
    Messages:
    84
    Likes Received:
    0
    Brad,

    Yes the voltage has been checked and was in accordance with the Manufacturers advice.
    Will check again and let you know but it will be sometime tomorrow.
    Note that the Wet and Dry readings will have to be at least 24 hours apart.

    Regards,

    Colin
     
    ColinCamSmith, Jul 21, 2021
    #43
  4. ColinCamSmith

    ColinCamSmith

    Joined:
    Nov 25, 2004
    Messages:
    84
    Likes Received:
    0
    Brad,
    Notwithstanding my previous response whereby I will check the voltages again, the unit must be working.
    In full Dry mode the voltage runs up to 0.059 volts (60% on the Gen Input Unit) and in full Wet mode it is 0.001 volts (1% on the Gen Input Unit). Both results according to the manufacturer are what we should expect.
     
    ColinCamSmith, Jul 21, 2021
    #44
  5. ColinCamSmith

    ColinCamSmith

    Joined:
    Nov 25, 2004
    Messages:
    84
    Likes Received:
    0
    It is simply a matter of reversing the readings to get the result we want??
     
    ColinCamSmith, Jul 21, 2021
    #45
  6. ColinCamSmith

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    We are not replacing/updating the moisture sensor system i/o. We are creating a new user system i/o that contains the new moisture percentage. The code calculates the percentage from the raw value from the measurement app and stores it in a user system i/o.

    I think you are getting very confused here in the way you have named the 2 variable the same (i.e. "Moisture Sensor"). The first is in the Measurement Manager which is the raw value from the field. The second is the user variable that is being updated from the logic. This is the one that contains the percentage. You should be displaying the user variable, not the measurement app variable. What I would do is change the Measurement App variable to say "Moisture Sensor Raw" to avoid confusion (you will then need to adjust the code). This variable does not need to be displayed anywhere, just used in the logic. The user variable is what you want to be looking at. That's why I got you to put the last writeLn in. It logs the calculated value.

    Randomly trying stuff will not get you anywhere. You need to understand what is going on. What we are trying to do here is really very simple, and if approached in a consistent way should work easily.

    Again, this makes no sense. You say the sensor is reading 0.04999 which according to your constants means the sensor is dry and should give a low percentage moisture , not 80% like you say.

    Please confirm: Which way around are the constants!!!!!
     
    Ashley, Jul 21, 2021
    #46
  7. ColinCamSmith

    ColinCamSmith

    Joined:
    Nov 25, 2004
    Messages:
    84
    Likes Received:
    0
    Ashley,
    Before we get into the heavy stuff:
    Constants are as attached and have not been changed.

    And again, if the Sensor is Dry the reading is actually high and when Wet it is actually low.
    Hence when the reading is 0.015 as it is at the moment and the Sensor is very wet it should read about 0.04999 but it is not (that is about 85% wet).
    When it dries out over the next 24-48 hours it should read 0.001 but will read 0.05900

    What am I missing?

    Regards,

    Colin
     

    Attached Files:

    ColinCamSmith, Jul 21, 2021
    #47
  8. ColinCamSmith

    ColinCamSmith

    Joined:
    Nov 25, 2004
    Messages:
    84
    Likes Received:
    0
    Ashley,
    See attached.

    You are correct. I am getting confused with the different variables.
    You may like to make the changes and send it back.

    Regards,

    CCS
     

    Attached Files:

    ColinCamSmith, Jul 21, 2021
    #48
  9. ColinCamSmith

    bmerrick

    Joined:
    Jun 13, 2007
    Messages:
    434
    Likes Received:
    34
    Location:
    Sydney
    Hi Colin,

    You probably realise that both Ashley and I are approaching this from two different perspectives. Ashley is doing it in Pascal, I am using the inbuilt hardware abilities of the General Input Unit. Both are equally valid ways to get to the data you want and present it appropriately to other devices on the C-Bus network.

    The output voltage being sent on the network by your General input unit is miniscule and so to me it looks like either there is no working input at all or alternatively, the scaling is set wrongly.

    Please look at the image attached. This is what the input should look like to correctly report a 0 to 5v DC input onto the C-Bus measurement app. If you set your input channel to these identical settings, we will get a lot closer to fixing you up if the moisture system is sending the right voltage.

    If you look at my channel 1 set up, it is reading 1451 millivolts, which is the 1.45 volts it is seeing from the mostly flat AA duracell (an old mouse battery off my desk) I have attached to the input. In my Toolkit log, it reads as this voltage exactly being transmitted on the measurement channel.
    DateTime= 21/07/2021 11:05:26 AM App= 228 Application 228 Group= 255 <Unused> Unit= 200 PC_GIM/NEWUNIT Event= Device 255, Unit 200, Channel 0 - Value: 1.4500000688713 Volts

    I chose the AA battery as it is about the centre voltage you would expect to see from your sensor when the soil is half wet half dry. In the end, we should be trying to make this read 50%.

    If you can go into Toolkit and set you channel exactly as per my image, and get your rig to read to this same point, I can then send you a library curve to invert the output the way you want.

    Cheers,

    Brad


    :eek::cool::cool::cool::cool::cool::cool:
     
    bmerrick, Jul 21, 2021
    #49
  10. ColinCamSmith

    ColinCamSmith

    Joined:
    Nov 25, 2004
    Messages:
    84
    Likes Received:
    0
    Brad,

    Understand and I will have a mate measure the actual voltage at the Sensor and then adjust the Scaling Multiplier to suit.
    Will keep you both posted as I am laid up at the moment and will to wait until tomorrow for the readings.

    Regards,

    Colin
     
    ColinCamSmith, Jul 21, 2021
    #50
  11. ColinCamSmith

    ColinCamSmith

    Joined:
    Nov 25, 2004
    Messages:
    84
    Likes Received:
    0
    Brad & Ashley,

    Further to above, you may have noted on the Homegate log there is a Rainwater Level Sensor reading of 0.094 amps.
    This, when the System I/O for the Rainwater Level is monitored for Status in a Text Box, reads 94%.

    Just for info,

    Regards,

    Colin
     
    ColinCamSmith, Jul 21, 2021
    #51
  12. ColinCamSmith

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    I think this is where the confusion is arising. You want the sensor voltage to be inverted so a high voltage gives you a high percentage and low voltage a low percentage, but that is not what you need to do if you are using my logic. The logic takes the raw voltage as input (so a low voltage is wet and high voltage is dry), and converts this to a percentage so a low percentage is dry and a high percentage is wet (as you want), then writes this percentage to the "Moisture Sensor" USER variable. It doesn't change the voltage (it can't). You then only ever access this user variable. Forget about the voltage, it's only used by the logic. All displays and calculations should user the "Moisture Sensor" USER variable.

    Add a level component to your display page, go into its properties, select the systemIO tab, select STATUS as the function, then USER VARIABLES, and select "Moisture Sensor" from the list. You can also go into Visual Properties and Value, select Custom down the bottom, and put a % sign in the post fix box.
     
    Ashley, Jul 21, 2021
    #52
  13. ColinCamSmith

    ColinCamSmith

    Joined:
    Nov 25, 2004
    Messages:
    84
    Likes Received:
    0
    Brad,
    I have set the Gen Input Multiplier to 40 and this gives me 1680 milli volts (17%) and the CBus Tool Kit log is now showing 1.596 volts. The Homegate Log is also now showing 1.595999 volts.

    So maybe some progress.

    Ashley, will this help?

    Regards,

    Colin
     
    ColinCamSmith, Jul 21, 2021
    #53
  14. ColinCamSmith

    ColinCamSmith

    Joined:
    Nov 25, 2004
    Messages:
    84
    Likes Received:
    0
    Ashley,
    Have done exactly as you suggested.
    Added Level Indicator, Selected Status for Moisture Sensor and set Properties to %.
    It is reading 0.0%
    The Text Box with the Selected Status for Moisture Sensor and Properties set to %
    It is reading 16% which equates the the voltage in the Homegate Log and the Tool Kit log.

    Why are they not both reading the same

    This must be driving you to the brink.

    Have you got Team Viewer?
     
    ColinCamSmith, Jul 21, 2021
    #54
  15. ColinCamSmith

    bmerrick

    Joined:
    Jun 13, 2007
    Messages:
    434
    Likes Received:
    34
    Location:
    Sydney
    Hi Colin,

    That's great, we are now getting a decent voltage signal that both Ashley's logic engine approach and my hardware approach can work with. You can choose your preferred way to go now and implement it.

    My approach just sends the water % out the measurement channel natively from the unit. Ashley's approach has the benefit of keeping all your sensor logic together in the one place in your HomeGate project file.

    On the General Input configuration side, I have further refined the settings. See the attached images with the parameters that you can use and the customised library curve.

    This library curve when applied inverts the voltage vs percentage and makes a 2.8 volt input on the channel send a 0% (fully dry?) to the measurement channel, a 0 volt input send a 100% (fully wet?) to the measurement channel and a 1.4 volt input gives 50% (just right??). You can see from my log the readings with a few voltages I cobbled up from the half dead battery collection in my desk drawer.

    Hope that works for you.

    Brad

    :eek::cool::cool::cool::cool::cool::cool:
    G_Input3a.jpg G_Input3b.jpg G_Input3c.jpg
     
    bmerrick, Jul 21, 2021
    #55
  16. ColinCamSmith

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    You are not going to get anywhere if you are trying to implement 2 solutions at once. Decide which one you want to go with. If you have modified the general input unit the logic code is now irrelevant.
     
    Ashley, Jul 21, 2021
    #56
  17. ColinCamSmith

    ColinCamSmith

    Joined:
    Nov 25, 2004
    Messages:
    84
    Likes Received:
    0
    Ashley / Brad,

    Out of action today will get back to you tomorrow.
    Old age and ruddy doctors.

    Regards,

    Colin
     
    ColinCamSmith, Jul 22, 2021
    #57
  18. ColinCamSmith

    ColinCamSmith

    Joined:
    Nov 25, 2004
    Messages:
    84
    Likes Received:
    0
    Ashley / Brad,

    Brad,

    First let me address your option.
    With the Multiplier set at 60, the readings reflect the higher numbers both
    in the Homegate Log and the CBus Toolkit.
    Further, they are then shown in the Text Box and Level Indicator (added on
    the advice of Ashley).
    The Text Box & Level Indicator are both reading the Status of the Moisture
    Sensor System I/O.
    Now, as the actual sensor has been drying out the readings have gone from
    82% yesterday up to 113% this morning.
    The reverse of what we are looking for.
    I understand you can massage this to reverse the readings but I am reluctant
    to go down this path as it removes it from Homegate.
    So many thanks for your efforts but I will continue (if he will still have
    me) with Ashley.

    Ashley,

    Going back to basics we have this:
    Constants:
    MoistureDry=0.001000 (Actually what we are seeing when fully wet)
    MoistureWet=0.059000 (Actually what we are seeing when fully dry)

    So we are getting the inverse of what we need.

    Global Variable MoistureSensor: real ;

    Actual "Moisture Sensor raw = 0.0500 as I write at 07:15

    So the current code reads: (0.05-0.001)/(0.059-0.001)*100 = 0.844828 or
    84.4%.
    Which means the sensor is almost fully wet when it is almost dry.

    Now if we go: -(0.05-0.059)/(0.059-0.001)*100 = 0.155172 or 15.5%.
    This presents the correct Moisture content in that it is now almost dry.

    The issue now is to get it to load the Moisture Sensor into the System I/O
    with this reading.
    At the moment although the code directs it to do so, it is not happening.

    Now at 10:32 the Homegate Log and the CBus Toolkit are reading 0.0529999.
    So further drying has taken place.

    And unfortunately both the Text Box and Level Indicator are reading 53.0%

    When do we give up??

    Regards,

    Colin
     
    ColinCamSmith, Jul 23, 2021
    #58
  19. ColinCamSmith

    bmerrick

    Joined:
    Jun 13, 2007
    Messages:
    434
    Likes Received:
    34
    Location:
    Sydney
    Hi Colin,

    Multiplier needed to be 0.695 as per my image, not 60? As long as the voltage into the channel was in the range 0 - 2.8V DC, the library curve was set to only read 0 - 100%.

    Anyway, it is all good to do it in the logic engine and has the benefit that it keeps all your similar logic in one place as I mentioned before.

    Good Luck,

    Brad
     
    bmerrick, Jul 23, 2021
    #59
  20. ColinCamSmith

    ColinCamSmith

    Joined:
    Nov 25, 2004
    Messages:
    84
    Likes Received:
    0
    Brad,

    The sensor will be fully dry over the weekend so I will measure the voltage.
    Then soak it until it is fully wet and again measure the voltage.

    For interest, I will keep you posted with the results

    Regards,

    Colie
     
    ColinCamSmith, Jul 23, 2021
    #60
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.