This instructable describes how you can build your own soil moisture sensor. There are a lot of instructables online about soil moisture sensors, but not that much about a self-made capacitor for measuring soil moisture content.
With the simple resistance measuring, the biggest issue is the corrosion of the metal sensor, not just because it contacts the wet soil, but also because of the electric current which causes electrolysis of the sensor. Feeding the sensor with an AC or a pulsating DC may fix this problem for a little, but we prefer to make a capacitor as a soil moisture sensor.
There are some advantages to a capacitor. You avoid corrosion , but capacitive measuring also gives a better reading of the moisture content of the soil in comparison with the resistance measurement. The electrical conductivity of the soil is increased by salts, so fertilizers added to the ground may result in incorrect readings.
The capacitor that we build will measure the time that is necessary to charge the sensor. The charging time will increase if either the resistance or the capacity increases. The resistance is constant and the capacitance increases if there is water between(or around) the sensor, because the relative permittivity of the dielectric material increases.
Our capacitor is build out of simple soda can, so you don’t have to waste money on this sensor. And it is fun to build sensors from ordinary things. You can also choose your own materials to built the capacitor. We made use of a Photon, but you can also use other devices such as Arduino.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Tools, Materials and Skills
· Cola can
· 15 Wires
· 2 long wire without pins
· 3 Led-lights
· 4 Resistance of 1 M Ohm
· 1 Resistance of 220 Ohm
· 1 capacitor of 100 nF
· 555 Pin ( NE555N)
· Glue pistol
· Soldering tools
· Programming on Particle
Step 2: Building the Condensator
1. Cut the cola can in two equal plates (10 x 7 cm).
2. Cut one small hole in the corner of each plate.
3. Get two long wires without pins ( 50 cm) and cut the plastic away from the ends.
4. On the one end attach a wire with a pin, and on the other end attach a plate.
5. Now you have to solder the wire to the plates to make sure the connection between the wire and the plate is okay. You also have to solder the wire to the wire with a pin because this is going to be the connection to the Breadboard
6. Put tape around the plates and make sure it is isolated, make sure that there isn't space for water to get to the plates.
7. You have to make sure that the distance between the plates is constant, so you have to saw two wooden bars with equal thickness.
8. Glue the two bars on the sides of the plates, make sure the distance is around 1 cm.
9. The condensator is now finished. It should look like the picture above.
Step 3: Wiring Scheme
Above is shown how the breadboard is built up, the circuit is also shown.
The blue resistance are of 1 MOhm, and the brown one is of 220 Ohm.
The wires that go to the right are the wires from your self built capacitor. Our capacitor doesn't have a positive or a negative side so it doesn't matter how you put the wires in de breadboard.
There is a pin in these board which is called 555 Pin. We used this pin because the capacitance of our sensor was very low (around 0.2 nFarad), so we needed to add very high resistances to see the charging time in our output. Theoretically the capacitor is charged in 0.2 milliseconds with an resistance of 1 M ohm. The problem with the photon was, that it could not handle this high resistances. The electrical current was flowing within the photon instead of through the resistances and the sensor. So we made use of an 555 pin (NE555). This is an integrated circuit (chip) used in variety of timer, pulse generation and oscillator applications. We use it to avoid the electrical current from flowing only within the Photon. Because of the 555 pin, the heavily reduced current (because of the high resistance) flow through the sensor. The 555 pin has 8 pins, with each another function. See the picture above.
Pin 1 connects the 555 timer chip to ground.
Pin 2 is the trigger pin. It works like a starter pistol to start the 555 timer running. The trigger is an active low trigger, which means that the timer starts when voltage on pin 2 drops to below 1/3 of the supply voltage. When the 555 is triggered via pin 2, the output on pin 3 goes high.
Pin 3 is the output pin. 555 timer's output is digital in nature. It is either high or low. The output is either low, which is very close to 0V, or high, which is close to the supply voltage that's placed on pin 8. The output pin is where you would connect the load that you want the 555 timer to power. This may be an LED, in the case of a 555 timer LED flasher circuit.
Pin 4 is the reset pin. This pin can be used to restart the 555 timer's timing operation. This is an active low input, just like the trigger input. Thus, pin 4 must be connected to the supply voltage of the 555 timer to operate. If it is momentarily grounded, the 555 timer's operation is interrupted and won't start again until it's triggered again via pin 2.
Pin 5 is the control pin. In most 555 timer circuits, this pin is simply connected to ground, usually through a small capacitor, about 0.01 µF capacitor. This capacitor serves to level out any fluctuations in the power supply voltage that might affect the operation of the timer. Some circuits (though rare) do use a resistor between the control pin and Vcc to apply a small voltage to pin 5. This voltage alters the threshold voltage, which in turn changes the timing interval. Most circuits do not use this capability, though.
Pin 6 is the threshold pin. The purpose of this pin is to monitor the voltage across the capacitor that's discharged by pin 7. When this voltage reaches 2/3 of the supply voltage (Vcc), the timing cycle ends, and the output on pin 3 goes low.
Pin 7 is the discharge pin. This pin is used to discharge an external capacitor that works in conjunction with a resistor to control the timing interval. In most circuits, pin 7 is connected to the supply voltage through a resistor and to ground through a capacitor.
Pin 8 is connected to the positive power supply voltage. 555 timer ICs need DC voltage in order to operate. This is the pin which connects to the DC voltage to power the 555 chip. The voltage must be at least 4.5V and no greater than 15V. It's common to run 555 timer circuits using 4 AA or AAA batteries for 6V or a single 9V battery.
Step 4: Code for Particle.io
int LEDR = D2;
int LEDY = D3;
int LEDG = D4;
int meting = D1;
unsigned long pulse;
int resistance = 2000000;
pulse = pulseIn(meting, HIGH);
capacitance = 1000 * pulse/(0.7 * 2 * resistance);
if (pulse < 15000 && pulse > 800)
if (pulse < 800 && pulse > 250)
if (pulse <250 && pulse > 0)
Above you see the code from particle.io, you can easily make your own account.
In this code we used the function pulseIn. This function measures the time between the pin to go high and to go low again. It measures this time in microseconds, we can also say that this represents the time of the capacitor to charge.
Our sensor measures three levels, the parameters in our script are determined by calibration after testing with wet, half wet and dry. After the parameters there is a code which says which LED has to be LOW or HIGH. The LED's tell you if you have to irrigate the plant or not.
Particle.publish gives us an output in console.particle.io, the delay is because we don't want that much output. You just have to copy this to your addres bar, you can check this on any device , just log in and then on the left side you have to click on logs and you will see your results.
Step 5: The END
I hope you enjoyed building your own soil moisture sensor!
If you have any questions, feel free to ask!
Participated in the
Epilog Contest 8
Participated in the
Arduino Contest 2016
Participated in the
First Time Authors Contest 2016