Soil Sensor Trips wrong way (dry>wet not wet>dry)



  • Hi everyone,

    Firstly a big thank you to everyone for your great ideas, guides and guidance. This site got my greenhouse project off to a flying start.
    I have one question which is probably going to expose my noobness.

    I have various sensors running on various test uno boards including multiple temp sensors on one uno and a single soil sensor on another.
    All there are reporting to my Ethernet Gateway then to MyController running on a Pi.
    Im using the digital output of the sensor and it shows up correctly in MyController. However the alarm is only triggered when the sensor goes from dry to wet not wet to dry. I have read through the sketch and it mentions inverting the send to allow for this. Am I missing something?

    Any Help would be greatly appreciated.

    Thanks
    Glen


  • Plugin Developer

    @crusher70

    Can you put screen shot of your alarm configuration?



  • 0_1456951122789_SoilAlarm.jpg

    Hi there,

    I have tried setting the "Trigger When" option to 1 and 0 but it still seems to be reversed.
    Many thanks.
    Glen


  • Plugin Developer

    @crusher70 said:

    Hi there,

    I have tried setting the "Trigger When" option to 1 and 0 but it still seems to be reversed.
    Many thanks.
    Glen

    What exactly your sensor returns 0 and 1? or string value like wet , dry something like? If it is string should be case sensitive.

    Also you have configured Dampening type as Consecutive with 2 counts, which means this condition should satisfy two times continuously.

    Recommendation: If you are sending string value from sensor Tripped variable is not a suitable one. Better use VAR1...VAR5 or suitable variable type.



  • @jkandasa

    Hi and thank you for your help with this.

    I'm using the default MySensor sketch, the read function is as follows:-
    the serial output shows that when the sensor is wet (not triggered) a 1 is sent and Dry (triggered) a 0 is sent.
    I have changed the Dampening to none for now.

    void loop()     
    {     
      // Read digital soil value
      int soilValue = digitalRead(DIGITAL_INPUT_SOIL_SENSOR); // 1 = Not triggered, 0 = In soil with water 
      if (soilValue != lastSoilValue) {
        Serial.println(soilValue);
        gw.send(msg.set(soilValue==0?1:0));  // Send the inverse to gw as tripped should be when no water in soil
      
        lastSoilValue = soilValue;
      }
    

  • Plugin Developer

    @crusher70

    Thank you for the code. Yes, your sensor sends 1 and 0. You have to configure two alarm definitions.

    one as you showed here and another one should be like trigger when == 0



  • @jkandasa

    Thank you jkandasa,
    I was looking at it from completely the wrong direction trying to cover everything with just one alarm. I have reconfigured as you suggested and also added a forward payload which turns on a relay to water plants and turns it off when soil is wet.

    Working perfectly thank you so much for your help with this.

    Glen


  • Plugin Developer

    @crusher70

    Perfect! you can also configure one safety alarm for your relay. For example controller turned on relay based on wet, dry signal. Later if we do not receive any data from sensor, relay will be keep on turned ON and water over flow will happened.

    To avoid this you can configure one additional alarm for relay. Say turn OFF relay if it's continually ON for more than 20 minutes.
    Condition: Realy == 1 and in Dampening: Active time 20 minutes



  • @jkandasa
    Great idea! Ill do that now. Thanks again for being so helpful.

    Glen



  • @jkandasa
    Ok one final nob question if you don't mind?

    I have configured the Alarm as suggested but set the active time for 1 min for testing. The alarm triggers as it should but I cant see where the triggering of this alarm turns off the relay. Sorry if this is a silly question but I can't for the life of me see where to configure it.

    Many thanks
    Glen


  • Plugin Developer

    @crusher70

    Hey, no problem at all. you can ask as many questions you want.

    Can you post your configuration screenshot?



  • @jkandasa

    As requested this is the alarm i have configured.
    0_1456959002208_Relayshutoff.png


  • Plugin Developer

    @crusher70

    Alarm triggers but there is no notification to execute for this alarm. You have to create new notification with Send payload relay =1. and map your new notification with this alarm.



  • @jkandasa

    Ah now I understand thank you once again.

    Regards
    Glen



  • @jkandasa

    Thanks jkandasa work great. I shall leave you alone to rest up for a while as its 4:30 am over there. I'm sure I'll have more questions at some point in the future, but for now you have been a great help so thank you very much. Take care and have a great day.
    Regards
    Glen


  • Plugin Developer

    @crusher70 well! Thank you!


Log in to reply
 

Suggested Topics

50
Online

11.4k
Users

11.1k
Topics

112.7k
Posts