OpenSprinkler Forums Comments, Suggestions, Requests Suggestion on adding a moisture sensor to system

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
  • #62717


    I am interested in using open sprinkler for my watering needs

    I also want to see how to utilize this with my drip irrigation system. I have numerous container plants and want to be able to water them when they are dry as they dry out faster than items in the ground. But I want to be able to control the watering as to not over water the pots.

    I am looking at building and using Wireless Soil Moisture Sensor as in this instruct able

    as it uses a capacitive moisture sensor instead of the cheap bimetal resistive sensors they should last much longer.

    As I am not a programmer and have some knowledge of arduino programming is there a way to integrate the output of the moisture sensor into the programming of the open sprinkler so it will turn on a valve when the reading gets below a set value and turn off the valve as well?

    Also If this could be accomplished your system would be fantastic to use in greenhouses for both seed and vegetative propagation as moisture control is crucial for seed starting and rooting cuttings, not to mention moisture control of sensitive plants such as orchids.

    Please let me know if this is possible and I hope you consider integrating moisture sensors into your system as well.




    also have you seen Vinduino it is a managed irrigation system and has a number of good ideas for irigation as well as utilizing gypsum block moisture sensors which are utilized in several commercial systems, you can also make your own



    Yes, we’ve considered supporting soil sensor but the difficulty is that the sensor ports on OS are all digital pins, so they cannot read analog signals. Technically capacitive soil sensors are digital sensors and they can output a digital signal where the frequency is correlated with the soil moisture. However, I am concerned that as the frequency can be very high, it’s not feasible to have OS read that signal as it will be wasting a lot of CPU cycles just to detect the signal frequency. So at the moment the best way is to use an analog soil sensor connected to a analog to digital threshold converter which converts the analog signal to a binary digital signal with a user defined threshold. This way the soil sensor becomes similar to rain sensor. This is also what firmware 2.1.9 supports — it allows a soil sensor with binary output.

    Hunter’s Soil Clik sensor basically works this way, albeit quite pricy:
    it’s equivalent to a soil moisture version of rain sensor.


    [email protected]


    all sprinkler controller manage up to 2 moisture sensor. But if I have 8 ore more zones, probably I need more moisture sensor!
    I suggest to considered this opportunity.





    If I understand you correctly, you are not measuring rain or soil moisture. Effectively the sensors are a switch – they just switch on (open state) once the sensor reaches a certain preset level, as defined by the sensor, NOT OpenSprinkler. They switch off (normally closed) once the value of whatever they’re measuring drops below the sensor threshold. There are variables (on and off delays) that give some hysteresis in order to prevent false positives and avoid thrashing.

    Flow sensors are different as they actually read flow data while a program is running and will display realtime flow data (at the footer) and display total flow when the program ends.

    That correct?

    What’s the memory usage and cycle time of the current OpenSprinkler code?
    Just wondering how much room there is to add features with the spare analogue, I2C and SPI pins, etc.
    How many digital I/O ports on the microcontroller are free?
    How many analogue ports are available?

    As a basic hack, would it be possible to multiplex sensor signals onto the sensor pins with a “number of sensors per pin” variable so that multiple “alerts” could be processed with the same sensor input pin? That would meet most of the requirements of what I (and I suspect many others) might want? Especially as we could then get away with alert sensors as are currently implemented. (It might require few code changes especially if the sensor reading block is implemented as a function).
    8 sensor inputs would require 4 I/O pins. 16 sensors would require 5 pins. Each additional sensor would require three extra variables (value, on_delay, off_delay) along with the code required to cycle through reading each sensor.

    Another option without using microcontroller I/O ports is to use RF as per your other adventures with weather sensors and power sockets. Would either need an addressing scheme or a form of multiplexing.

    Thoughts? Am I understanding things correctly? (Generally if I think I understand something, I’m not really comprehending the full complexity of a situation). 😉




    Oh. Using a 74HC165 for the input sensors would require 4 pins from the Microcontroller.
    using a 4021 multiplexer would require 3 pins.

    If there is I2C on board, then a MCP23008 (or MCP23017) would be a great option. No extra I/O pins needed at the expense of loading an I2C library. Pullups/pulldowns can be implemented making this quite reliable.

    If SPI is available, then the MCP23S17 would be even better!

    Can probably pinch the clock signal used to drive the HC595 output shift register if you’re still using that in the V3 board.




    @BratNZ: sure, the sensor pins are digital pins so obviously they can only read digital signals (on or off). ESP8266 unfortunately only has one analog pin and that’s already used for reading solenoid current. For that reason the sensors are assumed “switch” sensors, and not analog sensors.

    Flow sensors are also switch sensors basically, though they click at much more rapid pace compared to rain or soil sensors.

    “What’s the memory usage and cycle time of the current OpenSprinkler code?”
    – At resting state, OS 3 has about 27 to 30KB RAM available. There is also plenty of flash memory space, so you can expand the firmware quite a bit. About ‘what’s the cycle time’ — I don’t know what you mean by cycle time. If you are really worried about RAM and flash memory space, you can use OSPi, which is based on Linux.

    “How many digital I/O ports on the microcontroller are free?”
    – On OS 3, none, because all GPIO pins are used. However, you can expand GPIO using IO expander — that’s also how OpenSprinkler expanders work, they use PCA9555 I/O expanders on I2C line.

    Again, I think if you have complicated processing need, you should consider using OSPi, which has pretty much unlimited processing power and storage.



    I am a newbie to Opensprinkler. I have written a couple of Arduino programs (very basic) recently and used to write software programs in C 10 years ago. I am trying to see if I can setup a soil moisture sensor with opensprinkler to water my lawn and tie in alexa echo do to get updates on my lawn watering. Also, maybe update the mobile app with any new features I can think of (this is for later).

    Can you please tell me what are the best components I should buy to accomplish this? It would be great if you can suggest the moisture sensor as well. Is it better to plug the moisture sensor to a raspberry Pi board and have the Raspberry PI connected to Opensprinkler PI?

    Thank you for your guidance. I am a novice willing to put in the effort to learn. Thank you.



    Well here this is AGAIN since it vanished from the blog after making 1 edit on a typo:

    I have been working on this myself and let me explain my approach. First of all the idea of tying a soil sensor directly into OS is, in my view, a waste of time. The reason is that there’s a lot of processing and logic that is needed, too much to load down on OS. So here is my approach:

    1) Setup OpenSprinkler (either buy an outright Open Sprinkler controller or build one based on a Raspberry Pi (the second thing is what I did mainly because I wanted an excuse to learn about Raspberry Pi’s but trust me unless your time is worth nothing, it’s way cheaper to buy the entire OS unit ready to roll)

    2) Setup a Vera Home Controller.

    3) Install The Open Sprinkler app from here ( He should have it updated in the Vera Store by now but if not you can install it manually

    4) Build a waterproof soil probe such as detailed in the Instructible referenced above a few posts ago. The one in the instructible is unsuitable because it’s not waterproof and it’s not powered remotely but the idea behind it is good.

    5) Write a Vera app that communicates with the soil sensor

    6) Build and install a weather station around an arduino or raspberry pi

    7) Tie this into the Vera

    8) Write a scene in the Vera that manages sprinkling using the soil moisture and weather conditions. This is a lot more complex than it looks because of a number of rules:

    a) you don’t want to water on days with low humidity because a lot of the water evaporates before going into the soil
    b) you want to have a day or so where the sun thoroughly dries out the plants and surface of the soil or your are going to promote moss & mold and mildew growth as well as rot the plants
    c) you don’t need to water as much when it’s cloudy because the decreased solar radiation means the plants activity is a lot lower and they are not taking up as much water
    d) Soil water level only tells you the moisture where the probe is not the entire lawn so if you wanted to go off soil moisture you would need a bunch of probes
    e) you don’t want to water when the weather forecast says it’s going to rain tomorrow

    Professional agricultural like golf courses and farmers use cameras pointed at the plants, weather data, and seat-of-the-pants, thumbs-behind-the-britches experience to control watering and they are constantly tinkering with it. But they are running thousands of gallons of water and have labor costs for moving the sprinklers, and electricity costs for pumping water that make a mistake very costly. Lawn care companies that program sprinklers for homeowners simply over-water because the homeowner isn’t going to scream at them if their water bill is high but they will scream at them if the lawn is brown. DIY gardeners use the “stick finger in dirt and look at it to see if it need water” method which is the most accurate way of doing things – as long as they do it every single day – which 90% of them don’t.

    The goal of a watering system is to approximate the “look at it and stick finger in dirt” method as close as possible with software and the end goal being to use only the amount of water the plants need to have and no more. Unfortunately that is a lot more complicated than just attaching a soil sensor to the sprinkler and sitting back and letting it do it’s thing.

    I’m basically at step#4 right now. Unfortunately I have a ton of other stuff on my plate right now so I likely won’t be able to get on it for some time. I started this 3 years ago with a remote lawn 90 miles away, and Rainbird sprinkler controller at the lawn and nothing else, so it has taken a lot of time and work to be able to get to step #4. But at this point I can see the lawn (remotely) turn on and off the sprinklers and set a sprinkling schedule, so at least I am no longer operating blind.

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.

OpenSprinkler Forums Comments, Suggestions, Requests Suggestion on adding a moisture sensor to system