💬 Soil Moisture Sensor


  • Admin

    This thread contains comments for the article "Soil Moisture Sensor" posted on MySensors.org.



  • There is something in the sketch I do not understand

     * Connection:
     * D6, D7: alternative powering to avoid sensor degradation
     * A0, A1: alternative resistance mesuring
    
    void setup() {
      // initialize the digital pins as an output.
      // Pin 6,7 is for sensor 1
      // initialize the digital pin as an output.
      // Pin 6 is sense resistor voltage supply 1
      pinMode(6, OUTPUT);    
    
      // initialize the digital pin as an output.
      // Pin 7 is sense resistor voltage supply 2
     pinMode(7, OUTPUT);    
    }
    
    

    What is this for?


  • Hardware Contributor

    I think the code is written for a self made sensor and the pictures show a binary sensor...


  • Mod

    @Martin-Tellblom the pins on the sensor can corrode by electrolysis. By alternating polarity, corrosion might be prevented (I am not sure that it makes a difference in practice though).

    Some discussion on the topic is available in https://forum.mysensors.org/topic/2147/office-plant-monitoring/ (very long thread with lots of information)

    As @FotoFieber points out, the alternating polarity is for a different sensor than the one shown in the wiring guide. We should decide which version to use and stick to one version in the example. I'm not sure which one we should use though.



  • Is there any updated sketch to use with the Soil Moisture Sensor shown in the pictures?


  • Plugin Developer

    The moisture sensor should be presented as S_MOISTURE not S_HUM.



  • Dous this sketch belong to this sensor ? pin 6,7 and a1 or a0 are not connected.....



  • Yeah. It would be great if someone can tell us about the hardware and wiring used in this sketch.



  • Henrik
    Yes could you please confirm how the nano is connected to the sensors ,soil sensors please ,yes 5+ 0- pin 3 ?? or in your sketch pin 6 7 ? to were
    or a0 a1 please how?? pin 6 to pin 3 on nano ?? it just not clear ??



  • For some people it might be worthwhile to look at the Mi Flora sensor, a pretty awesome $10 bluetooth sensor that measures moisture, soilhealth, light and temperature, and lasts a year on one coin cell battery. Its protocol has been reverse engineered, and now a lot of scripts offer all kinds of integrations, including connecting it to MQTT servers or Domoticz.

    https://www.aliexpress.com/item/Original-Xiaomi-Flora-Monitor-Digital-Plants-Grass-Flowers-Soil-Water-Light-Smart-Tester-Sensor-for-Aquarium/32701321129.html

    https://github.com/marcelrv/miflora


  • Hero Member

    @alowhum Thanks for the info. I have one of these and I would like to somehow integrate it with my other sensors. Maybe it would be possible to build a MySensors Bluetooth GW node to connect to the Mi Flora.



  • For those who are using the analogue soil moisture sensor in combination with a nano

    Connect the output of the sensor to the A0 of the nano
    connect the gnd of the sensor to the gnd on the nano
    connect th vcc of the sensor to 3v3 on the nano

    the sketch that works for me:
    // Enable debug prints to serial monitor
    #define MY_DEBUG

    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    #define CHILD_ID 0

    #include <MySensors.h>
    // Here we are setting up some water thresholds that we will
    // use later. Note that you will need to change these to match
    // your soil type and environment. It doesn't do much for me because I'm using domoticz
    int thresholdUp = 400;
    int thresholdDown = 075;
    MyMessage msg(CHILD_ID, V_LEVEL);
    unsigned long SLEEP_TIME = 30000;

    // We are setting up the pin A0 on the redboard to be our sensor
    // pin input:
    int sensorPin = A0;

    void presentation()
    {
    present(CHILD_ID, S_MOISTURE);
    }

    void loop()
    {
    int sensorValue;
    sensorValue = analogRead(sensorPin);

    //send back the values
    send(msg.set(sensorValue));
    // delay until next measurement (msec)
    sleep(SLEEP_TIME);
    }


Log in to reply
 

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.