A simple moisture sensor circuit for keeping plants happily watered.
One of the easiest ways to damage a plant is by letting its roots dry out too much. However, there are consequences for giving a plant too much water, too. They’re just often not so obvious. This simple circuit is entirely analog and, while far from perfect, is easy to build and use.
Plants are great to have around the home. Aside from a vegetable garden, potted herbs and flowers are great for balconies and windows. This is particularly good if you live in a unit, as are vertical gardens and green walls. Indoors, plants with a lot of leaves and which cope with lower light are great for keeping air fresh and are often good at purifying the air. The NASA Clean Air Study even looked at what species of plants would be good in a space environment, finding that some plants remove toxic chemicals like formaldehyde, toluene, xylene, and ammonia. The study on chemical removal was conducted in sealed conditions and only applies to the home in places where air flows poorly.
Whether for food, aesthetics (meaning improving appearance or visual pleasure), or air cleaning, the challenge is remembering to look after plants. Water carries nutrients from soil into the plant and also is involved in most of the internal processes in the plant. If whatever the plant is growing in dries out too much, the plant cannot function and less nutrition is carried into the plant. Light falling on leaves causes photosynthesis in the leaves to produce enough to keep the plant alive, but water is needed for this and soil nutrients are needed for growth.
Too much water is a challenge, too. Many fungal diseases thrive in wet conditions, as do several pests like fungus gnat (which looks like a fruit fly). Root Rot can cause your plant to wither and die, and roots of many plants also need an amount of air, which excessive water smothers. Lots of water flowing through the soil or potting mix leaches nutrients and carries them away. The upshot of this is that you need to be careful not to water your plants too much!
THE DEVICE
The circuit we have here is pretty simple, even by Kids’ Basics standards. However, it’s not the simplest soil moisture sensor around! The simplest variety have less components and light an LED when moisture is present. The two problems with this is that they are not adjustable, and they are used like a test instrument where you have already remembered that there is a plant in need of checking. We wanted something adjustable that you can have in the soil and leave running, with it turning on a light when the plant needs attention.
The best way to do that is to have a circuit which is battery powered, and turns an LED on when the water level gets low. However, one LED sitting there and gradually turning on is unlikely to gain attention. Gradual changes rarely do. The solution is to use a flashing LED, and to make sure it really works, we chose an RGB (Red, Green, Blue) variety. Standard flashing LEDs just blink, at a rate of one or two flashes per second. They are rarely bright, being standard indicator LEDs with a driver circuit embedded in them. The RGB LED chosen here is very bright, and changes abruptly between Red, Green, Blue, and combinations of those colours. This makes it more noticeable than the regular fading RGB LEDs.
SOME HELPFUL HINTS
We encourage you to read all the way to the end of the article before you build. Not only will you then have a better feel for the overall picture as you build, but we sometimes discuss options or alternatives that you will need to have decided on. You will need some basic hand tools for most builds. Small long-nosed pliers and flush-cut side cutters meant for electronics are the main ones. Materials like tape or glue are mentioned in the steps, too. We always produce a tools materials list if you have to go shopping, but anything that is lying around in most homes is just stated in the steps.
As always with Kids' Basics, we avoid soldering to make the build more accessible to more people, but having an adult around can still be helpful. You won't need any particular skills besides being able to identify components at a basic level, and even then, we help as you go along. If, for example, you don't already know what a resistor is, you'll probably be able to work it out from the photos and description in each step.
We do provide a schematic or circuit diagram but this is just helpful if you already know how to read one. Don’t stress if you have never learned, but take the chance to compare the digital drawing of the breadboard layout (which we call a 'Fritzing' after the company that makes the software) to the schematic and see if you can work some things out. You can make this project from the Fritzing and photos alone. You might also like to check out our Breadboarding Basics from Issue 15.
The Build:
TOOLS & MATERIALS (See Text for details): |
---|
Strong Wire |
Scraps of Cardboard |
Masking, Electrical, or Regular 'Rticky'/Cello/Plastic' Tape. |
Electronics Parts Required: | ID | Jaycar | ||
---|---|---|---|---|
1 x Solderless Breadboard | - | PB8820 | ||
1 x Packet Breadboard Wire Links | - | PB8850 | ||
9 x Plug-to-plug Jumper Leads # * | - | WC6027 | ||
2 x 150Ω Resistors* | R3, R6 | RR0552 | ||
1 x 1kΩ Resistors* | R2, R5 | RR0572 | ||
1 x 1MΩ Resistor* | - | RR0644 | ||
2 x 1MΩ Potentiometers | R1, R4 | RP7524 | ||
1 x BC547 NPN General Purpose Transistor | Q1 | ZT2152 | ||
1 x BC557 PNP General Purpose Transistor | Q2 | ZT2164 | ||
1 x Flashing LED of Choice # | LED1 | - | ||
1 x LED of choice | LED2 | ZD0150 | ||
1 x 4AA Battery Pack | - | PH9200 | ||
4 x AA Batteries | - | SB2425 | ||
1m Speaker Wire | - | WB1702 |
* Quantity shown is what is used in the build. Product may only be available in packs.
# We sourced our RGB flashing LED from LEDsales.
We’re actually building two separate circuits here, on one breadboard and sharing a power connection. The probes will also be shared, but you’ll have to move those depending on which circuit you want to use at the time.
You will need some strong wire for the probes. This could be coat hanger wire, fencing wire, or anything else strong enough. Make sure it has no coating, as some is enamelled with a coat so thin, you barely see it. We used mild steel tig welding filler rods, because we had some already.
Step 1:
Place the breadboard in front of you with the outer red (+) rail furthest away from you and the outer blue (-) rail closest to you. Add the three wire links shown as well as two wires that connect the + and - power rails together.
Step 2:
Install the BC547 NPN transistor so that the flat face is away from you. Its left-hand leg (the emitter) goes to the wire link to the upper blue (-) rail. Install a flashing LED with its short (-) cathode leg to the right-hand (collector) leg of the BC547.
Step 3:
Add a 1kΩ resistor (brown, black, black, brown, space, brown) between the short wire link and the middle leg (base) of the BC547 transistor. Add a 150Ω resistor (brown, green, black, black, space, brown) between the long (+) anode lead of the LED and the upper red (+) rail.
Step 4:
Install the BC557 PNP transistor with its flat face away from you. Insert a wire link between its left-hand (emitter) leg and the upper red (+) rail.
Step 5:
Insert an LED with its long (+) anode leg to the right-hand (collector) leg of the BC557, and its short (-) cathode leg in the row next to that. Add a 150Ω (brown, green, black, black, space, brown) resistor between here and the upper blue (-) rail.
Step 6:
Place a 1MΩ resistor (Brown, black, black, yellow, space, brown) from the middle (base) leg of the BC557 to a spot on the board to the right. Add the wire link shown, which jumps one row.
Step 7:
Install two 1MΩ potentiometers. The left one meets the wire links in their rows, and the 1kΩ resistor meets the middle leg (wiper) of the potentiometer. The right-hand potentiometer has its left and middle legs meet the red wire link’s ends, and the right-hand leg currently meets nothing but an empty row.
Step 8:
Cut two lengths of strong wire to use as probes. Use hot melt glue to attach these to a scrap of cardboard or some other rigid material, with about 2cm of the wire above the top of the material.
Step 9:
Cut a plug-to-plug jumper lead in half, and bare the cut ends. Bare both cores of one end of the speaker wire, and twist one half jumper lead onto each. Tape the joins, but we left one of ours uncovered for you to see.
Step 10:
Bare about 5cm of each core at the other end of the speaker wire. You might need to do this 1cm or so at a time. Twist the strands of each into one core, and wrap around the short ends of the probes. Tape the wraps, but again we left ours for you to see.
Step 11:
Plug one of the jumper lead plugs into the row for the base of the potentiometer wiper and 1kΩ resistor, and the other into the upper blue (-) rail. Plug the red lead of a 4AA battery pack into the upper red (+) rail and the black lead into the upper blue (-) rail, and install batteries.
Step 12:
Test your device by dipping the probes into a cup of tap water. Adjust the potentiometer until you have no light. Having only a thin film of water in the cup helps. Now, you can take it to a pot plant that is almost too dry, and adjust the potentiometer until the flashing LED just activates. If you get nothing in either case, disconnect the batteries and check connections.
Step 13:
Move the jumper leads so that one side connects to the upper blue (-) rail. The other side has to connect to the vacant end of the potentiometer. Because the body of the potentiometer hides the legs, you’ll have to be very careful to put this in the right spot.
Step 14:
Connect the batteries, and touch both probes. This circuit is so sensitive that the LED should light just from your body’s conductivity, unless your skin is too dry. Adjusting the potentiometer has only a small effect, and if there is enough moisture, it will have almost no effect.
HOW IT WORKS
The heart of this circuit is the transistor, the NPN BC547. In an NPN transistor, current fed to the base activates the transistor and flows out to ground via the emitter. This allows a much larger current to flow from the collector to the emitter.
Transistors are made up of slices of material called a ‘semiconductor’, which means it conducts under some conditions and not under others. The conditions can be altered by ‘doping’ the semiconductor with other chemicals. Some chemicals result in a P-type material, and others in an N-type material. The types respond to electricity in different ways, so arranging slices in different ways gives different responses. The most common general purpose transistors are ‘bipolar’ transistors, and these have two slices of one type of material, and one of the other. They can be NPN, or PNP. In reality, they are made with very clever manufacturing processes where chemicals are applied straight to the one tiny bit of semiconductor, but the result is the same, so think of them as slices joined together.
There are many other types that are completely different to bipolar transistors, like Field Effect Transistors (FETs), but they’re far less common in learner-level electronics. Common bipolar transistors, which the BC547 is, are controlled by current, not voltage (as opposed to FETs and others, which are voltage-controlled). This makes it really useful for us.
For bipolar transistors, there are always three terminals: Emitter, Base, and Collector. The base is always the one in the middle of the diagram (but not always the middle of the device package), and it does the controlling. The emitter is always described in relation to the base. Current flows across the base/emitter junction to make the transistor work. Look closely at the diagrams and you’ll notice that the arrow points into the base on a PNP transistor, and away from it on an NPN transistor.
A current must flow from the base, to ground. Following the arrows, that means for a PNP transistor, the current must flow from the emitter, into the base, and then to ground: So, the emitter must supply the current and therefore must be connected to the supply voltage. A PNP transistor is controlled by whether or not the current can get from the base, to ground.
For an NPN transistor, the current must come from elsewhere in the circuit, flow into the base, and out of the emitter to ground. An NPN transistor is controlled by supplying a current to the base, or not.
This circuit is based on an NPN transistor. Current flows from the positive supply rail, through the 1MΩ potentiometer R1 and the 1kΩ resistor R2 to the base of the BC547. There is a minimum voltage that must be present here in order to work. The PN junction from base to emitter has a voltage drop across it that must be overcome in order to work. This is around 0.5V to 0.8V for most devices.
We measured ours with a test instrument to be 0.758V. R1 is a potentiometer wired as a variable resistor, while R2 is a fixed resistor that makes sure there is a maximum current that can pass to the base no matter where R1 is set to. This value is enough to saturate the base-emitter junction but not enough to damage it.
However, a transistor is not a simple switch. It is proportional, which is an extension of the word ‘portion’, which means ‘part’. That means the transistor can be partly on. There is a zone where there is some current, but not enough to turn the transistor on at all. Then, there is a zone where the transistor turns on by an amount related to the current flowing through the base. Then, there is a maximum, after which the transistor is ‘saturated’ and cannot be turned on any further no matter how much current is applied. Each device has a maximum base current which it can handle, too, without being destroyed, but this is higher than the saturation current.
In our NPN circuit, the current flowing through R1 and R2 provides the base current. If you swap the flashing LED for a plain one, short the probes together, and turn the potentiometer gently, you will see a point where the LED starts to change brightness up or down depending on which way you’re turning. This is the base current being in the range between saturation and minimum. The driver circuits in many flashing LEDs interfere with seeing this, because they tend to be on or off, with no in between.
Also connected to the base of the transistor is one of the probes. The other is connected to ground. Pure water does not conduct electricity, but it is rare to find pure water. Even distilled water is not pure, although it’s close. Tap water has a bunch of impurities in it, and these allow it to conduct electricity. Rainwater does too, and most importantly, the nutrients in the soil are salts of metals (mostly) and they conduct electricity very well.
The moisture in the soil between the two probes conducts electricity, but how much current flows depends on how much moisture there is. Without moisture, even the salty nutrients don’t conduct. That means current flows from the probe connected to the base of the NPN transistor, to the probe connected to ground. Instead of flowing through the base and out the emitter, activating the transistor, the current now has an easier path to ground, and it takes it, turning off the transistor. As the soil dries out, this path of conductivity through the soil is lost, and the current again flows through the base of the transistor to ground, activating the LED.
This is where the variable resistor R1 comes in. It allows a greater or lesser current to be available, because drier soil will conduct less. Turning R1 up or down creates a sensitivity control, so you can add current to the system at a given moisture level until the LED activates.
In our PNP circuit, the principle is much the same, except the soil conductivity activates the LED in the presence of moisture, not the absence like the NPN circuit. This has valid uses, particularly if you want more of an on-the-spot test where you plug the probe into the soil, then move it elsewhere. The light then becomes an indicator of ‘things are ok’. This is because the current must flow from the emitter, which is connected to the supply voltage, though the base, and out to ground. However, the ground path only exists if there is moisture between the probes.
The resistors are arranged differently, too. The fixed 1MΩ resistor R5 still does the same job, but R4 now limits the current flowing out of the base and therefore through the soil to ground. Because there is plenty of voltage and current from the emitter connected to the supply voltage, the base-emitter voltage of 0.7 (ish) volts is overcome very easily, and this circuit is hypersensitive.
You might notice the different positions of the transistors in the diagrams. This is because the current in the base-emitter circuit shouldn’t be held up by anything. NPN transistors should always be connected so that the base current flows straight from the emitter to ground, known as a low-side switch. If we swapped it so that the LED and its current limiting resistor R3 were between the emitter and ground, their resistance would affect the flow of current from the emitter. For a simple load like an LED and current-limiting resistor, this may not matter. We have even done this in the past in Kids’ Basics for other design reasons. However, it is generally avoided.
Likewise, the PNP transistor is nearly always used as a high side switch. It is connected so that its emitter is connected to the supply voltage, because the emitter is the source of the base current in this case. Any load connected between the supply and the transistor will affect this current to the base. With PNP transistors, the load is connected between the collector and ground. It can be confusing for some people to think of collector and emitter apparently changing roles like this if you think of the labels as belonging to the load. Just remember that the emitter is always labelled by its relationship to the base, not the load, follow the arrows, and you should be ok.
WHERE TO NEXT?
With such a simple circuit, you could choose one half or the other (the NPN or PNP version) and build it onto a backing board like cardboard or foam core, with the probes attached, as a one-piece unit. This would involve one of the smaller breadboards which don’t have power rails, meaning you will have to be careful adding extra wire links to make it all work.
You could, if you were really feeling brave and have some soldering skill, try air wiring it. However, we only recommend this if you already know how.