Sunday, October 30, 2011

Arduino Garden Sprinkler - Making the Sensor

This is a follow up of my previous posts on making an automated garden sprinkler, using the Arduino platform. I'll detail out the making of the humidity sensor here. The property of soil that is most impacted by humidity is its resistance / dielectric property. Commercial humidity sensors are based on capacitance or impedance measurements being affected by humidity change. While that is probably a much more appropriate method, just measuring the soil resistance provides good enough accuracy and sensitivity for the purpose of automating our sprinkler.

Humidity Sensor Circuit
The soil humidity sensor I'm using is based on a simple voltage divider circuit. We calculate the soil resistance by measuring the ratio of voltage drop across a known resistance R1 to that across the soil probes R2. Resistance R2 varies based on the amount of humidity in the sensor - the more the humidity, the less the resistance. Choice of R1 is based on the average resistance of the sensor (R2) in the humidity range where we want the most accuracy. I am using a resistor of 330 ohms which I determined by measuring sensor resistance by creating a controlled environment through a pot full of soil. While choosing R1, make sure that it is large enough so that the sensor circuit draws current within limits. It is better to leave room for different sensor types by using a potentiometer (1K should be fine).

The resistance can be calculated as:
R2 = R1 * Vs / (5-Vs)
And if the voltage is applied in the reverse, R2 = R1 * (5 - Vs) / Vs.

Since Arduino ADC values range from 0 to 1024, the corresponding equations become:
R2 = R1 * ADC_Reading / (1024 - ADC_Reading)
R2 = R1 * (1024 - ADC_Reading) / ADC_Reading

In my sprinkler circuit I use the second scheme mentioned above, where the +5V is applied to the sensor terminal and R1 is grounded. The sensor reading the sprinkler unit displays is the ADC reading. It also displays the resistance calculated for reference.

Materials (exact dimensions are not important):
  1. Plaster of Paris
  2. 1 x Cylindrical plastic piece. 3 inch height, 3 inch dia (1.5 inch after cut . see step 1 below). A piece from a plastic bottle would do.
  3. 2 x Galvanized screws. 2 inch long, 4mm dia.
  4. 4 x nuts to fit the above screws
  5. Masking tape
  6. 0.5 meter multi strand copper wire. Of the same gauge used for home electrical wiring.
  7. A 1 inch square piece of stiff plastic. A piece from old plastic credit card would do.

The slideshow below shows the materials and a few steps while making a sensor (detailed immediately after). In the text of the steps, the numbers in brackets refer to materials above.


Steps:
  1. Cut the cylindrical plastic piece (2) along its length so that it can be opened up by pulling it apart. Note that once cut, the plastic will usually wrap on itself and the resulting diameter will become smaller than earlier. Choose an initial size larger than what you want finally.
  2. Use masking tape (5) to seal the cylindrical piece (2) from all sides except one end
  3. Punch two holes of around 5mm dia on the stiff plastic square piece (7) approximately 15mm apart. A regular paper punch would do the job. Place the 2 inch long screws (3) into the holes. Use one nut (4) on each screw to tighten. Make sure they are roughly parallel.
  4. Strip the ends of the wire (6). Tighten them, one each on two screws (3) using two nuts (4) on each screw as a pinch. Seal the edges where the wires join using some tape to prevent loose wire strands from shorting the terminals. Cut the plastic piece (7) so that it fits into the cylinder (2).
  5. Mix PoP (1) and pour into the cylinder (2) till two inches height. Maintain a gel like consistency. If the mixture is too watery you may get cracks when it hardens.
  6. Push the screw contacts into the PoP mixture till it is sticking out slightly from the PoP gel but completely inside the plastic cylinder.
  7. Hold the wires from the contacts straight up and fill up the remaining part of the cylinder with more PoP gel till the top, sealing the contacts completely inside.
  8. Leave the setup for 30 minutes for the PoP to harden enough. Then tear out the masking tape and open the outer plastic mould. You have your sensor! Leave it overnight for the PoP to cure and harden completely.

2 comments:

Anonymous said...

Excellent data. Lucky me I reach on your site by accident, I bookmarked it.

prasad said...

Splendid stuff.. seriously....

Prasad

www.cricforu.com