1. Seedlings need blowing around a bit when they pop out or they get all spindly. Cue wiring up two 80mm PC case fans to a chain of a single astable then two monostable 555's to generate an oscillating wind field that goes on for 5 seconds each direction after a delay of 10 minutes. Dried the compost out, blew most of it it away and then killed the plants dead. No tomatoes for me!
2. Watering robot version 1. Similar to above but with a 74hc390 dividing down the clock so it only ran once every day. Used an unprotected MOSFET to control a small water pump from ebay. Back EMF blew the MOSFET up and jammed it as a short. Emptied the entire water reservoir into the pot, down the wall and into the carpet.
3. Watering robot version 2. Same as above with problems fixed. Apart from I ran out of bipolar 555's so I used CMOS ones which are a little more tetchy about noise. Cue last 555 getting jammed in an on state and the same thing happening. This time, the tupperware box with the electronics ended up getting wet and the wall wart exploded.
Edit: meant to say to the OP - nice work. This is the spirit of all things interesting :)
We bought some pot plants to keep alive and some cheap soil sensors; they're just two electrodes and you pass a current through the soil, measure the resistance and get a proxy for soil moisture. We left the sensor continuously logging on Friday, came back on Monday to find the plant very unhappy and the probe contacts almost completely corroded. Within a day or two it was a stump, never recovered.
Turns out you're not supposed to leave these things powered on 24/7 and capacitative sensors are a much better solution. TIL you can electrocute plants.
Details above. Looks like you can get 3.5ps resolution with an off the shelf PIC after calibration which is pretty impressive!
So the price is..
3$ for the microcontroller, 3$ for the 4 ns comparator, and a few cents for the resistors, capacitors, and 7 GHz transistors (I couldn't find the exact model), and probably some dollars for the rest of the materials such as steel rods and tubes. All in all it looks doable for <50$ easily. That's pretty amazing!
On the PIC solution you posted, how do you get around the fact that the comparator is only good to 4ns (regardless of whether you can time down to 4ps)? Lots of measurements and look at the stdev?
Ones that worked eventually: http://imgur.com/a/EDdwR - note cable ties :)
What a lovely way to learn about the world ... by taking copious notes about all of the (surprising) things that don't work.
I'm slightly tempted to do a 4th attempt now inspired by the original poster :)
(you need to stick a transistor between the 555 and the relay anyway so you might as well just use a MOSFET)
Good tip: measure voltage between the output pin and gnd or Vcc in both states and then have a think.
Plus when you're not an idiot like I was, a MOSFET is cheaper.
I sometimes overestimate the ability of the average electronics hobbyist to properly understand a datasheet.
Looks like a cool project.
The mark of the start of any good hobby project is a sense of humor about the time it really takes to accomplish something simple with technology on the first go-round.
However, Vegetronix makes an ultrasonic soil moisture sensor that does not have electrodes, and thus does not corrode. It is far more complex and expensive ($40) but it's designed as a moisture sensor for sprinkler systems and as such is engineered to be left in the ground.
Edit: Link to Vegetronix sensor: http://www.vegetronix.com/Products/VH400/ . I have used it and it works well, but as it turns out, even this is not sufficient to really automate a garden. You need fertilizer. Hydroponics make dealing with that complication much easier -- until you realize that the fertilizers are caustic / acidic enough that you have to flush the lines with water as well...
In other words, there's a pretty good reason you can't buy a kit off the shelf that will grow plants :)
Actually - I've had great luck with an AeroGarden. A friend got me their Harvest Touch model in the fall, and I successfully grew herbs all winter.
Then this spring I started tomato seedlings in it, and had far-and-away the most successful tomato seedling starts in my decade of trying.
My model is the Harvest Touch - which tells you when to add water and fertilizer on a screen. But there are more advanced models that connect via WiFi: http://www.aerogarden.com/aerogardens/wi-fi-aerogardens/mira...
I don't see much value in the "smart" features, but as far as easy-indoor hydroponics, they really can't be beat.
The one thing that made my scratch my head was your approach to measuring moisture. There are several very reliable methods for measuring soil moisture directly (changes in resistance, capacitance, time domain reflectometry, etc) that will give you exactly what you are looking for here.
"Therefore, we felt it was fair to assume that watering based on moisture level is impossible and that GreenPiThumb is doing the best it possibly can, given certain inexorable limits of the physical world."
This just isn't true. The sensor you picked up from Sparkfun should give you decent measurements for a while before degrading gradually depending on your soil chemistry.
 I ran a consumer soil moisture IOT company for a few years that was sold to Scotts Miracle Gro in 2016.
Currently I'm using this one: https://www.adafruit.com/product/1298
But after 3-4 waterings, it reads 95-100% consistently, regardless of the temperature. I've tried 2 of their sensors and have had the same problem.
Can you point us in the right direction on this? The wiki doesn't make it clear how it would be used for measuring soil moisture.
I haven't looked at the industry in a couple of years, but I think that many of the high-end commercial sensors use some variation of this technique.
Your moisture problem could just be that you were relying too much on the water evaporating/being absorbed rather than needing to drain out. Gravel at the bottom of a pot with holes in helps water drain really well. Alternatively, without the gravel you could place the pot on a dish, fill the dish and let the water be absorbed from the bottom up.
Alittle more details about watering:
IIRC many plants grows best in the long run if watered thoroughly and then left to dry up a bit in between.
The reason for the drying is the drying causes the roots to grow. And the reason for why it should be really soaked when watered is so that the roots will stretch towards the bottom instead of spreading out on top.
(Correct me if I'm wrong, I left farming school almost half my life ago && English is not my mother tongue.)
Also I get the sense that I shouldn't just be leaving standing water in the tray forever, but it's also pretty difficult to remove the tray and empty it.
This way, it cannot get to Wet, and you could just Pump that Pot full with watter, any excess watter, will just drain through the Soil back into the reservoir :)
Haven't had the chance to try it out in soil yet, but reading the comments it looks promising. It uses capacitance instead of resistance and connects directly to the I2C pins of the Pi. So, easier to setup and should be more reliable.
On the software side I use Grafana
Not really made for gardening projects but its monitoring and alerting capabilities are pretty much perfect for this kind of application. Not to mention how easy it was to set it up on the Pi and get all (temperature, moisture, light) the sensor data in.
They use capacitive sensing and they're enclosed and waterproof.
I highly recommend them.
I have found them to be reliable and accurate. No failures yet in about a year and a half.
I usually adhere to the old "you get what you pay for" mindset, so I have no problem spending more on something I can rely on.
For pump and other peripheral control I plan on using an opto-isolated relay board. You can get one for really cheap and they're easy to setup with the Pi. Check this wiki on how to use the board in isolation mode.
Of course the later heading "the gardening wasn't supposed to be hard" seems to imply that he assumes non-coding skills are easy to figure out or obvious, which is a sadly too-common trend in the tech world.
We did look for gardening supplies that would spread the water out, but everything we found was designed for large fields or at least small gardens, not single planters. I'm seeing the same thing now when I Google "irrigation system parts." Looking at drippers, I'm not seeing how it would solve the problem. Doesn't it just drip onto a single spot?
- measuring air moisture of small upside down cup on top of the soil
- measuring weight of the whole pot
OTOH indeterminate tomato plant, for example, weighs a lot, and the weight would also be affected by picking the fruit.
I've grown some glorious plants on my desk at work with exactly that method. When the ends get a little droopy, I water them heavily.
You can also use a peristaltic pump for accurate watering and adding in nutrients, or adjusting pH. Sparkfun even has a kit (https://www.sparkfun.com/products/12915) for its automated bartender.
That's at least partially how my finger works as a sensor. A finger test probably picks up sponginess too.
This may or may not work depending on location of the plant. If it's in changing temperaturs and direct sunlight, there will be periods where it needs more water.
Here's a picture of my setup.
I have a enclosure (that I recently made waterproof) that sits out in my garden that has the ESP8266 wireless chip in there, which works very similar to an Arduino with built in WiFi. I have it reading data in from a soil humidity / temp sensor, an air humidity sensor, a light sensor, and a air temperature sensor.
That data gets sent back to a simple django webserver that I have running (indoors) off of a raspberry pi. It records all the sensor readings every 10 minutes and registers them to various plots in my garden. And then, if there are any big issues (no light for 2 days, lower than average soil humidity or soil temperature, etc), it texts me.
Eventually I'll connect it to my irrigation system, but I don't trust it enough yet!
I have the exact same problem with soil humidity sensors that you mentioned. I even sprung for some fancy ones (http://bit.ly/2sMNRnD) that claim to be waterproof. I cannot make them read useful information and, once it rains or I water outdoors, the sensors read 99% for the next few days. It's very frustrating and the missing piece to make all of this work.
Like you, this started as a quick, month-long project and now it's become something a lot bigger :)
I think eventually I'd like to build this out to be a vegetable garden planner, so I can plan my vegetable garden at the start of the season, monitor what's happening with them, and automatically trigger my irrigation system if needed.
Anyway - it was great to read this! I'd love to hear how this project evolves and would be happy to share any of my experiences as I've put this together.
P.S. And, it's a long shot, but if you (or anyone is reading this) figures how to accurately measure soil humidity temperature in a waterproof environment, I would be forever grateful!
I don't understand TDR well enough to explain it, so I will let you search for your own info. The cheapest usable TDR sensor is about $350.
Tension has a simple analogy; a Slurpee (is that trademarked?) is easy to drink through a straw in the beginning, but it gets harder to pull the liquid up the straw as you drink more of it. That's tension and plants also struggle to pull the water from the soil depending on lots of factors including the composition of the soil, the amount of water present, drainage, etc.
There are several sensors that can be used to measure tension but none are accurate in all conditions, so people who want to measure tension tend to use multiple sensors of different types and triangulate on a useful number.
Large scale farming (in dirt across thousands of acres) is where the complex sensors are needed because the soil attributes are not uniform.
When you're gardening in a pot indoors or in a greenhouse with the same soil everywhere (because you bought bags of it), you can use those $0.43 resistance probes and just calibrate your watering amounts and intervals over time. Pump on for X units of time, ignore for Y units to let the water move through the soil, then sample every Z units until it needs more.
Then one needs a/two metal piece of defined length, and a high-frequency oscilloscope, that can also give a pulsed signal (ideally of high frequency).
The biggest issue I see is that you'd need something like at least 0.5 GHz resolution in the oscilloscope with a metal piece of 25cm (quick mental math and some guesses, don't hold me to it). Probably better to have at least 2 GHz. I don't think computers and software alone is up to it after a quick search. Maybe one can increase the travel time in the probe (metal stick) somehow to lower the needed resolution, but not by orders of magnitude.
Your project looks really cool! Is your code open source? I'd love to check it out.
The cheapest DIY solution I could think of was ESP8266 ($2), Vreg ($.5), moisture sensor ($.5) and LiPo battery (i have many of these..) but I decided I didn't have time or inclination to write the software.
I continued looking for commercial products, and ordered one of these: https://www.aliexpress.com/item/Chinese-Version-Original-Xia...
Pros- Cheap ($15). Has temperature, light and 'fertility' (capacitance?) sensor.
Cons- Logs to phone app (in chinese) via BTLE instead of WiFi.
After a few weeks it seems to be working satisfactorily and I will probably order a few more units.
Not that there's anything wrong with building your own device. Just don't lie about it.
I have a few plants I wanted to monitor, so price is more relevant- $300 is more than I'm willing to pay. I think you underestimate how much of the world thinks $60 is unreasonable for such a device, but i don't suppose there's a way to know which of us is right :)
A flyback is critical in anything involving a magnetic field, especially a collapsing magnetic field from a motor that stops spinning. The field collapse induces a relatively huge current which will be many many many times greater than anything a normal component is designed for.
Not having one is like driving your car down the highway without any breaks. The only way to stop is to crash.
So your suggestion is actually introducing a second magnetic field, so now you've doubled the chances of blowing up your Pi and or the MOSFET.
Whether you're using a transistor/MOSFET directly with a motor or instead with relay + motor you need the flyback diode.
No. You haven't fixed the original problem, but your motor is now isolated from the rest of the circuit.
You've just now have a relay with an inductive element instead of a motor. Ultimately, you haven't solved anything (unless you are using an AC motor, and you don't have a triac or something else solid state to control the motor). You still need the flyback diode.
But you haven't doubled your problem by introducing a relay, merely moved the issue to another part.
Now - in regards to the mosfet - many mosfets (not all!) have a built in protection diode between the source and drain. Check your datasheet for details (including what kind of back-feed voltage/current can be handled by them - some may need an added diode with better ratings in detail).
EDIT: Also - some relays have built-in protection diodes (or can be ordered as such) as well (again, check the datasheet). You see this more on relays for automotive applications (ie - standard BOSCH style relays) than ordinary bare PCB relays.
Now think of all the electricity as one big wave. Cause that's what it is. If you were running 12v , you can see upwards of 30v surge. This is bad.
The key is to equalize the power on the motor. And that's done by putting a diode in the reverse flow across the terminals. So that big flow of electrons can equalize itself BEFORE hitting other silicon (like the MOSFET or your RasPi).
Ideally, you want to do this for motors, electromagnets, solenoids, and inductors(well, unless you're doing an L-based filter , but aside the point). They all have this magnetic energy->electricity->surge thing going for them.
Attempts to measure these spikes on a cheap scope years ago ended up blowing the scope input FET up. Whoops. Good job it was a university owned scope :D
Yeah - they make special high-voltage probes for this kind of thing (some can go up to 10 Kv and beyond - just depends on how much money you want to spend).
I believe that the main difference between a standard probe and an HV probe is one of resistance; I think the HV probe puts a large value (mega-ohm) resistor into the mix (not sure if it's in series, or between the probe input and ground - see my further note below).
If you have a scope, it's handy to have one around "just in case" if you can afford it. I got lucky myself; I found one for a few dollars at a local Goodwill thrift store (the strange stuff you can find there...)
Hmm - I decided to look a bit more into this - I guess things on HV probes can get complicated quickly!
So - a basic probe is just a voltage divider with large value resistors (like I alluded to earlier); but as the frequency increases, lots of other weird and fun stuff come into play (and in the comments section of that article, someone mentions special chemicals that had to be added to certain special probes he used in the past!).
Technically frequency compensation is required across all voltage dividers for scopes so not to accidentally create a low pass filter with the parasitic capacitance in the cables and input circuits. It's all quite fun.
Disclaimer: was an obsessive compulsive scope collector for a while.
Drain the water back into the reservoir (use a simple filter to prevent damage to the pump) and just use a schedule for watering.
I used a mechanical timer switch for 15 mins every hour for my hyrdo setup. For soil, such tiny plants, and no lights you would need far less frequency. A general rule of thumb is to give it enough time between waterings to let it get a bit dry.
How much time do you think it should go between waterings? The first batch, we kept waiting for the soil to get really dry, but weren't sure if it should just be not very damp to the touch or like as dry as before we put water in at all.
If the differential is tending to 0 then it means that not only the soil is saturated, but the plant is as well. This is _quite_ a basic concept, since you do not want a fully saturated soil all of the time.
A proper biological approach is to estimate how much water exactly the plant needs per unit of time, and then make sure the differential is always exactly that amount. This is not an exact science, especially when you're only working with a single plant and your conditions are probably far from ideal.
This approach would easily take into account other hidden variables, such as the rate of evaporation of water from the soil that depends on the ambient temperature. It also scales to hydroponics.
A rough ballpark on watering cycles is usually good enough. I'd watch the leaves to give you an idea. I'd stop watering and wait until the leaves show signs of under-watering and then use slightly less time as my watering period. I'd guesstimate based on your setup that the period will be measured in days.
IMHO if you're going to have that much set-up you might as well go hydro.
And, as I'm assuming the real aim is to build cool things perhaps you could use Deep Learning to do leaf classification (Over Watering | Under Watering | OK). That way you could use a webcam to control the watering instead of the sensors. Knowing your watering times and regular classification samples you could use a fourier transform to help identify the optimum watering period. Perhaps someone could do this as an API service. I do Deep Learning on images as my job so if you want I could tell you how to create the training data and once you have that I could train a classifier for you.
Quite an advanced bot: as close to a human as you can get!
Are there any industrial plant moisturing robots? What approaches do these use?
Edit: I met this guy a few months ago at a faire: https://lambdanodes.wordpress.com/ The project doesn't seem to have advanced since then, but maybe he'll get better results with his epsilon node.
Sure there are. They look like this: https://upload.wikimedia.org/wikipedia/commons/8/86/PivotWit...
I assume you mean the second/third definition of "robot," since GreenPiThumb doesn't look like a human. https://www.merriam-webster.com/dictionary/robot
Using our guy's own sawtooth model of watering/drainage, it would make more sense to just water at fixed intervals and experiment with the frequency to see if the plant grows.
Still a fun project!
With those you can have 6 plants on a single 47l tank and only re-fill it every month. (depends on how thirsty they are)
It's a gods send when I want to go away for a few weeks vacation.
For other house plants that are not connected to a huge water tank I tend to just turn over a 2l plastic bottle into the soil after thoroughly saturating it first with water.
So with this the only real requirement I had for my grow op was monitoring. Because I have hard wood floors and I don't want them to swell up due to a leaking tank.
For those who don't want to / can't pay for it (eg the developing world), burying unglazed pots will also work. It's probably the most water-efficient method in arid land. The technique is at least 4000 years old.
While it sounds scary, hydroponics is much easier to automate. Use a substrate like grodan blocks that can't be overwatered, and have it drain back into the reservoir you are pumping from. Then it's just a matter of setting your cycle time appropriately, and watering for x seconds every y hours, and changing the water after a set number of days, and adding new nutrients. By using more water than you need without risk, you can ensure an even level of watering over the entire medium.
It's also much easier if you have a nutrient problem as you can easily flush with a large amount of properly pH'd water to 'reset' your substrate, which is very hard to do with soil.
This doesn't even get into things like potting mix typically has eggs for all sorts of pests, if not pests themselves. If you are lucky and get a clean batch, you are still providing a great environment for pests to live.
While it does cost a bit more to do hydro, it's honestly not that much. If you want to be super cheap you can use pH papers or by a $20 pH pen. A starter nutrient kit from general hydroponics should be under $30.
PS - here's a link to my raspberry pi automated hydro system on hackaday (https://hackaday.io/project/12418-garden-squid)
There are many wifi enabled switches to enable the water pump. Try out the ESP8266 and/or ESP32 in your next project.
Your mind will blown with the possibilities :D
Also, you may loose the soil and go for hydroponics, that would make this really from the future.
What a great idea! (Especially since his "dirt is broken"). :-)
Also just took me a few evenings instead of months.
I was running through moisture sensors on a weekly basis until I hooked it up to the GPIO on only flipped the power on when I was taking a reading. Now I get readings every 10seconds and haven't had to replace the sensor in over 6 months.
Edit: Was using something similar to this board:
I think RPi is a overkill for this project.
Not when you consider the goals of their particular project and the experience of the author(s), as he does explain.
Also, this makes me think. I have two Raspberry Pis lying around. One is a glorified video player, the other one is just catching dust right now. I have wanted to do some kind of hardware project with it for a while, but I am kind of lazy and have pretty much no knowledge of electronics.
I have wanted to build a weather station, though, that keeps a long term record of its measurement in some kind of database. A Pi would be well suited for that, so I might get around to it one day after all.
I use irrigation tubing with drip line emitters in my garden. That might be a solution for you. The cool think about the emitters is that they control the flow of water and are easily positioned. I think they start at .5ga/hour on up to 10ga/hour.
Is that true? If so, that would explain why the sensor doesn't work here, but leaves me wondering why I've seen so many projects try to use the sensors that way.
1. why use a water pump, instead of a gravity-fed system with a valve you could control with a servo?
2. Would a scale be able to measure soil moisture? Dump in X grams of water, wait until scale registers X/2 before adding more. (Some fiddling would be required to see how much of the water is retained by the plan as building material.)
2. Generally not; a plant's water consumption is not steady over its lifetime.
I eventually moved on to hydroponics. Soil is just too "analog" for most of this stuff to work. Hydroponic kits are available on Amazon for cheap, though the main measurement you end up doing with hydroponics is pH measurement -- and I am not aware of any "hands off" sensors capable of accurate pH measurement that are remotely affordable.
The biggest pain with hydroponics is that you do have to totally change out the water periodically. That gets difficult, because you have to add nutrients, and those nutrients are pretty caustic, cannot be pre-mixed and actually need to be mixed into the solution in a certain order...
After a while, these "automated garden projects" end up becoming basically industrial control/automation projects with complex rulesets, programming schedules, etc. It was fun and I learned a lot, but it ends up being a much bigger project than you assume when you start.
Thanks for your reply, though. I'm starting to think about doing something like this, despite all the warnings in the original post and all the comments that it's basically doomed to failure.
And the ironic part is that it's actually not hard to cobble together an effective automation setup using some analog electronics like a cheap light timer, an AC fan controller, and a $20 automatic watering gizmo from the hardware store. I had a hard time building a more effective solution using an RPi or Arduino.
Kidding, it's a project I worked on with my friend. I maybe should have made that more visible at the top of the post.
I actually love the Pi---one is now my primary computer---but it seems to have created a niche for "let's add a website and database to my really trivial control systems project" that I'm not sure really advances much of anything.
According to the Merriam-Webster, this arguably fits two of the three definitions of "robot".
I guess you could say that measuring soil moisture and adding water isn't "complicated" but I would also disagree with that assessment.
2: a device that automatically performs complicated often repetitive tasks
3: a mechanism guided by automatic controls
The addition of the camera makes me think that a Pi might be a better solution.