RPi - Automated watering system (Design)

Thread Starter

Litch

Joined Jan 25, 2013
85
This is all just theory at the moment, thought I'd post it to my peers for review before I actually commence design (and maybe get some pointers).

So the idea:

I've got quite a few chilli plants growing outdoors at the moment and because of work I don't always get to water the bloody things (interstate trips etc..) - and the LOVE water and heat (Chillies are mostly tropical).

So the theory is to throw together a small (cheap-ish) monitoring system that will detect water levels and water (via electronic solenoid) accordingly.

Ultimately, to measure water content in the soil, and water it when required.

[The RPi and it's limiations]
I've got like 4 x RPi's laying around doing nothing (and a few more doing other tasks) so it just makes sense to utilise one of them for this project - but there are some caveats to take note of:

  1. Real resistance/capacitance based water sensors are expensive! Try around the $70 mark +/-; Stainless-steel cutlery are rather inexpensive :) as long as I can 'tune' the ADC to desired level via trial and error (and re-tune every so often to accommodate for the unavoidable corrosion/oxidisation). As such I'll make the 'water sensors' a pair of fork prongs on a board coated with silicon gel (other ideas welcome!)
  2. The RPi is 3V3 Digital I/O only - no ADC exists so an external ADC will have to be used. What the RPi does have is a couple of I2C channels so an I2C-based ADC I/O expander would be ideal - but that also yields some distance issues because of the bus (1 meter is about the reliability of 3V3 I2C), now we're looking at I2C bus expanders to support the 10 meters or so from my plants to my shed.... This is quickly getting more complicated, perhaps an outdoor cabinet is the answer, and just run power from the shed... Hmm, that might be the go - Other ideas welcome.
  3. The RPi code is easy (That's my bread and butter)
  4. I intend to supply schematics, source code and photos.

[Water supply]
  • 12/24v Irrigation water solenoids are also pricey, washing machine solenoids on the other hand are not, but they run on 240v which means relays, diodes and mains power (which isn't an issue).
  • Water pressure is rather good in my house which means, depending on the outlets I use, could water next door's house or burrow a hole in the soil depending on where they're pointing. A flow-limiter will have to be employed.

[Overview]

  • 2 Circuits boards are required as I see it now. One for the RPi I2C to DIO/ADC (Low voltage area) and one for the relay/diode solenoid control (High voltage). Interconnects will be modular - something in the molex range, like a USB header on a motherboard (and the RPi DIO header).
  • 2 outdoor rated cabinets will be used, again separating the RPi and it's control circuits to the high voltage relays and solenoids.


Time to pick some components out and design my Control circuit board - To be continued...

All design ideas welcome! (This is a forum)
 
Last edited:

MrChips

Joined Oct 2, 2009
30,706
Seriously, I think RPi would be overkill. I would go with Arduinos.
But looks like you're an RPi expert so that makes a difference.
 

strantor

Joined Oct 3, 2010
6,782
With all those words, why would you make me google "RPi?"

Ah well, I recommend an arduino since it already has analog inputs, and these sensors. If you really must incorporate your Raspberry Pi, you could interface it with the Arduino for a on screen display of soil moisture, and maybe an online interface so you can monitor and manually control you pot, er..., I mean chilli farm from your smartphone.
 

Thread Starter

Litch

Joined Jan 25, 2013
85
Hmm, seems we have some Arduino fans out here, but MrChips is right - I do know the RPi rather well, and linux development on the RPi is a lot more friendly to me than learning a new uC and its assembly language, plus the cost of the unit and it's board.

Plus that sensor is still $35 + p/h, but my fork idea is free (unless the Mrs sees me flog it).
 

tshuck

Joined Oct 18, 2012
3,534
Growing some ghost peppers too?:D

I did this with a smaller setup with a PIC.

For the sensors, I used wires encased in Plaster of Paris, I did this because soil has a variable number of ion in it, affecting conductivity, making any reading from two electrodes subjective at best. I heard that Gypsum will absorb water and change its conductivity reliably, well, as reliably as any DIY moisture sensor anyway:p. Plaster of Paris uses Gypsum in it, so there we go, a moisture sensor. They do break down after a while though and need to be replaced every so often.

As far as the control goes, I tend to agree with the others, the RPi is overkill, but, as you said, you'd like to stick with it...


Tackling the ADC issues as ideas come to my head:
You could employ wireless sensor modules that would take readings and transmit them using your favorite wireless technology to the RPi, which could be in control of the rest of the process, relays, timing, etc. this would, however drive up the cost and time as you would need some sort of controller to figure out when to transmit.

Maybe you could employ some sort of differential signaling(i.e. RS-485) with the RPi, this would allow you to extend your range considerably, but I don't know much about RPis yet, so I don't know if this is possible or not. At the very least, you could use I2C to talk to a transceiver.

On a side note, how big is your setup?
 

Thread Starter

Litch

Joined Jan 25, 2013
85
On a side note, how big is your setup?
Thanks for that tshuck - that helps!

As for the set up, there are 4 of 650mm x 350mm "tray" pots filled with Thai/Birdseye/Cayenne/Carribbean. Habaneros are still germinating, a couple of large pots with black-Thai chillies and a couple with Jalapenos

I'm yet to get some bloody Ghost (Bhut Jolokia) seeds that germinate!

And thanks to nsaspook as well - I'll check that code out later.

But for now - this is the initial circuit (Image and application file); model numbers are mostly provided (circuit made with ExpressPCB; because then I can just order a couple via that program).
 

Attachments

KnRele

Joined Jan 7, 2013
20
Some time ago, I had a similar idea, to automate watering of my potted plants when away for some time, much along the same lines as discussed here: have humidity sensors and start running water with a pump or a solenoid valve when the soil was dry.

I made a soil humidity sensor from two pieces of stainless-steel threaded stock -- two stainless-steel forks would work just about the same -- where I used this as part of a voltage divider. To avoid problems with corrosion and migrating ions or any such, I would briefly apply a positive voltage, then measure the attenuation of the voltage divider with an A-D converter; then I would apply a similar negative voltage, and measure the attenuation for that polarity as well.

The schematic of this is similar to the one I have attached here. Here, the controller drives the Enable and Select inputs of a 4053 from two of its GPIO lines, configured as outputs, so that it can turn on the positive or negative voltage as desired. The voltage-level conversion from 3.3V to 7.5V is done with NPN transistors (2N3904) -- R2 and R5 will make sure the transistors are off when the GPIOs are configured as inputs.

The two resistors R7 and R8 form a voltage divider, together with the unknown resistance in the soil. If this is dry, its resistance is high and the output voltage should be close to plus or minus 3.5 V.

R9 and R10 scales a +5V to -5V input range to the proper 0 to +5V range that the ADC can handle. R11 and R12 and the two diodes serve to protect the ADC if for some reason the op-amp should be forced into saturation and give voltages outside the range of +5V to -5V. I used a TL082. (the unused half should be configured as a voltage follower, with the output connected to the non-inverting input, and the inverting input connected to 0V)

The controller that I used was a Picotux and the ADC was a PCF8591, which connects via I2C. A Raspberry Pi would work just as well with the PCF8591.

Other alternative devices which already have both the digital outputs and the analog inputs would be any one of the several Arduino variants, or any of a number of the more capable PIC microcontrollers, the PIC16F690 for example.
 

Attachments

Thread Starter

Litch

Joined Jan 25, 2013
85
Brilliant KnRele, I didn't even think of that (momentary measurement, with opposing polarity).

Think I need to go back to the drawing board.
 

MrChips

Joined Oct 2, 2009
30,706
Right idea but way too complicated. Use two I/O pins from your MCU and connect your soil sensor wires there. Connect a capacitor in parallel with the wire and measure the time constant of the combo.
 

Thread Starter

Litch

Joined Jan 25, 2013
85
Because the RPi doesn't do timing via "cycles per MHz" very well, and could well be far off depending on process load since it's all scheduled from the Linux Kernel - especially in the vicinity of sub-100ms. As such, I've added an NPN in there to "Turn on" the sensor current. Not ideal, but it should significantly reduce any corrosion, and since any measurement cycle would be in the range of at least 30 minutes, and a duration of 1 second, the impact should be minimal.

Also rearranged some components.

Revision 2 - Changelog:
* ADC moved closer to probe pins
* Darlington moved to where more appropriate
* Power diode added for common ground to prevent back flow
* BC548 NPN added for sensor current on/off
* 330R resistor added in-line to NPN base pin for current limit.
* Swapped out 100uF Tant for Electrolytic (Cheaper, more appropriate)
* Swapped out the ULN2801A with a ULN2803A (Has inbuilt resistors for 5V TTL, which is more suitable for the RPi 3V3 logic; diagram doesn't show new part number).

Component Datasheets:
The rest are pretty well known.
 

Attachments

Thread Starter

Litch

Joined Jan 25, 2013
85
First proto (Apart from the whole power circuitry being wrong) the LM7805 1.5A VREG gets rather hot, so much so that I've raised it to stand vertical and put a heatsink on it.

Still gets too hot.

That's with a 9V 2A DC SM PSU feeding it, with either the RPI connected (~400mA draw), or every relay engaged (~450mA). Have not been keen to try both.

Is there something I'm doing wrong? Should the LM7805 get that hot at < 1A load?

What is the "Temperature coefficient of output voltage" listed in the LM7805 datasheet?

Should I be looking at voltage "conversion" rather than "regulation" ie. DC to DC power supply rather than a wide range DC input in to a 5V vreg?

Space is minimal, I need somewhere between 1.5 to 3A @ 5V - Ideas?
 

Thread Starter

Litch

Joined Jan 25, 2013
85
Revision 3 PCB:
* Removed PIN 10 from ground on the Darlington (Bad connection, grounded all relays and engaged them from power-on)
* Removed horizontal TO-220 LM3805 VREG, redesigned it to be vertical mount with a "FISCHER ELEKTRONIK FK 218 SA-32" heatsink
* Cleaned up what was the mess I made with the power supply, the hell was I thinking.
* Increased trace width for 240v area and ground lines.

Revision 2 Photo:
* Alpha board (First test)
* Relays, DIN, headers installed (now to be removed).
* Power circuitry has bee hacked up underneath to fix the original screw ups
* LM7805 stood up vertical with HS attached
 

Attachments

Thread Starter

Litch

Joined Jan 25, 2013
85
Design finished, proto is working 100% (In the context of engaging relays and measuring resistance across the 6 ADC pins)

DC-DC converter is nice and cool powering the RPi and all the relays at once (Thanks to THIS thread)

Thanks for all the input, I'll dump photos, schems and source code in finished projects as soon as I can.
 

Attachments

Top