coco coir

Analog Soil Moisture Sensor

| November 20, 2012
Photo Credit: Keith Knoxsville
A Hen and a Drake Green Teal on the truck bed. Not a limit on anything, but a fun morning out.

There are a lot of DIY moisture sensor articles out there. They are quite basic in principle. Gardenisto articles assume basic knowledge of programming, microcontrollers, and circuit design. We generally prefer to use the Arduino for our applications, as it is so widely used and supported. Our example code is also written in C, and intended for use on the Arduino.

This article focuses on the principle of analog sensor measuring via the Arduino microcontroller, as well as real world usage in a hydroponic coco coir growing medium.

How does a moisture sensor work? As water saturation increases, so does the conductivity of the soil or growing medium. If a small electric current is applied to one sensor lead, then at some fraction of that current should be measurable on another sensor lead a small distance away.

Galvanized nails are also commonly used, simple and effective, but for our basic moisture sensor, we went a little more compact. Two lengths of insulated steel jumper wires are secured in heat shrink tubing. The ends are left exposed. On one end the exposed leads are bent almost 180 degrees back. Caution should was taken to ensure the bent leads are not in contact with one another.

The wires are inserted into a small diameter aluminum tube, just short enough to leave both ends exposed and workable.

DIY Moisture Sensor

Whilst leaving both ends exposed and workable, wrap and secure heat shrink tubing beyond the full length of the tube. The entire thing should feel rigid. This will allow the sensor to hold up to being moved from location to location, and a little abuse.

Our example keeps the wiring fairly simple. It is possible to over complicate the circuit with transistors, or a power source that flips back and forth to prevent an electroplating effect and corrosion of the sensor leads, but for our example we left it simple.

We did add a variable 100k potentiometer to make minor mechanical adjustments.

We ran the power wire to a digital pin, the ground pin to the ground, and the sensor wire to an analog pin on our microcontroller. Our microcontroller is an Arduino, based on the C programming language. They are inexpensive, and have made professional level hardware interfacing available to any hobbyist.

To check soil moisture, we turn on the digital pin which powers the sensor, and give it a fraction of a second to stabilize. We then take analog readings on our analog pin. The readings are done inside of a loop to gather 20 readings before taking the average.

for (i = 0; i < 20; i++){   val = val + analogRead(analogMoisture); } val = val / 20; // take average val = val / 4; // scale to 8 bits (0 - 255)

The digital power pin for the sensor is then turned off. The result is printed to the serial monitor. The following code was extracted from a larger coding block of a more advanced sensor, and formatted to run independently as a simple Arduino program. Entering ‘2’ into the serial monitor will return readings.

* Simple analog moisture sensor.
* Leave us a question or comment at

int analogMoisture = 0; // pin number of analog moisture sensor readings
int digitalSensorPower = 12; // power up/down pin for sensor readings

int i; // variable used in FOR loops as counter
int val; // variable for reading Moisture status
int intSerialVal = 0;

void setup() {
   pinMode(analogMoisture, INPUT);
   pinMode(digitalSensorPower, OUTPUT);

void loop(){

   intSerialVal =;
   if ( intSerialVal == '0') {
     digitalWrite(digitalSensorPower, HIGH);
     delay(10); // 10 milisecond delay for stability post power on

     for (i = 0; i < 20; i++){        val = val + analogRead(analogMoisture); // sensor on analog pin 0      }      val = val / 20; // average      val = val / 4; // scale to 8 bits (0 - 255)      Serial.println(val); // Send Sensor Readings      digitalWrite(digitalSensorPower, LOW);      } }

So what does the returning value mean? Before using our sensor on our coco coir growing medium, we created a set of controls by measuring cold water, warm water, and air. The values we attained were: H20 cold:149-146, H20 warm:163-161, Air:0. For a healthy plant in our growing environment, we try and let soil cycle between partially dry, and wet but not over watered. We determined our plant health was optimal when the coco coir moisture level was in the 120-127 range after watering.

Of course, there are additional considerations to make, as you'll notice from the controls. The electro conductiviy of water changes with temperature as well as the level of salinity caused by nutrients in the growing medium. I'll expand on these issues in a more advanced post, but for simple moisture monitoring this method is simple and effective.

Tags: , , ,

A Simple Hydroponic Drip System

| February 13, 0201
Photo Credit: Keith Knoxsville
A Hen and a Drake Green Teal on the truck bed. Not a limit on anything, but a fun morning out.

Basic Drip SystemA simple automated drip irrigation system is pretty easy to build. Drip hydroponic systems offer unfamiliar hydroponic growers an opportunity to work with dirt-like growing mediums, but unlike soil the hydroponic growing mediums offer greater flexibility and control over aeration and moisture holding capabilities.

Our example system is very basic in principle. Water is sent through drip irrigation to plants from a reservoir beneath the growing container. Plants are potted in a pot or growing container filled with a 50/50 mix of coco coir fibers and perlite. The excess runoff is returned through drainage to the reservoir via two 1/2″ hoses. The hoses are attached to barbs, securely fit into grommets, that fit into drain holes that are drilled into the growing container. The system automatically runs off of an 24 hour outlet timer.

Our example uses basic irrigation equipment, a pond pump, and a fairly basic timer. It is also stowed nicely into a custom cedar planter box to make things a bit more aesthetically pleasing.

Basic Drip System CloseupThe cost to build this system can range based on availability of materials, and your ability to price shop. The system pictured, cost roughly $45-$50(sans cedar planter box) and can accommodate a couple more plants. The cost would increase as one scaled the system to accommodate more growing beds. Its a simple economic issue of needing a more powerful water pump, additional plumbing, more growing containers, etc.

What you will need for this basic hydroponic drip system is in the build list below. Shown are quantities, and what Gardenisto perceives to be reasonable ranges on the cost of equipment in US dollars.

Drip Emitter Setup1. Coco Coir ($5.00-$25.00)
2. Perlite ($3.00-$12.00)
2. Pot or growing container WITHOUT drainage. ($2.00-$12.00)
3. Small Reservoir or 5 gallon bucket ($2.00-$120.00)
4. 1/4″ riser pipe, 6″ minimum length ($0.15-$0.99)
5. 1/2″ drip line QTY 8-10 feet ($2.40-$6.00)
6. 1/2″ barbs QTY 2 ($0.30-$1.50)
7. 1/2″ grommet QTY 2 ($0.40-$2.00)
8. 1/4″ drip line QTY 10 feet ($0.50-$2.00)
Drip System Overview9. 6 Zone Pressure Compensating Drip Emitter with 1/2″ FNPT QTY 1 ($2-$6)
10. 1/2″ female to 1/2″ barb adapter QTY 1 ($0.30-$1.20)
11. Adjustable Flow 1/4″ drip risers QTY 6 ($2.00-$6.00)
12. Water Pump – about 200gph ($10.00-$60.00)
13. 24 hour/7 day Outlet Timer [mechanical or digital] – ($2.99-$25.00 )
14. Air Pump ($4.99-$29.99)
15. Air stone ($0.99-$1.29)
16. 3-5 feet of 1/4″ airline ($0.99-$3.99)

Tags: , ,