Saving Water When Raining

With the recent rain I noticed that my sprinkler system continued to do its job, even when the garden had more than enough water. Why not automatically disable the sprinkler when it's raining!

Supplies:

  1. Processor, for deciding when to turn on/off water - Adafruit 32u4 feather
  2. Rain Sensor, to detect the rain - Jaycar XC-4603
  3. Battery, to power the project - Energizer 9V
  4. Solenoid Valve (latching), to block the water flow when needed - Sunshoweronline IVL-NYMV75620DCL
  5. H Bridge Driver, to allow the small processor to control the big valve - Adafruit DRV8871

Step 1: Overview of Components

Rain sensor + Processor + H Bridge Driver + Solenoid = Fixed!

The components:

  1. Processor, for deciding when to turn on/off water Adafruit 32u4 feather
  2. Rain Sensor, to detect the rain - Jaycar XC-4603
  3. Battery, to power the project - Energizer 9V
  4. Solenoid Valve (latching), to block the water flow when needed - Sunshoweronline IVL-NYMV75620DCL
  5. H Bridge Driver, to allow the small processor to control the big valve - Adafruit DRV8871

Step 2: Reading the Rain Sensor

The rain sensor can be connected to either an analog or digital input. The analog returns 0 to MAX of what your analog/digital converter is, say 1024. The attached code reads an analog value then re-maps it. This is done so that we can work with understandable ranges.

Wet

Medium

Dry

Now that we have distinct states we can perform actions based on them.

There is an additional reason that 3 states were chosen. This gets around 'chatter'. If you are just on the edge of one state that opens the valve and another that closes the valve will open and close rapidly, 'chattering' (the sound it makes). To get around this we need to add a 'deadband', a space in which actions are prevented to prevent it chattering. In the next section I'll show how we handle this.

FYI, these concepts are part of Control Systems.

Step 3: Driving the Solenoid

I've chosen a 'Latching' solenoid for this application. This is to conserve the battery. A normal solenoid will down juice whenever you activate it while a latching only does on transition. The complication here is that a latching needs to receive reverse polarity to 'unlatch'. Ie drive it forward to open, and reverse voltage to close. As a result we cant use a relay, we will use a H-Bridge.

This code sets up the two inputs of the H-Bridge then we can send it a valve request of OPEN or CLOSE. The latching solenoid needs power for a moment (I chose 300mS / 0.3 seconds) and then you can release to conserve battery.

Step 4: All Together Now

All the code together

Step 5: Items for Improvement

There is always room for improvement!
  1. Singular Battery - Currently we run from 9V and if you want this to run without assistance, then a LiPo is also required for the micocontroller. To be able to combine these batteries one way would be to use a Boost controller to step the LiPo up to 6V.
  2. Solar - To not touch the system ie change batteries, solar could be added.
  3. Lower Power Consumption - Adding sleep functions will allow us to extend the battery life out so that the solar panel could be lower. Additionally if the boost is added, as digital switch on that so that its consumption is reduced.
  4. Weather Forecast - Rain sensor is good, and internet forecast of the weather is great. Switching to a Particle product or ESP32 will win at this.

Step 6: Thank You

Thanks for following along! Look forward to hearing how you go and how you adapt the project!

Share

    Recommendations

    • Fandom Contest

      Fandom Contest
    • Sensors Contest

      Sensors Contest
    • Growing Beyond Earth Maker Contest

      Growing Beyond Earth Maker Contest

    Discussions