Wednesday, November 23, 2011

PCB as a Capacitive Soil Moisture Sensor

Electronics enthusiasts have been designing ways of automating plant care for decades, with mixed results. A traditional weak point of these installations is the resisitive moisture sensor, that is inaccurate and prone to degradation. In this post we will design and fabricate an inexpensive capacitive soil moisture sensor out of a printed circuit board that exhibits none of the weaknesses of its resistive brethren.

The Story So Far

Plant care automation is a popular project in the amateur electronics community. Recent examples include the Garduino system, and the twitter-enabled Botanicalls. Both these systems rely on the fact that the resistance of earth that contains water is lower than the resistance of earth that contains less water. This works, but it has two important drawbacks.

First of all, the electrodes suffer from degradation due to oxidation. The voltage applied to the electrodes in the soil attracts oppositely-charged ions present in the soil or water. These ions then deposit on the surface of the electrode. These oxides are insulators, leading an increasing resistance of the electrodes over time. Second, water is actually a rather poor conductor compared to the impurities it contains. Soil resistance is therefore dependent upon the contamination in the soil more than the moisture content. This means that resistive methods require a calibration step that depends on the soil composition.

Capacitance and Dielectrics, for fun and profit

A parallel plate capacitor
Let's take a standard parallel plate capacitor. The capacitance of this device is dictated by its dimensions (the plate area and the distance between the plates), as well as by the material properties of the substance between the plates, the dielectric. It turns out that water has a very large dielectric constant. A capacitor that has water between the plates would have a capacitance that is 100 times higher than the same capacitor using air or rocks.

This is how we are going to build our sensor: we are going to make a capacitor using the soil as our dielectric. If the soil is moist, the capacitor will contain more water. This will result in a higher capacitance. If the soil is dry the capacitance will be lower. 

Touchscreens on iPads and smartphones use this exact same system. Your finger is 70% water. When you touch the screen the composition of the dielectric changes and you cause an increase in capacitance.

A co-planar plate capacitor
As a basis for the sensor we will use a co-planar plate capacitor, instead of the standard parallel plate construction. That way we don't have to get the soil/moisture to occupy the gap in the middle. The electric field lines extend outward from the plates into the dielectric on both sides.

Designing the Sensor

As we have seen in the previous section, we are looking for a way to create a sensor that consists of isolated conductive plates, separated by a narrow gap. The assembly must be waterproof, as it will be in contact with moist soil for extended periods of time. As luck would have it, there is an inexpensive technology that enables us to build isolated conductors in arbitrary shapes with ridiculously small tolerances. This technology is printed circuit board fabrication. 

We design a custom PCB that contains a number of co-planar plate capacitors in parallel. Capacitance sums in parallel, so this will lead to a larger capacity of the entire assembly and therefore a larger capacity swing when the dielectric changes. We want to measure the dielectric constant of the surrounding medium, not of the FR4 fiberglass the PCB is made of. Therefore, we will place plates of the same polarity on both sides of the sensor. This is in contrast to a parallel plate arrangement, where opposite polarities are used.

The sensor, as designed in Eagle
In the image above you can see the sensor as designed in Eagle. The entire assembly is about 4 inch long and 0.5 inch wide. The traces are identical on the reverse side. The PCB sports pads for a jumper header to connect to your circuit, and a pointy tip for easy insertion into your target soil. Note the relatively large separation between the plates. The capacity is actually inversely proportional to the separation between the plates. In a next revision we'll tighten this up significantly. After all, we're paying for 6 mil spacing, we might as well put it to good use!

The physical sensor, in Laen purple!

I sent it off to Laen's PCB order to have it produced. Two weeks and $15 dollars later I received three copies of my sensor, in a glorious purple color. It was my first board using Laen's order, and I'm really happy how it turned out. I have a feeling it will not be the last.

Soak testing.
To make sure the isolation (soldermask) on the sensor is really waterproof, I'm performing an extended soak test. In order to be usable the sensor needs to have a resistance that is at least an order of magnitude larger than the discharge resistor in the measuring system, even after being submerged for a significant period of time. I'm planning to use a resistor in the mega-ohm range. The resistance needs to remain above 10 mega-ohm or so. After 12 hours in the glass, the resistance is still above the highest range on my multi-meter. So far so good.

After the soak test, it's time to start terrorizing the potted plants again!

You can also download the schematic and the board file, both in Eagle 5 format.

The small print: All rights for the design are reserved, but you are welcome to use it in a non-commercial or educational setting and/or to use is as a basis for your own designs. No warranties of any kind are provided. I am not liable for anything you do with these files. If you want to negotiate different terms, contact me.


  1. This comment has been removed by a blog administrator.

  2. Wow!!!
    Can't believe this. I just decided to make a sensor just like yours fingered plates and all. You have designed exactly what I need. I would love to get a copy of your brd and sch files. I too have ordered from laen and have been so impressed with the board quality. I am not building a soil moisture meter but instead a liquid level meter. Check out my post on the subject

  3. Hah, funny how it works out sometimes. Looks like you have quite the setup there. I trust you have seen this capacitive water level sensor: They are using a basic stamp but I don't hold it against them ;)

    I'll be happy to share the sch/brd, but that will have to wait until I am home. You ought consider to significantly tighten up the "gutter" between the fingers in order to increase the sensitivity of the sensor, though.

    I like your schmidt-trigger based cap-to-freq converter. I'll experiment a bit with that ;)

    1. Hey, great!
      Sorry about the double post. (Easily Excited ;))
      The setup is my day job, working at an Engineering school and running experiments in the background. Its good for the students to see me engaged in projects at least thats what I keep telling everyone.

      I am planning on making I think 3 of these sensors and running some tests.

      I'll do 1 fingered board like yours, 1 two straight strips up and down and then the same as that one only with a ground plane on the back so it has shielding. If I keep the surface area the same I hope they are comparable.

      If I do make my own fingered board I'll tighten up the gap. I guess the fingers just make for more surface area?

      Thanks for the link, thats a good article, I had seen it but its been a long time (I used to subscribe), it may have triggered something in my brain as it seems we are doing almost the same thing, only they use an external counter.

      The little oscillators based on the Schmitt trigger are good for all sorts of fun, you can make pwm drivers and many interesting circuits with them.

      Thanks again,

    2. Hey there!

      I've added download links to the original post. The schematic is just a single connector, but you will need it to keep Eagle from complaining.

      Yes, the fingers should increase the capacitance per unit area. If you look at the electric field lines, you notice that material that is far away from the gap contributes relatively little in terms of capacitance. Adding the fingers should increase the total capacitance. However, I have not built and unfingered reference model, so I really can't be sure. Also, I have not managed to find a good software package to model these effects either.

  4. That's really brilliant idea. I like to make this type of circuit censor.. Nice and such a informative post for me as a pcb designer i will try to make it. pcb design

  5. Hi, really nice and simple design this pcb!
    Im looking for a solution to mesure humidity in soil and resistive type sensor is not the best for long time on outside environment..
    Which kind of circuit are u using to convert the capacitance mesured in this pcb to convert it to a voltage to be able to read in a microcontroller adc?


  6. Hey Vitor! At the moment I'm using a charge-discharge circuit similar to the one in this nerdkit tutorial:

    I'm using a different micro, but the setup if similar. Look at the bottom-left part of the schematic. You will see a micro pin (13) connected to both a large resistor and the sensor. Both are connected to ground.

    If you drive the pin high, you will charge the cap (== sensor). If you then configure it as input, it will go into a high-Z configuration. The cap is then connected to ground through the resistor and will discharge with the classic exponential characteristic V = V0 * exp(-t/RC). When it gets below the negative threshold voltage, the pin will change state. You know your supply voltage (V0), you know the switching voltage (approximately) from the datasheet (V). Measure the time and you know t. You know the resistor you put there so you know R. Solve for C, and there's your sensor value.

    It's a bit crude but it works. For more control, you can hook it up to the comparator input of the micro and put a well-defined voltage (internal reference, zener) on the other comparator pin. Then you have precise control over V. You can measure t using one of micro's clocks. I would not use this system for precision measurements, but it should keep your plants alive.

  7. It is an excellent post. I was extremely impressed. It helps me a lot to enhance my knowledge. Thanks for sharing..PCB

  8. Hi Drx I've used your board to mesure soil humidity with very good results.
    My microcontroller is outputing an square wave at about 2Khz, with a capacitor in serial then 10k resistor in paralel (to get sinusoidal wave from sqare wave), then it connects to one pin connector on your pcb. The other pin on your pcb is connected to a ampop precision rectifier circuit like this

    U just have to add a capacitor at rectifier's output in paralel to get a continous voltage to be mesured in microcontroller ADC.

    After this u get a proporcional voltage to capacitance mesured by your really nice pcb :)
    Now my plants are under control and need to tank to you because your pcb give me the start point for something that I was looking for some time and not had much success, just with creapy resistive mesure..

    Best regards

    1. Thank you for your kind words Vitor_A!

      This sounds like a really sensible way of doing it. By converting the frequency to a voltage you do away with all the timing trouble of my solution, or the frequency measurements that ednspace ends up doing.

      Could you elaborate a bit more on your schematic? I tried to mock up a version of it in circuitlab ( but I could not seem to make it work.

      Am I reading this right?
      * The square wave generator output connects to a cap. Based on the frequencies I'm guessing 50nF or so?
      * The 10k resistor connects to the opposite end of the cap and to ground
      * The sensor connects to the connection between the cap and the resistor.
      * The other end of the sensor connects to the input of the precision rectifier circuit.
      * The output of the precision rectifier circuit connects to the ADC input and to a large cap (10uF?) to ground.

      Alternatively, could you please jot down a schematic? I'm really curious to see it in operation.

    2. Hi All,

      I've been working on this same concept as well. From what I have read, it's best to create a pulse train that is in the Mhz range.

      I would also love to see an example of the circuit Victor_A has described.

      The concept I was trying to use was sending the pulse through the sensor, then using opamps to find the peak voltage of pulse train. This could then be sent to the controller.

      Here's the circuit I've been playing with:

      My idea came from Tuxgraphics:

  9. Hi, this circuits are the same concept that I'm testing, u could base on this one to get the ideia
    The ideia is to rectifie an periodic signal to get a DC output voltage.

    This PCB works as a variable capactior when applyed a periodic signal like 2Khz or 4Khz like in flower watering.

    The capacitance changes according to surronding water (soil humidity) more humidity, more capacitance u get.

    For example in my case the output from microcontroller has 2V amplitude voltage, applyied to one pin of PCB (after capacitor), and the other pin u will get the same signal but in different amplitude (more humidity in soil more amplitude voltage u get), I get about 25mV for almost dry soil and 1200mV for a soil with lot of watter (more capacitance, more conductive the pcb will be for periodic signal).
    Then the circuit just rectifies this voltage to get an DC voltage to be sampled by ADC.

    Like rbrainard said there are some sensors that work in range of MHZ, I saw some to about 70Mhz, but for this frequencies u can't use AMPOP because it has limitted bandwidth of about 1MHz - 5Mhz.
    This are better because can sense some volume of soil using this high frequencies to get reflection in soil water, capacitive only mesures surronding humidity to PCB.

    Capacitive also do work, because when u put some water is a plant, this water tends to distribute equally on all soil.


    1. Hi Vitor_A. Sounds like we're all working towards the same concept. Do you have a schematic of you rectifier circuit? I'm leaning towards using the frequency to rectifier circuit as well. I had originally tried to measure the capacitance. But, at high freq, it's pretty tough.

  10. Hi, the circuit that i'm testing now is this one, it works perfect for your pcb
    U have to generate a square wave of about 4KHz to input

    I'm also checking this circuit to optimize this one.
    A higher frequency is desired because on planar capacitor the electrical field goes outside the alternating stripes, sensing more volume of soil to get a more precise reading of an amout water in some like a liter of soil.
    U should try to do the pcb with small alternating stripes, it could range much higher frequencies.

    Keep on touch

  11. U could also check this pcb design and

    They use this pcb design for high frequencies, the electrical field has more range


  12. Hi again, nice circuit from rbrainard but that is for a symetrical power supply, but if u want to battery operated u have only single supply, u have to change reference point ground.
    I redesigned the circuit and u can see here
    Run simulation on time domain simulation U will see the output voltage, then change value of cap sensor when run again simulation to see voltage change on output


    1. Hi Victor

      I am designing a soil sensor device and want to use one of the PCB layout sensors in this topic. Do you have a circuit diagram to convert the capacitance to a voltage, for use in the MHz range? Also, how to design the sensors PCB to accommodate for the higher frequencies?

      I am designing this to work with an Atmega 328. The current circuit is using the ADC and a resistive sensor, but we need to move to capacitive.

      More info on the project can be found here: under the soil sensor group

      Thanks mate! Tom

  13. Hey everyone, check out this!
    A professional moisture sensor (>$200) schematic!

    1. Interesting find! Also available on Google Patents for easy browsing:

    2. Hi,

      I am interested in building an Arduino compatible capacitive soil moisture sensor, came across this discussion and like your idea! I started playing with Arduino for another project and even though I have almost no idea about electronics I would like to give it a try :-)
      The frequency seems to be an important issue (cf.:, because with higher the frequencies the influnce of soil texture and soil conductivity is reduced, which sould make the sensors easier to calibrate. The patent describes a measurement based on two different freqeuncies, which seems very interesting. Sensors like are running on 80MHz.
      Are you aware of any schemeatics for high frequencies that might be used in addition with an Arduino?

      Thanks in advance,

    3. Hey,

      I have done a lot of digging in this field. Basically the Khz range is useless, 5-10 Mhz is ok for normal textured soil. But for sand and high salt content soils you definitely need 70 Mhz, no need to go higher with FDR (based on official studies).

      I have seen in some datasheet that VH400 uses 10 Mhz, so its an entry level.
      10 Mhz is also used in ECH2O probes: EC-10, EC-20 (see the previous patent)
      70 Mhz: EC-5, same patent with higher frequency (the fastest XOR gates you can get)

      No need for Arduino yet, the output of these sensors are simple DC voltage.
      I would love to see a VH400 schematic. The other ones are molded into plastic.

      I built the 10 Mhz based patent, it works fine. You have to fine tune the RC, but only uses 1 IC. Build that first and take some readings. (calibrate in a glass of water)


    4. Hi mrx23dot,

      thanks for your reply!
      Do you know of any publication concerning the MHz problem? There must be some physical law behind - at least I hope ;-) I will also ask a geophysicist.
      Ok, I understand the analog voltage output for Arduino.
      Do you - or someone listening - have some eagle board files of a MHz circuit to share? Would be really helpful to me.

      Thanks and cheers,

    5. Hey,

      I cant find the frequency study, but here are some product frequencies and specs:

      I just used a breadboard.

      Sensor length should be 10-25cm, with parallel traces.

      Use a trimmer for determinate the resistor size (before the XOR gate). Set it so the output DC voltage would be <1V.
      You have to calibrate the sensor, the output changes about 0,1*Vcc to 0,2*Vcc. And is independent of temperature.

      Also works great as a liquid level meter.


    6. Thanks!
      However, I am interested in DrX's interesting design and thus an "optimzed" schematic/board for it.

      ps: Seems many commercial sensors run at 80Mhz (Such as the VH400 and the WaterScout sensors.)


    7. Hi mrx23dot!

      Did you build that sensor, you linked?

      Don't you have a schematic on your PC that can be opened by Eagle? I would thank you soo much if you could post it.


  14. This comment has been removed by the author.


    2. Thx, I just have one more question. Are U sure about the value of the 10kF capacitor? I think it could be a quite huge one. :)

  15. Hello,
    I was interested in making my own soil moisture sensor and I was wondering... would an oscillator circuit of this kind be suitable for this application ?

    Thanks a lot!

  16. Hello, I dissected a vegetro nix sensor if anybody wants to see pictures ill post them. Disappointingly, what I take to be a microcontroller has had its top sanded off. Great blog!

    1. Hello,
      Excuse me to discover to late this interesting blog. I´m very interested in the project. I have the vegetro nix sensor, but it still in use. Of course I would like to see the circuit. Pleas could you send me it?

  17. Hi Huck Milton,

    Please post the pictures of the vegetronix sensors inside.
    Thank you!


  18. Hi DrX,
    I'd like to use this sensor in my thesis.
    Do u give me permission for that? In case of "yes", how could I refer to you? I shouldn't refer to a guy called "DrX" :)


    1. Hello Edina
      Have you finished your Thesis? Could I see it? I´m irrigation engineer and I m very interested in this subject. Please let me know from which University...

  19. Interesting article, thanks.
    How did you come up with the PCB form-layout factor like this? did you try to calculate the expected average capacitance value of the pcb sensor when inserted in the soil?
    What value did you get on the pcb sensor posted? in the order of 10pF, 100pF etc?
    Can you post more information?

  20. Hi,
    I am working on a sensor circuit for home plant applications,
    I found this blog very interesting.
    If you have any experience with soil moisture, pH, etc, and you are interested to collaborate and forward to me any information.
    All people that send useful information I will send to them one of the first prototypes of my sensor.
    I am looking for a smart way to built and integrate a capacitance moisture sensor, built on the PCB, ideas how to build a good oscillator and measure the frequency drift.

  21. Hi, nice build! I've made my own version - it uses the same low pass filter idea. I've settled on 1MHz as it was performing OK with standard component values I had, but it can be made to run up to 8MHz with some battery lifetime penalties.

    I've made a little study of the technique and how to select resistor values:

  22. Hello!

    I stumbled across your blog during my research on capacitive soil moisture sensors. I am building an irrigation control system using soil moisture sensing for my graduate research project in Mechanical Engineering and found your design to be similar to what I was looking for. I went ahead and ordered 3 PCBs and have been having fun building the system around these. I am nearing the end of construction and am starting to write my research paper, and was wondering how you would like to be cited.

    Please e-mail me at Thanks!

  23. Hey
    This post is really amazing, just what I needed right now.. I'm working on designing an automatic irrigation system..
    And I would like to use your ckt as my sensor ckt, but i'm unable to download the board and schematic links
    Can u please help me asap?

  24. Is the Arduino Capacitive Sensing Library enough to use with this sensor ?

    Or do i need some extra circuit to make it work ?


    1. I only have a passing familiarity with Arduino, and no experience whatsoever with that library. It looks like it might work with the right component choices, but I don't know for sure one way or the other.

    2. This comment has been removed by the author.

    3. Ok thanks.

      It seems it's principle is very similar to the NerdKits circuit principle. But instead of measuring discharge time, it will measure propagation time, from one pin to another.

      I'll test both, thanks !

      Another thing that i didn't understood correctly: is your PCB layout good for measuring humidity using higher frequencies like 80 MHz ?


  25. Hi,

    This is the closest to a DIY capacitive soil moisture sensor that I've seen in my one day's googling. I like it.

    I tried to sift through all the comments and it seems there's a few designs out there. I'm failing to see if there was any conclusion as to what design is the best/straightforward. Vitor_A seemed to have it nailed down, did you (or someone else) try his setup?

    I am surprised that there aren't more pages like yours. Every other irrigation system relies on the resistance measurement which - as you pointed out - is prone to a number of weaknesses. I'd really appreciate if you could point me to the right direction. Like many other green thumbs, I don't have the formal electronics background, just trying to figure it out and hope that the part I don't understand, just works :)

    Nice work!

  26. Could soneone please explain why the high frequency setup is best?
    What speaks against a much simpler method:

    Unknown capacitor (soil probe) in series with a known capacitor. Both are loaded by a DC voltage. From the known capacitance and the voltage drops on both capacitors the unknown capacitance can be calculated.


  27. Hi, I'm a soil science researcher (not an electrical engineer), and have long experience using soil moisture sensors. The reason why high frequency set up is best lays on the fact that the dielectric constant is a complex number, i.e. a real part + imaginary part. The real part is dependent on soil moisture (the one you are insterested on measuring) but the imaginary part is dependent on the conductivity of the media and it is inversely proportional to the frequency. By using high frequency sensors (on the MHz range) you get rid off the unwanted salinity contribution on the total dielectric constant. The whole picture is rather more complex due to the so called Maxwell- Wagner effect but this is basically the main reason why low frequency sensors are highly affected by soil salinity and therefore would give artifact changes in soil moisture that could be due to changes in soil salinity.

  28. Here a link to a paper rather difficult to find that explains the principles discussed above, and also some ideas for building what the author calls a "tuned" sensor, which avoids the need of a high working frequency

  29. Why don't you use Timer 555 to make output frequency proportional to sensor capacitance and then measure frequency?

  30. I thought I would chime in here and share my project as this project was a big help to me.

    I've designed a sensor which uses a printed PCB similar to this one here. The trouble with the one here is that wires are required to connect the sensor to the frequency measuring device (arduino). Therefore you also pick up capacitance along the connecting wires which introduces significant error. One option is to use low capacitance shielded twisted pair wire, however this is a sub-optimal workaround. I've got around this problem by mounting all associated electronics onto the pcb. I've used a Teensy 3.1 as my frequency measuring device as it is able to measure frequencies up to 70mhz with the freqcount arduino library. Also mounted on the PCB sensor is a schmitt trigger 74hc14n. The teensy measures the frequency and then puts out an I2C digital signal to communicate back to a host arduino which logs to an SD card and outputs to an lcd screen. There's also a P82B715PN I2C extender on the sensor pcb so that I can run long wires back to the host arduino.

    I'm happy to share all my working code and anymore information with anyone who would like it.

    Here's a photo of the proof of concept (using a modified version of this pcb sensor)

    And here's a photo of the pcb i'm currently having printed:

    1. Hi Michael,
      I am the Anonymous from previous post :) . You are right about added capacity from line. I am using Frequency to Voltage converter after the 555 timer and also mount parts on sensor's PCB. But the most important, I think, is that you are not measuring absolute values in percentage of humidity. So you can easy correct values in software. What is the approx capacitance of sensor in your design. I think the capacitance of above design (shown at this web page) is about 25-100pF

    2. Hi Michael,
      I am developing circuit for soil moisture measurement. Could you share how we get the voltage proportional to capacitance change. Are you using oscillator then
      count ?


    3. Hi Michael,

      70Mhz is suitable for measurement? So if you set up an oscillator in which sensor act as capacitor, out put frequency is variable. So how to use 70Mhz for measurement?