Advise for water sensor

Hello everyone,

I could use some help in selecting hardware for a water level sensor. I was hoping something would already excists so that I could jump into integrating the solution quickly but so far I haven't found what I'm looking for. Perhaps I'm thinking/looking in the wrong direction so let me first explain my modern world problem :wink:

I'm not very kind to my plants. I generally don't water them in time. First I put it on my work and the traveling that comes with it but this pandamic year brutely exposed my own pure shortfall. I just forget! Last year I started to replace my traditional plant pots with ones that have a water reservoir. Depending on the plant and size of the pot you only water them once every few weeks. Great for the holidays to come! But it turns out that I forget to water them even more!

Below is a picture of how these pots work. There is a water reservoir under the plant with 4 or 7 cm of water. There is even a water level indicator which I consistently seem to ignore!

What I would like is a small, battery (ie CR2032) powered, sensor that can report wireless to Home Assistant when the water level is zero. Through MQTT, for example, but anything else will do too. Getting the state once a day should be enough. Nicer would be to have multiple states (100%, 75%, 50%, 25%, 0%) and perhaps increase the update frequency to 2x a day. But this is all extra.

I looked at several sensors and projects but they come with different kind of ceavats. They use a big board that consumes too much power for a small battery like the CR2032. My best bet would probable be to have 1 or more read relays? Perhaps then I could only initiate an update when the level has changed? Or I could try to read somehow the level of the existing level indicator. This basically is a cork on the water, pushing a red plastic pin up or down.

Any thoughs are welcome.

ps I thought about getting a common available moist sensor which would work for the inside plants but I'm using the same pots for outside and then rain could generate false readings.

I use capacitive soil moisture sensors. I used hot glue to cover the electronics and connector to keep the tronics from being damaged by the water.

I sense to a level of 20% remaining, then I energize a valve and start a small pump motor which runs for 5 seconds. After the pump turns off, measurements are taken for 1 minute, if the moisture content is still low then another 5 seconds.

I found that the pump needs a valve to stop siphoning from happening.

I found that if I let the pump run till a 40% reading then after a few minutes will put the water content at 80% or more. It takes a while for the capacitor to catch up with the moisture content. My motor pumps 1 ounce in 5 seconds.

I use MQTT to transmit the moisture levels to my web site and, from the web site, I can change the moisture level trigger point, manually turn the pump off and on, and put the project in standby.

There are float switched available for about a dollar on eBay, but whatever you do involves gear all over the place. Wouldn't be simpler to just set up a font system. No batteries to go flat, and no Arduino either.

Thanks @Idahowalker for your input.

Do you mean to say that when you are measuring the moist level with the capacitive moist sensor, the measuring needs to be done for a x time? Or when watering, the moist in the soil takes some time to be spread before the sensor picks it up?

I'm thinking about combining the moist sensor with level switches on a wifi capable microcontroller and upload the data once or twice a day. Depending on the power usage when measuring, I consider doing multiple measurements between the data upload.

Which board do you use and through what which data connection? WIfi, xbee, RF? Is it battery powered and if, what battery did you use and what is the durability?

@Nick; I see your point, though I hope to find a solution with simple equipment. A font system (if I understand it correctly what this is), is quite complicated as the plants are scattered all over the house or garden.

rob789:
Thanks @Idahowalker for your input.

Or when watering, the moist in the soil takes some time to be spread before the sensor picks it up?

You got what I was meaning to write.

rob789:
I’m thinking about combining the moist sensor with level switches on a wifi capable microcontroller and upload the data once or twice a day. Depending on the power usage when measuring, I consider doing multiple measurements between the data upload.

Which board do you use and through what which data connection? WIfi, xbee, RF? Is it battery powered and if, what battery did you use and what is the durability?

Here is my moisture level code. I use WiFI. Not battery powered.

Moisture is read 4 times a second. Every 5 seconds the moisture level is published to the MQTT Broker for storage in a database.

I can, from my website, turn the pump on or off and set the moisture level.

void fDoMoistureDetector( void * parameter )
{
  //wait for a mqtt connection
  while ( !MQTTclient.connected() )
  {
    vTaskDelay( 250 );
  }
  int      TimeToPublish = 5000000; //5000000uS
  int      TimeForADreading = 100 * 1000; // 100mS
  uint64_t TimePastPublish = esp_timer_get_time(); // used by publish
  uint64_t TimeADreading   = esp_timer_get_time();
  TickType_t xLastWakeTime = xTaskGetTickCount();
  const TickType_t xFrequency = 10; //delay for 10mS
  float    RemainingMoisture = 100.0f; //prevents pump turn on during start up
  bool     pumpOn = false;
  uint64_t PumpOnTime = esp_timer_get_time();
  int      PumpRunTime = 5000000;
  uint64_t PumpOffWait = esp_timer_get_time();
  uint64_t PumpOffWaitFor = 60000000; //one minute
  for (;;)
  {
    //read AD values every 100mS.
    if ( (esp_timer_get_time() - TimeADreading) >= TimeForADreading )
    {
      xEventGroupSetBits( eg, evtADCreading );
      TimeADreading = esp_timer_get_time();
    }
    xQueueReceive(xQ_RM, &RemainingMoisture, 0 ); //receive queue stuff no waiting
    //read gpio 0 is water level good. Yes: OK to run pump : no pump off.   remaining moisture good, denergize water pump otherwise energize water pump.
    if ( RemainingMoisture >= 40.0f ) 
    {
      WaterPump0_off();
    }
    if ( !pumpOn )
    {
      log_i( "not pump on ");
      if ( gpio_get_level( GPIO_NUM_0 ) )
      {
        if ( RemainingMoisture <= 20.0f )
        {
          //has one minute passed since last pump energize, if so then allow motor to run
          if ( (esp_timer_get_time() - PumpOffWait) >= PumpOffWaitFor )
          {
            WaterPump0_on();
            log_i( "pump on " );
            pumpOn = !pumpOn;
            PumpOnTime = esp_timer_get_time();
          }
        }
        //xSemaphoreGive( sema_RemainingMoisture );
      } else {
        log_i( "water level bad " );
        WaterPump0_off();
        PumpOffWait = esp_timer_get_time();
      }
    } else {
      /*
         pump goes on runs for 5 seconds then turn off, then wait PumpOffWaitTime before being allowed to energize again
      */
      if ( (esp_timer_get_time() - PumpOnTime) >= PumpRunTime )
      {
        log_i( "pump off " );
        WaterPump0_off(); // after 5 seconds turn pump off
        pumpOn = !pumpOn;
        PumpOffWait = esp_timer_get_time();
      }
    }
    // publish to MQTT every 5000000uS
    if ( (esp_timer_get_time() - TimePastPublish) >= TimeToPublish )
    {
      xQueueOverwrite( xQ_RemainingMoistureMQTT, (void *) &RemainingMoisture );// data for mqtt publish
      TimePastPublish = esp_timer_get_time(); // get next publish time
    }
    xLastWakeTime = xTaskGetTickCount();
    vTaskDelayUntil( &xLastWakeTime, xFrequency );
  }
  vTaskDelete( NULL );
}// end fDoMoistureDetector()

Oh, I use a self priming pump. I have a electric valve attached to the output of the water pump. After water pump is ran, water can still flow from a siphon effect. When the motor shuts off the valve loses power, the valve closes, stops the siphon.

A bjt transistor would do with a couple or wires.
Or for a bit more sophistication, a simple CMOS logic chip would do as well.
A four gate NOR chip like 4001B could do the sensing, provide a latched output and provide an alarm LED buzzer alternating output.
A bjt transistor could give you an open collector output for interfacing.
I've just done a circuit for leak detection based solely on the 4001B that has a quiescent current draw of about 3 microamps and works well down to 1.75 volts, though designed for 3-volts.
The sensor bit uses a SR gated latch, and the flasher is an asymmetrical flip flop.
Sensitive enough for damp finger on one hand and ground or Vcc on the other to trigger.
For better results on the flasher, use a third gate to clean the pulses up.
A Google search will provide plenty of information.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.