Introduction: Automatic Watering System With Capacitive Probe and Arduino on the Cheap (and I Mean It)
Disclaimer: I'm not an electronics engineer, so I cannot offer any warranty for the design (much less for your implementation). I only know the presented solution worked for me for at least about 5-6 months (so I can't even vouch for its reliability over longer periods). Also, take my hints on where to source your components just as they are: hints only, not recommendations and certainly not endorsements.
Prerequisite knowledge (things I won't explain): how to solder your components and how to compile and upload a sketch on an Arduino board.
Resource repository: start on http://acolomitchi.github.io/cap-soil-moisture-v2 and, after reading about the content of it, get to the github repository.
Why yet another automatic watering system? Some time ago I bought a piece of acreage some hundred kilometres or so from home, no power connection, with the idea I'll plant some fruit trees – weekend farmer, you see? And so I did.
Except that the Godzilla El Nino was announced; even in a normal year Melbournian summer is sort of dry, El Nino didn't look as a good prospect for the survival of some just planted trees. Even more so as temperatures of 40℃ usually come with strong hot winds from the Australia's centre, winds which will dry the soil in hours. And I can't get there in less than 2 hours and definitely I can do it in weekends only.
So, what I needed:
- an automatic watering system with soil moisture detector...
- … as cheap as possible (if I am to scale up later to hundreds of them)...
- … as low tech watering assembly as possible (low pressure “mains” - 1 meter of water head or less) …
- ... as low consumption as possible (no power grid available)
Additionally, the soil is slightly acidic, not a problem for the just-planted tree species I needed to water but definitely going to affect any resistive probe, running the risk of increased resistance due to corrosion in a matter of weeks (and thus wasting precious water... only to make the corrosion worse): capacitive soil probe it is, then.
The principle - well, simple.
For the probe, etch a planar capacitor with coplanar plates from a piece of PBC (actually, a two sided PCB, but the pattern etched on the two sides is the same). The theory - since the water has a higher electric permittivity than the soil, when the soils is moist the capacitance of the probe increases.
For the controller: anything that can detect somehow the change in the probe capacity and trigger the watering. In brief, the design is a NE555 astable using the moisture probe as the charge/discharge capacitor, with an Arduino mini-pro used to count the pulses in a given time, the later also triggering the water when needed.
For the watering assembly: KISS principle – a mini fish-tank centrifugal pump, pushing water up to a hight of a bit above 1 meter (slightly above the max level of water in an IBC/pallet tank), into the ascending branch of a poly tube – just punch a small hole in the descending branch to stop it syphoning when the pump stops.
The BoM is as follows:
- 1x Arduino Pro Mini with ATM168 at 5V/16MHz – in my experience, clones are OK and much cheaper
- 1x NE555
- 1 x 2N5551 – NPN transistor
- resistors: 2x 470R, 1x 4k7
- electrolytic capacitors: 2x 10uF
- trimpot: 1x50k – if using my PCB design, take a vertical one with a 2.54 mm pitch between terminals.
- diode: 1x 1N4148
- fish tank submersible water pump 12V, 3 meter water head or equivalent – the “submersible” capability is not absolutely needed, but if it is so then you can use it outside without any other extra protection.
Warning: as the 2N5551 is used as a relay, don't go with the power of the water pump over 6W (I'm using a 5W one) – the transistor is rated to 600mA max.
Also, this design requires 12V powered pumps - the lower the pump voltage, the higher the current needed to perform the same work. If you go with lower voltage/higher current (e.g. 6V), the controller logic will work just fine, but you will need to replace the 2N5551 "relay transistor" with something supporting a higher max current. - some lengths of flexible tubing with internal diameter to fit the outlet of your chosen pump
- jumper wire (to connect the probe, power, pump at least)
- 12V supply – I'm using a set of two 4R25X (lantern) 6V batteries – in my experience, for a good 4 months between battery changes
If this is your first project using Arduino Pro Mini (congrats, not only they are useful and a great fun, but cheap as well), you will need:
- 1x UART Module USB 2.0 To TTL Converter at 5V
- 1x mini USB 2.0 cable
- 4x female-to-female DuPont cables
to upload the sketch into Arduino's flash and to use for serial comms – you'll get to reuse them across projects.
Supplementary, if you decide to go with my PCB design, the following connectors:
- 1x 40 pin male header single row breakable, 2.54mm pitch – you won't use them all
- 2x 12pin female header row 2.54mm pitch – or use a single 40x one which you'll split to get 2x12 pin (just use a cutter to scarify a shallow groove in it and then break along the groove)
- 5x 1 pin DuPont wire female pin
- 7x 1 pin DuPont pin housing
- 1x 2 pin DuPont pin housing
- optional – 2x 2 pin 5mm terminal block – power in and pump (out) will be mounted here. Alternatively, use some extra DuPont female pins to connect them, if you feel like you don't need a stronger mechanical connection (just add 4 more DuPont female pins 2x 2pin DuPont housing). Or just solder the wires on the board (I preferred to have them detachable)
The box/enclosure/housing for the circuit is let as a homework for the reader – if you want to follow my PCB design (presented below), the panel is 45x45mm, with 3mm mounting holes in the corners and 40mm between the hole centres.
Tools
- solder iron, solder, flux – you know the drill
- crimping tool for the DuPont pins
- whatever you want to use to print, etch, drill your PBC (if you really-really are a DIY-er, but go to your friendly local PBC fab shop – if you are tight on budget and/or you local PCB shop is not as price friendly as you expect, there's always the pcbway.com way).
Approximate price for the whole
After some extreme adventures in low-tech DIY land (which I set into the addendum at the end of this article), I ended into outsourcing the probes and the controller boards to pcbway.com – far cheaper than I could do it myself in any reasonable time.
I also sourced most of the components from ebay or aliexpress.com – my personal experience tells me the Arduino Pro Mini clones and the rest of the components do work in a situation as simple as this one. And, come on, you got to admit the price difference for an Arduino Pro Mini from $1.25 on aliexpress to $9.95 on digikey/sparkfun is quite significant. Especially when the entire controller, capacitive probe and minipump, components and PCB fab outsourcing, including postage, can be had on below $9.20 each, with components to spare at the end! True, this is the price I got for a quantity of 40 – which got me to less than $400 in total. For details, see "Hints for sourcing dirt cheap components"
Step 1: The Soil Moisture Probe
A double side patterned PCB acting as a planar capacitor with coplanar plates - see the first diagram (qualitative explanation only).
The simplest would look like two combs with interleaving teeth. After some experimentation, I settled to a pattern presented on the second photo of this section; the pattern is repeated identically on the two faces of the PCB (you can find the Gerber files into the project's github repository)
Just feel free to let you mind/hands run wild with whatever pattern you like, but keep in mind these hints derived from my experience:
- the longer the traces (and the closer one to another) – the higher the capacitance of the probe, thus less sensitivity to parasitic capacitance (e.g the connecting wires); but, starting with an initial copper area, longer traces means will mean more copper surface to etch away, thus a lower contribution of the surrounding medium on the capacitance of the probe.
- aligning the traces on the two faces of the PCB. Remember? We want to measure changes in the capacitance of the surrounding soil, thus those electric field lines better close through the soil rather than through the PCB plastic substrate. (see d. in the first diagram of this section)
- you do not want to measure only the moisture of the top layer of your soil, so you need you probe a bit on the longish side. However, you do not want the probe to feel the last remnant of water in the deeper layer while the upper roots are dying waiting for the water. For some just-planted trees (bought bare-rooted) or ornamentals in largish pots, probably 100-150 mm in length is fine. If you want to use it for some shallow-root plants, a 100 mm in length could be enough (if you stick it obliquely into the soil – if a shallower depth is needed, you'll want to increase the width of the probe to keep enough area).
No matter what you do, any reasonable sized capacitive probe will have a very small capacity – in my experience around 80-200pF in air. The capacity is difficult to measure directly because the probe is designed to pick influences for external environment (you want to measure the moisture in the soil surrounding your probe, don't you?) thus anything around it, especially conductive media (such as a human body), is going to induce a change in its capacitance value.
Anyway, the important thing to be said here: when connecting the probe to the controller, use as short wires as you can afford – even after the probe is sunk into the soil (thus isolated from outside influences), these wires will still be able to pick external presences and influence notably the count of pulses – fortunately not significant enough to make this project unusable.
Last word of caution before the specific details: after soldering the connection wires to the probe, make sure that the connection is thoroughly insulated; the currents in the probe are on the order of microampere or less; unless the soil is bone dry, it is going to be able to conduct such small currents, thus shorting your probe.
Initially, I used a drop of superglue to cover each connection, but I discovered that superglue does not cure in volume as fast as it glues surfaces; as it tends to form a layer of dried glue on the surface of the drop while the interior can remain liquid/uncured for days. As such, I switched to "acrylic nail monomer+powder" (search ebay) and obtained an adherent, hard (and coloured) drop of plexiglass protecting the connection. Perhaps an overkill, but I didn't want to lose my just planted trees to an Australian summer during the “Godzilla El Nino” event.
Finally, the second photo of the section presents the probe in its two "incarnations": one a pure DIY (see the story of my extreme low tech DIY adventure at the end of this article) and one outsourced to the pcbway.com fab - you can guess which is which.
Step 2: The Controller - Schema
I decided to go with the simplest NE555 astable using the probe as the charge/discharge capacitor, count the pulses using an Arduino Mini-pro and also use the Arduino board to trigger the watering if the number of pulses go over a certain value (this means the capacitance of the probe – thus the soil moisture – dropped below the threshold value).
The PCB design I reached is a single side with all the components mounted through hole (DIP mount) – this makes it very simple to assemble, only a soldering iron is needed. The PCB trace pattern is attached as the PDF file at the end of this step (Back Cu layer only); a 4x layout on a 100x100mm panel (including snap lines) is available as Gerber files on the project page on github.
Explanations:
- the left side is one (of the two possible) main variations of NE555 astable circuits.
- the NE555 is powered by the Arduino's digital pin 6. Therefore, NE555 will only be active when the controller decides it's time to take a measurement;
- the Q1 transistor acts as a relay for the pump, having the later as load in its connector. Its base is commanded by the digital pin 3 of the Arduino controller. I'm repeating the warning : do not connect directly to it a pump rated to more than 6W, use a relay in between;
- the output of the NE555 astable is connected to the pin digital pin5 of the Arduino controller; this one is fixed (because it's the only one used by the FreqCounter library I'm using), all the other pin choices were rather governed by the traces on the PCB
- the trimpot in the connection to the probe is used to tune the frequency – I'll come to this later – the 4K7 resistor just limits the frequency going close to the max (if you set a zero resistance on the trimpot)
- the probe is connected by a single 2 pin header row; for the power and the pump the schema allows for two different connectors – not essential, but as I wasn't sure which one of pin-header/female-DuPont or terminal block would suit better my choice of enclosure
- the diode connected to the pump terminals – the D_flyw1 flywheel diode – just in case the pump motor creates spikes in voltage when turned off – I didn't test for the spikes, but the 1N4148 is cheap enough and better be safe than sorry (the diode is rated at 1A for non-repetitive pulses 1ms pulses and 4A for non-repetitive pulse of 1μs; in my case it was enough - but don't blame me if it fails for your case)
- the capacitor in the parallel with the power connector – filter out voltage fluctuations in case the controller is powered by a noisy line (not absolutely needed if you power the circuit from batteries)
Some comments: the NE555 astable uses the output pin (pin 3 of NE555) for both charging and discharging the probe capacitor (unlike the standard NE555 astable, which uses the VCC to charge the capacitor and pin 7 – the discharge pin – to drain it). Normally, this choice is a bit frown upon, because the impedance connected in the NE555's output could affect the pulse duration/frequency; however, the NE555 signal is presented to one of Arduino's pin configured as input – thus a very high impedance, therefore the change in the charge/discharge time is negligible. As the PCB space was at a premium for me (and I still wanted DIP-mount components rather than SMD ones), the advantage of using a lower number of components and simplifying the traces was good enough to go this way.
Now, what about the other connectors - the CONN_SUPPLY1, CONN_SETTINGS1, PPROG0/PGND0, what are they for? The detailed answer in the "Controller - the logic", meanwhile the short answer is: they are used in configuring the controller without the need of a computer.
Warning: the circuit is NOT protected against reversed polarity - when connecting the power, mind the +/- signs.
Warning: the Arduino board can fit in normal and inverse positions - the pinout is symmetrical. But if you plug it in reversed, you'll likely end with an unusable Arduino board (I did it once).
Attachments
Step 3: The Controller - Assembly - Arduino Pro Mini Board
I chose to replace the angled pins from the original package with straight ones - while this adds to the height of the assembly, it make easier to connect to the controller while in a box.
Also, a minimal pinout (4 pins of 6) are sufficient: VCC, GND, Tx and Rx
Feel free to adjust to your needs
Step 4: The Controller - Assembly - Controller Board
Note the mounting orientation for the D_flywh1 diode and Rb1 resistor - they are vertical.
Note also the orientation of the NE555 - the top (has a "notch") is towards the "power in" side of the PBC
Step 5: The Controller - All Together
You can see
- the "configuration board" (explanations a bit later) on the bottom side of the photo
- the probe leads trimmed to about 25 cm (shorter is better), with a 2 pin DuPont connector - depending of your choice of enclosure, you may what to crimp the DuPont pins and slip in the DuPont housing only after you mount the circuit inside the enclosure
- the pump is connected using the terminal block - mind the polarity
- no power connected, but you get the idea
Warning: the circuit is NOT protected against reversed polarity - when connecting the power, mind the +/- signs.
Warning: the Arduino board can fit in normal and inverse positions - the pinout is symmetrical. But if you plug it in reversed, you'll likely end with an unusable Arduino board, not totally fried but no longer functioning normally.
Step 6: Controller - the Logic
Now, about the logic in the Arduino controller: count the pulses, if they get above a threshold, trigger the watering. The logic is simple, isn't it? Except after my first iteration, I discovered it is not only simple but also too simplistic. The shortcomings:
- you cannot keep the soil measuring process running continuously if you're using batteries as your power source. While measuring, the controller uses about 35-40mA (more will be drawn when watering). A set of two 4R25X 6V batteries (aka “lantern batteries”) were depleted in about two weeks – multiply this with the number of watering points and you'll see it's no longer cheap. Better take moisture measurements with hours between them – use your common sense, the time between two measures will vary on the season, temperature, amount of soils around your plant, etc.
- Even more, you cannot even keep your Arduino fully alive between two measurements, without doing anything between two measurements; a Pro Mini will still draw 20—25mA – so a battery set will last only 3-4 weeks. Better put it into deep sleep – in my experience, this drives down the consumption to a mere 3mA, enough for the same batteries to last for about 20 weeks (only later I learned about The Shrimp and other extremely low current ATM368 circuits, which would extend the life of a lantern battery set to longer than the physical life of the batteries themselves. Well, there will be a next time)
- you cannot decide how much water you dispense by simply reading the probe until you consider “it's wet enough” - because it takes some time for the water to infiltrate the soil, therefore you'll either decide it too early (if the probe is close to where the water hits the ground, so the soil gets wet too quickly) or too late (if the probe is a bit too far and it takes some time for the water to actually infiltrate the soil). Better stick with the rule of “if it's too dry, pour a predetermined amount of water, stop and wait for a good while before testing again”
- you can't preset the watering parameters at home, then go in the field and expect to work as fine as you 'tuned' it to. Each soil will have its own mineral content, structure, compactness, capacity to retain water, etc – which will impact the parameters quite significantly. Somehow, I didn't see myself going it the field carrying the laptop with me only to setup each watering point with its very specific parameters values.
Anyhow, the above shows that the controller logic configuration will need at least 3 parameters and, highly preferable, these 3 parameters should be settable without requiring the use of a computer:
- the "dryness threshold" - the level one considers watering is needed
- the amount of time to apply watering – this correlates well with the amount of water dispensed for the plant
- the time between two consecutive moisture readings (in between the Arduino will be put into deep sleep)
Of course, there is also the issue of probe readings (after uploading the program), if only for the sake of diagnosing what's going on.
Referring to the schema in the "The controller - schema", this is where the PProg0/Rgnd0/Pgnd0 – let's pompously call it “the configuration board” (lowish right of the schema) and CONN_Settings1/CONN_Supply1 (top of schema, above Arduino connectors) come it play: at boot time, the analog pins A0-A3 of the Arduino board are configured as INPUT_PULLUP during the setup stage and the logic checks the 4 pins and interpret the result as one command of the possible 16. Therefore, to “signal” a pin, you just need to connect a pin to the ground using the “configuration board” (stick the Pgnd0 DuPont pin of the “configuration board” into the Ground pin of the CONN_Supply1, then use the other Pprog0 pins to pull the corresponding Arduino configuration pins to the electrical ground).
Note: of course the whole thing could have been done with 4 toggle micro-switches and maybe they could be fit onto the board. But I preferred to keep the things as cheap as possible (and at a "macro" dimension - my eyes aren't what they used to be).
The list of setup commands - with the codes in the {A0,A1,A2,A3} order:
- operational mode - {0,0,0,0} - no setup, the normal operation
- set watering time - {1,0,0,0} - the controller will switch on the pump and keep it on until the wire is pulled out from the pin; in that moment, the controller saves the recorded watering duration and uses it for the next cycles;
- set threshold moisture level - {0,1,0,0} - the controller read the current moisture level, interprets it as the minimal level and will trigger the watering when the value reaches this value (next measure cycle)
- 3 mins between moisture testing - {1,1,0,0} - sets the period between two consecutive moisture probing cycles to 3 minutes – useful for testing purposes, not recommended for long term running
- 1 hour between moisture testing - {0,0,1,0} - Sets the period between two consecutive moisture probing cycles to 1 hour.
- 2 hours between moisture testing - {1,0,1,0} - Sets the period between two consecutive moisture probing cycles to 2 hours.
- 3 hours between moisture testing - {0,1,1,0} - Sets the period between two consecutive moisture probing cycles to 3 hours.
- 4 hours between moisture testing - {1,1,1,0} - Sets the period between two consecutive moisture probing cycles to 4 hours.
- 6 hours between moisture testing - {0,0,0,1} - Sets the period between two consecutive moisture probing cycles to 6 hours.
- 8 hours between moisture testing - {1,0,0,1} - Sets the period between two consecutive moisture probing cycles to 8 hours.
- 12 hours between moisture testing - {0,1,0,1} - Sets the period between two consecutive moisture probing cycles to 12 hours.
- diagnosis mode - {1,1,0,1} - performs humidity probing every 5 seconds and reports the number of recorded pulses through the USB serial interface - useful for system diagnosis
- reserved - {0,0,1,1} - reserved for future extensions
- reserved - {1,0,1,1} - reserved for future extensions
- reserved - {0,1,1,1} - reserved for future extensions
- reset to factory default - sets the threshold level to something that no soil (no matter how dry) is going to trigger watering, the interval between 2 humidity probing to 6 hours and the watering time to 5 seconds (i.e. establishes a configuration that will surely need change for any useful purpose)
You can download the source code from the project page on github.
Step 7: Verifications After Assembly (and Before Deployment)
Verifying your circuit after assembling it:
- with power, pump and probe detached, make up the “Diagnosis” setting configuration using the “configuration board” (configuration {1,1,0,1} as explained in the “Controller – the logic”)
- connect the Arduino board to the computer (through the UART adaptor and the USB cable) and upload the sketch – at this stage, the controller will be powered by USB
- start the Arduino IDE “Serial console” (adjust this step to your specific dev environ)
You will need to see values between 40,000 and 50,000 being echoed in the console every 3 seconds or so – the board counts the pulses over a 100ms period and outputs them – without any charge/discharge capacitor attached, the NE555 astable is expected to oscillate/pulse at values around 500kHz
If all you see is values of 0, it is likely the NE555 is defective or underpowered (you are using the 5V version of Arduino Pro Mini and the UART adapter, aren't you?)
Adjusting the “dry level” oscillation frequency and confirming waterproofing of your probe
- let the power and pump unconnected, let the “Diagnosis” setting configuration in place
- connect the probe to its socket and (preferably) let it hang in the air as far as possible of any objects (I'm doing it at the middle of the edge of a wooden table and let the probe hanging in air by its wires)
- adjust the trimpot until the values echoed in the console are as close as possible to 20,000
- now, get a hold with your hand on the probe. Depending on the dryness of your skin, the number of pulse should drop to a value between 8,000 and 12,000
- take a non-conductive recipient large enough to hold you probe, fill it with water and, while still connected to the controller, dunk the probe inside (may be a shallow recipient, just place the probe horizontally). You should note that the echoed count drops at around 2,000 or under – but if it drops straight to zero, your probe coating has a serious crack allowing the water to short the planar capacitor
- important: let the probe inside the water and examine the output for at least a couple of hours. You should notice a slow further decrease of the echoed values – in my case, it goes as low as 1,700 overnight, then it stabilizes. If it goes all the way to zero, the coating has a microscopic crack (the probe is unusable)
The last point shows that actually the “full wetting” of the probe is not instantaneous, it take time for the water to fill all the micropores of the probe surface. Which means you shouldn't make any calibration of the watering system straight after putting the probe in the soil (if you do, you will need to redo them).
Verifying the power side
Until now, all the verification where carried with the power sourced via the USB cable.
- disconnect the UART adaptor from the computer and let the pump unconnected and let the probe under water.
- unpin the “configuration board”
- connect the 12V power supply to one of the CONN_PWR1 or CONN_PWR2 connectors – it would be helpful if, at this stage, you connect at first the wires on the controller side and only afterwards make the connection to the power supply/batteries (a switch in the power circuit may help) Warning: the current circuit does not have any protection against reverse power connectors – make sure you know what you do, otherwise it's likely you'll ruin the circuit (I did it once)
- power on the controller (if you used a switch) or reset the Arduino board – the “power on” on the Arduino board should lit. In the default configuration (no configuration pins pulled to the ground), the setup stage will perform a set of 8 measurements, each one will light the “blinky” LED on Arduino board
If everything is correct, power off the controller, re-establish the “diagnosis” configuration using the “configuration board”, reconnect the UART adaptor to the probe (you may skip the “power” pin on the UART), power on the controller from the 12V supply, reboot the controller and examine again the count values echoed in the serial console – there should be little to no change.
Verifying the pump side of the circuit
- power off the controller and unpin the “configuration board”- let the controller in its "operational mode"
- connect the pump to one of the CONN_PUMP1 or CONN_PUMP2 connectors – mind the polarity
- power on the controller. In its setup sequence, the controller will switch on the pump for 5 seconds.
Step 8: Deployment of a Watering Point
Due to the fact that the probe needs to reach a moisture equilibrium with the surrounding soil and this takes time, the deployment needs to be performed in stages possibly days apart.
One thing to keep in mind: the watering system will measure the humidity of the area surrounding the probe – the implicit assumption is that whatever the probe measures is representative for the average humidity available to the plant. Where this becomes relevant is in the watering strategy, as you can choose anywhere between:
- placing the probe closer to the plant and using small amounts of water in more frequent watering session (say, hours apart). This strategy would be suited for small plants with a small and localised root system and or potted plants (the water cannot escape the pot before wetting it thoroughly)
- placing the probe further apart from the plant and applying large amount of water in unfrequent sessions (10 hours or days apart). This strategy will be suited in watering large plants in outdoors position (young or small trees)
Stage 1 – probe settle
At this stage, all the electrical connections are performed and the controller is mounted in the enclosure of you choice, but the pump will not be connected to the water supply.
If you like, you can keep the controller not powered at all, this stage is not meant to make any adjustments to the controller but only let the probe humidity reach the balance with the surrounding soil.
- sink the probe into the soil
- water the plant manually until the soil around the probe is to what you consider the optimum level of humidity (remember the implicit assumption of “whatever the probe measures is appropriate for the plant”?)
- depending on the watering strategy you choose and the soil structure, you may need to repeat this cycle a number of times a number of times before going into the next stage. Sinking the probe into the ground is likely to disturb the soil structure as well and you want the soil to resettle as good as reasonable possible.
Stage 2 – calibrating the watering system
- Setting the minimum level of acceptable moisture
Reminder: as the moisture level is translated by the capacitance of the probe and this capacitance varies not only because of the humidity but also the soil characteristics (structure, mineral content, etc) it is impossible to calibrate a probe “in lab conditions” and have it working the same when deployed. Which means each watering point will need to be specifically calibrated.
This step is mainly meant to establish the specific level on which the watering event is triggered, it is important that the probe is properly settled and the soil reached the level of minimum humidity acceptable. The followings assumes you decided that “in conditions like this, trigger the watering” (a “configuration by example” approach)- make sure the pump is not connected to the water supply or the watering tube is diverted from the area – the setup phase of the controller logic cycles the pump for 5 seconds (as a mean to verify the pump works) and we definitely don't want to alter the humidity level before calibration
- using the “configuration board”, establish the “read minimal level” mode {0,1,0,0}
- power on the controller (or reboot it if already powered) and step away from it and the probe connections – you have 30 seconds to do so. The rationale for this: the capacitance of the probe is small enough to be influenced by your presence around the controller/probe wires – while the change induced by your presence in the number of counted pulses does not alter the measurements to the point of making the watering system unusable, the change is far from negligible (my estimation is a variation of +/-10%)
- once the measurement of the current soil has been acquired (and saved for future use) the controller will resume it normal cycle, switching on the pump for 5 seconds during the initialization (in the setup() function) – it is the signal by which you will know it's safe to come closer and continue the calibration process
- Configuring the watering time
This step will tell the controller how much water you want to drop at one watering event – also performed in a “configuration by example” this involves:- connect the pump to the water supply
- establish the “watering time” configuration using the “configuration board” - {1,0,0,0}
- reboot the controller. The controller will trigger the pump and will keep it going for as long as the setup configuration is maintained to the “watering time” config
- when you consider the amount of water already delivered, simply pull the “configuration” board from the setup pins – the controller will detect the change and will store the watering time to use at the next watering event
- Configuring the interval between two measurements ("soaking time")
Finally, setting up the interval between two consecutive humidity measurements – mind you, it's not the interval between two consecutive watering event, but how long between one humidity measurement and another (neither of which may result in a watering event, if the humidity is not below limit)- use the “configuration board” to establish the setup configuration corresponding to your choice from the set of predefined intervals – sorry, no custom settings here
- reboot your controller – once you hear the 5s pump test cycle, you know that the setting was recorded and is going to be used for the future
- unpin the configuration board and close the controller enclosure.
Congrats, you're done with this watering point, go to the next one.
Step 9: Hints to Source Dirt Cheap Components
Based on my experience, the only recommendation I can make is the www.pcbway.com for PCB fabbing - the prices for what I sent to them were low (the courier charges where higher than the PCB price - PCB-es were unexpectedly quite heavy for their size), the quality high, you are able to track the PCB-es through their process on their page, took about 2 days from placing the order to completion. For orders placed from OECD countries and in small quantities, I wouldn't be surprised for 10 days or less from order placement to DHL-to-your-door delivery.
For the rest below, don't even take them as recommendations, much less endorsements - take them as hints only (I decline any responsibility if something does not work because of the components you bought).
All I can say is that, using ebay and aliexpress.com with care (look on the seller reputation and read the feedbacks), the thing worked for me.
Below, I'm listing some searches on aliexpress.com very likely to bring back results for the same (or similar) components that I used:
Step 10: Adventures in DYI Land - Earlier Attempts
PCB etching - toner transfer
When I started to fool around with the probe patterns, I used only a Brother laser printer and some super cheap yellow toner transfer paper I bought from ebay, no photoresist and no solder mask.
Oh, boy: the printer, toner and transfer paper combination would not work at first – the toner would refuse to stick on the paper until I discovered that the paper coating, at the temperature the Brother printer needs to melt the toner, is not longer sticky enough for the toner. I wish I have read the “PCB toner transfer Flamethrower style” earlier (just to know how extreme one should be to deal with the Brother toner).
But, in the end, I discovered that, before printing, gently wiping just a bit of the coating with isopropyl alcohol will allow the toner to stick to the paper and (equally important) the toner to be transferred later onto the PBC with an cloth iron. Did I mention gently and just a bit? It's like in: take a gauze, spray it with a tiny amount of alcohol, let it dry for some 20 seconds (it should not feel damp, humid only rather) and pass it gently over the piece of transfer paper at most twice over the same place. Wipe too much of the paper coating and the toner won't transfer on the copper.
Even doing so, I needed to use a kitchen thermometer to find a setting for the iron for a temperature of around 120℃ and not much higher - stop the steam as well.
Even more: don't expect the traces to be very neat and have a sharp permanent marker to correct the missing traces.
The insulating layer over the probes - very low tech style
--
Warning: some discussion I had in the comments sections (thanks, diy_bloke) reminds me I didn't say anything about safety, more specifically about xylene. That's no joke, while it's not as deadly as toluene, xylene would have some nasty effects if not treated with respect - fortunately, the effects are reversible if you are exposed to a low concentration and/or for short times. Stay safe.
--
The protective layer over the traces – what can be simpler? Just dissolve some plastic in a suitable solvent, dip coat the probe (how hard can it to do it manually?) and you're done. Oh, how naïve I was.
Too thick of a layer and the probe won't have enough sensitivity; too thin of a layer and the dried coating will scratch when you stick it into the soil and your probe will end a shorted capacitor.
After multiple experiments going well over a week, I finished by using polystyrene foam dissolved in xylene (no, acetone won't do) until it gets to the consistency of a thin syrup (other plastic/solvent combination I tried would scratch/crack too easily – e.g. superglue in acetone - or will get a gummy consistence once dried (I suspect because of plasticizers). The polystyrene foam seems to have a low level of added plasticizers and the resulted coat is tough enough to resist minor abrasions.
Dunk the probe in the mixture then slowly raise it by its wires (you solder them already, haven't you?) so the the meniscus formed by the solution wetting the probe surface is/stays uniform all along the process (put your eye glasses on if you need them... I did). I used to raise it as slow as 40-50 seconds for the 100mm length – you'll know you raised it too fast (or your plastic/solvent syrup is too thick) if, after 5-10 minutes after dipping, a sizable drop forms at the end of your probe.
Let it dry for about 20 minutes, then use a heat gun (or hair-drier) to force the solvent evaporation - xylene is not as volatile as I would have liked, but other solvents have higher toxicity. While forced-drying don't let the temperature go over 60℃ (if you touch an edge of it, it should feel it somehow hot but bearable) and dry it until you don't feel the xylene smell coming out from your coated probe – don't worry, it doesn't take longer than 20 minutes and you don't actually need to smell it sooner than 10 minutes (because I can guarantee you, sooner than that it will still smell). What if you try to dry it at higher temperature, you ask? Well, the outer layer will dry faster, delaying the drying of the inner layer – it'll take longer. If you raise the temperature over the boiling point of the solvent – for xylene it's 134℃ - bubbles will form underneath, ruining your attempt to have a continuous uniform coat.
Wait... did you think is over? Once the first layer is dry, you'll have about 0.05-0.1mm of coat thickness – far too easy to scratch.
So you repeat the process. Except that now, you will have already one coat which will absorb some of the solvent (and, if you keep your probe too long, will completely dissolve it – make those 40-50 seconds count). And, because of this absorption, you will need to let it dry longer and then force-dry it longer.
And you'll need to do it at least 4 times (and at most 6 times – afterwards the probe becomes notably less sensitive to the external medium).
It takes about 8 hours to coat a single damned probe. Of course you can let each coat dry overnight at the ambient temperature and you'll have about a week for a whole batch of probes.
Or stop being that cheap and go to pcbway.com already (or use solder mask UV-curable paint only if you can obtain a uniform water-proof coat of no more than 0.2-0.3 mm thickness - good luck if you want to give it a try, I didn't)
Multi-PCB assembly
My early prototype involved the controller, a/the pump relay and the Arduino board all on their own PCB, connected with DuPont connector terminated wires. Even more, there wasn't a possibility to configure the controller except the use of the laptop.
The mounting inside the box? Hot glue (I'd post some pictures if I wasn't so ashamed of my - natural for a beginner - naivety).
My word of advice: just don't - it may seem to work on the bench but is totally unreliable in the field.