185 comments

[ 4.3 ms ] story [ 248 ms ] thread
Hmm. A MOSFET for a motor switch might be overkill. Also, there's no flyback diode. So your Pi pretty much will let its blue smoke out when you get a flyback voltage, or at least the MOSFET.
That sounds... undesirable. Electronics is definitely not my area of expertise, so I'm very open to feedback. What do you recommend?
When MOSFETs get hot, that usually means the gate voltage is too low. It looks like your driving the MOSFET gate through a resistor voltage divider. It would be better to drive the gate straight from the PI's GPIO pin. Also a flyback protection diode would be a very good idea.
Wouldn't a relay be easier to integrate? and also keep the pump power circuit isolated from the pi power circuit?
Anything involving collapsing magnetic fields, eg solenoids, relays, motors, absolutely simply has to have a flyback diode.

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.

> 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.

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.

Read up on flyback diodes. There are additionally numerous motor driver IC's specifically for this purpose.

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.

I haven't done much electronic stuff in a good seven years, but this is typically what you would use a relay for, right?
You'd still want a flyback diode, as the voltage spike will arc across the contacts of a relay as well, shortening their life.
Yep was going to say exactly this. Anything involving collapsing magnetic fields, eg solenoids, relays, motors, absolutely simply has to have a flyback diode.
Incidentally you can demonstrate this by wiring up the relay so it oscillates i.e. use the NC contacts in series with the coil. Then stick your fingers across the coil. It'll give you a nice shock. Not enough to hurt you but enough to go "hmm, I'm not going to do that again" like licking a 9v battery.

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

> Attempts to measure these spikes on a cheap scope years ago ended up blowing the scope input FET up.

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...)

Note:

Hmm - I decided to look a bit more into this - I guess things on HV probes can get complicated quickly!

https://www.repairfaq.org/sam/hvprobe.htm

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!).

Yeah the Tektronix HV probes used to come with an aerosol can and you had to fill them up.

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.

Something that also exists (but are mainly used on pure or nearly pure electrical systems - think old-school, pre-microcontroller/cpu ladder logic relays and controllers) are "quencher resistors"; these were resistors placed across the coil to absorb the voltage spike. You sometimes see them on automobiles, mainly older vehicles.
Long and short, motors store power in magnetics when electricity is flowing. When its not, the coil loses its magnetization and turns back into electricity.

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.

So great to read. This is exactly the kind of project the Raspberry Pi was designed to enable - doing something a bit odd (and arguably pointless!) but having fun and learning loads along the way.
One of the better laid out Pi project summaries I've seen. Good work, I say.
Did the pot you use have holes in the bottom? It looks like you have it just sat on a desk so I'm assuming it's basically just a bucket?

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.

Yeah, it drains into a little tray underneath. I'm trying to figure out a better solution for that because we can't see how much water is in the tray, so if too much has drained out, it starts overflowing onto the table with no warning.

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.

Put some pebbles on top of the tray to raise the pot off of it, so it's not sitting in the standing water.
Oh that's a good idea. Thanks!
I usually throw a base of pebbles / marbles into the bottom of any pot before I put the dirt in, which also aids in draining.
Put another sensor in your tray wired up to your UI, so as soon as the sensor goes from 0% to 100% for moisture, you know to empty your tray.
what if the tray was the way to detect moisture level? or, you could drip it back into the supply water?
Why not connect your tray, back into the Watter reservoir?

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 :)

If you are growing from seed, does the bottom up absorption still work or do you need roots first? I tried googling this but I'm reluctant to visit some of the "green" websites that dominate the results from my work computer.
It depends on how deep your pot is. For normal pots it probably doesn't work without roots.
Lots of plants like to be top fed. Also roots of different plants can grow differently for aeration. Probably best to educate yourself on horticulture more so than software and sensors.
You'll probably want to germinate in small containers, which work fine when bottom fed. I use styrofoam cups that are placed on top of a capillary mat, which draws water from a container underneath. Works great, keepz the soil moist but not wet. I have these in my indoor seed starter; it has temperature controls and fans to keep young plants moving. Works great for mint, tomatoes and peppers. Peppers actually like to be 'abused' a bit - periods of drought, hard winds, large variation in temperature. Makes them very bushy with thick stems. With a computerized system this is easy to implement, but the problem is how to measure the response variable in such a system (or even define it) to set up a fully self-regulating system. The hard- and software in these systems are easy, it's the botany, biochemistry and horticulture that is hard.
Agree.

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.)

I also thought about doing a project like that, thanks for the write-up. I somehow can't really believe that it's that hard to measure soil moistures.

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.

I'm sorta thrown off by the use of "we" and "our" in the middle of this article. From the top of the article (which doesn't use we/our), I understand that this is just one guy doing this. Is there someone else in the process that I'm missing?
> My friend Jeet had just started learning to program, so I asked if he’d be interested in collaborating with me on GreenPiThumb.
It's the royal "we". I should have mentioned in the post that I reign over a small kingdom.

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 bought this moisture sensor for a gardening project

https://www.tindie.com/products/miceuz/i2c-soil-moisture-sen...

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 https://grafana.com/

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.

Thanks for the tip! I hadn't seen this.
Beware of the delivery time though. It took them 3 weeks to ship the sensor from Lithuania to Estonia :)

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.

http://arduino-info.wikispaces.com/ArduinoPower

Another, more polished, option is http://vegetronix.com. I've used their probes for years and can't believe they're not more popular.

They use capacitive sensing and they're enclosed and waterproof.

I highly recommend them.

$40 is quite steep compared to the rest of components usually used in such a project.
Have you had any fail yet? $40 seems like a lot until you add up replacement of failed units for the cheaper stuff.
I admit the price is steep, but it's worth it for me. They're more for a professional application than the hobby side of things.

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.

Or.. you can use a $2 Arduino Nano clone, a 1¢ 10MΩ resistor and some aluminum foil strips to build one yourself.

http://playground.arduino.cc/Main/CapacitiveSensor

Thank you for that. I was really beginning to give up hope for the site :-)
...nope. This'll give you a nice little touch sensor but not much more than that. Try turning this into any sort of usable measurement of soil moisture as opposed to "there's wet soil on this strip of foil" and you'll run into a wall.
Miceuz's work is excellent and this sensor in particular is on point. I've been using a handful of them with an ESP8266 as a wireless I2C master for the last year or so.
Instead of measuring soil moisture try:

    - measuring air moisture of small upside down cup on top of the soil 
    - measuring weight of the whole pot
Or don't measure at all and instead use precise amount of water on precise times (RTC module, medical grade piezo-electric pump). My similar project is on hold at 20 or so sketches of various types of water pumps.
> Or don't measure at all and instead use precise amount of water on precise times

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.

Wouldn't the weight of the pot increase as the plant grows (because it's absorbing carbon from the air in fact).
This could be accounted for - for example, if the weight of everything drops by 100 grams, then at least 100 grams of water has been used or evaporated. Eventually any increase in weight from the plant could probably be calculated, but for many plants, (like bush beans), it's a relatively small amount, probably less than a pound.

OTOH indeterminate tomato plant, for example, weighs a lot, and the weight would also be affected by picking the fruit.

I wonder if you could use the camera to detect when the plant needs water? I have a plant on my desk that I dump water into whenever it starts looking sad and it's been alive for years now.
> I have a plant on my desk that I dump water into whenever it starts looking sad and it's been alive for years now.

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.

Wouldn't two temperature sensors tell a bigger difference for wet soil, as the wick temperature is lower in damp soil. If it's little difference it's probably dry.

That's at least partially how my finger works as a sensor. A finger test probably picks up sponginess too.

How would measuring the weight account for the plant growing in size and weight?

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.

You may also hack this product by Xiaomi.

https://www.aliexpress.com/item/Xiaomi-Mi-Flora-Monitor-Smar...

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.

"loose the soil and go for hydroponics"

What a great idea! (Especially since his "dirt is broken"). :-)

But I’m a programmer, not a gardener. If I had a plant, I’d have to water it and check the plant’s health a few times per week. I decided it would be much easier if I just spent several hundred hours building a robot to do that for me. If the plant lives to be 80 years old, I come out slightly ahead.

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.

Love this. I went down a similar path last year, using a Raspberry Pi to water an outdoor vegetable patch. In the end I used a package [1] to control a remote controlled plug socket. I also hit similar problems with soil moisture, so went down the route of pulling a weather feed - pump water if it isn't going rain. Easy if you are watering outside!

[1] https://github.com/dmcg/raspberry-strogonanoff

Oh, that's awesome! Doing it outside is interesting because there are a whole different set of challenges. I like your project name.
This is inspiring. I've been thinking about hand rolling a rain water reserve style irrigation system that essentially just pulls/scrapes a weather forecast and waters my garden. Not nearly as precise as this but hopefully useful.
I had good results with using a simple timer board that switched the pump on and off at fixed intervals. The total setup (for 5 potted plants) costed around $25 including the timer board. The results were great especially with tomato and okra where we had a hard time collecting the produce :)

Edit: Was using something similar to this board: http://www.ebay.com/itm/Automation-DC-12V-LED-Display-Digita...

I think RPi is a overkill for this project.

> 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.

The plants look waterlogged; the roots need air to breathe.

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.

Oh, thanks for the feedback. There are holes at the bottom of the planter. Is there something different we need to be doing to get it to drain properly?

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.

I would think a purely technical approach to this is flooding the plant every hour, and then measuring the differential of how much water had flooded the roots vs. how much water was pumped out.

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.

This is basically hydroponics. And by "basically" I mean "exactly". Replace the soil with an inert, porous medium like hardened clay. And if you aerate the water with say, an aquarium pump/stone, you don't even need to drain it...
The drain back into the reservoir is so you don't have to worry adding too much water in one go as it'll just drain back out right away. The soil will only hold a certain amount. By not having the soil soak water back up from the pan you don't need to worry about controlling the amount of water you just need to time the period between waterings. The drier the soil the more water it'll absorb every watering period so it's reasonably self correcting.

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.

>GreenPiThumb: a gardening bot that automatically waters houseplants, but also sometimes kills them.

Quite an advanced bot: as close to a human as you can get!

I'm not much of a gardener but the idea of measuring the moisture level seems ill-conceived... Namely because you are measuring at only a single point in your 3D region of soil, and you don't know what range of moisture should be maintained without experimentation.

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!

As the plant grows the rate of water being removed from the soil increases, so the amount of water supplied will need to increase. Varience in illumination, temp, and humidity will also change transpiration rates.
I really like the addition of the web camera - it's a nice bonus on top of the more traditional temperature/humidity/light/moisture readings that most people incorporate into these DIY systems. Much better than what I made the first time I built one of these things.[0]

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.

[0] I ran a consumer soil moisture IOT company for a few years that was sold to Scotts Miracle Gro in 2016.

> time domain reflectometry

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.

Oh you may be exactly the person I need to talk to! I'm looking for a soil humidity sensor that is able to permanently sit in my garden and accurately measure soil humidity and soil temperature. Do you have any advice?

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.

I am so excited to see this! I've been working on a very similar project to monitor my outdoor vegetable garden using a raspberry pi and some ESP8266's. Like you, I'm using this as a project to better learn javascript, angular and django. It's in the very early stages, but I'm really loving the experience so far.

Here's a picture of my setup. http://imgur.com/a/BV188

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!

Thanks for reading.

Your project looks really cool! Is your code open source? I'd love to check it out.

That looks cool. Does having your electronics enclosed in a greenhouse bring them close to any temperature limits?
Probably! But I haven't had any issues yet.
Soil moisture measurements can be scientific if you have enough money. Look up Time Domain Reflectometry and Soil Moisture Tension.

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.

It should be possible to hack together a basic TDR device, especially if you can calibrate it.

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.

https://electronics.stackexchange.com/questions/268333/ghz-c...

I love these projects. They are always destined to fail from experience but are great fun anyway. I've tried a few times to do similar things. I'll catalog my disasters quickly:

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 :)

Solidarity. :-)

What a lovely way to learn about the world ... by taking copious notes about all of the (surprising) things that don't work.

It's fantastic. When it fails miserably I am usually in hysterics at the sheer carnage my creation unleashed. So much to learn.

I'm slightly tempted to do a 4th attempt now inspired by the original poster :)

That's a very positive outlook to have, the bit about unleashed carnage made me laugh :)
you should play dwarf fortress.
Why not use a relay? Less to worry about for a side project like that. If you don't need sub-millisecond switching then you gain complete isolation, constant voltage output, and AC or DC switching
Relay has a considerably lower drive impedance than a MOSFET for switching so you end up having to drive the relay with something anyway because the 555 will probably die. Might as well skip the middle man and use a MOSFET which has a crazy high source impedance.

(you need to stick a transistor between the 555 and the relay anyway so you might as well just use a MOSFET)

Nope. 555 has drive capability of over 100mA. More than enough to drive a small relay directly. Just make sure you have a spike suppression diode in circuit.
Take a look at the output switching on different variants of 555s (there are about 6). This isn't always the case. Not only that if you pull lots of current through them, and 100mA is a lot, then the Pd of the sink transistor is pushed a bit hard. I've let the smoke out of a few over the years working on that assumption.

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.

Fair point.

I sometimes overestimate the ability of the average electronics hobbyist to properly understand a datasheet.

I don't think many people read the data sheets to be honest even some of the professional engineers. It's mainly gluing canned circuits together and see if they work or not. This is a little difficult if you didn't start with analogue and work up.
Seedlings need _light_ when they pop out or they get all spindly. The sun does something like 1 kW/m3, so if you're using artificial light, you will need plenty of (preferably LED/CFL) lighting. Source: the generations of spindly tomato plants who went before the thick-stalked purple-green-leaved ones.
Indeed. This was on the kitchen window sill with sunlight 50% of the day. We got there in the end unaided by technology but it was so much fun trying with it.

Ones that worked eventually: http://imgur.com/a/EDdwR - note cable ties :)

While that's true, the OP's solution is one way to help promote thicker stems if your lighting is sub-par. E.g. more light is best, but failing that for some reason (budget, space, whatever), stimulating the stems is a reasonable backup.
Fun story: we're doing a project at work to do with agriculture.

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.

Probably not so much electrocuted as poisoned with metal ions.
I did wonder this, was it simply the corrosion that did it?
You plated your plant! :)
This is a really cool idea actually. However you're likely talking sub nanosecond rise times which makes things a little difficult in the signal processing space. For example my scope (knackered old 1971 Tek 475) can barely manage 1.8ns on a properly terminated transmission line which this will likely not be.
I don't remember the name of the peripheral off the top of my head, but there are some PICs that have a very fast time measurement unit in them. I don't know if they're fast enough for soil measurement, but there's app notes around for doing TDR-based liquid level sensing with them.
http://www.edn.com/Pdf/ViewPdf?contentItemId=4433411

Details above. Looks like you can get 3.5ps resolution with an off the shelf PIC after calibration which is pretty impressive!

That's the one! I was blown away when I first saw it!
Wow!

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!

Provided you can get the rise time fast enough, you can use a TDC7200 http://www.ti.com/product/TDC7200 which will give you picosecond timing on the signal.

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?

I really want to get a Farm Bot to mess around with. Appears to be open source and you just order the parts to assemble for your space.

Looks like a cool project.

I have been thinking about making a homebrew Phototron using an arduino, grow lights, temp+moisture sensors and a water reservoir.

The addition of the camera makes me think that a Pi might be a better solution.

I have a pretty similar project. But the problem with the mainstream moisture sensors is that they break after some time (or I did not find a good one). For myself I found the expensive solution a flower power from parrot http://global.parrot.com/au/products/flower-power/ a handy solution. It workes with bluetooth and they have some documentation. I did some working for python: https://github.com/Dlotan/flower-master-fab/blob/master/app/... and get good results over a long perioud without too many outliers
This was a hilarious read (as well as informative). Fantastic work, fantastic writing!