The basil speaks to me

Intro

Part of my home automation system is monitoring the well-being of various other non-human species around the house. So i started with the plants. Since they are mostly fixed creatures and generally require only water input from humans, monitoring the soil humidity is a good start.

How

There are quite a few ways to measure how much water is in the soil, some of them described here. But the internet shops are full of cheap soil humidity sensors which don’t work. They are based on measuring the resistance, which due to the current present induces corrosion. Andreas Spiess has a nice video explaining the problem where he also shows the newer type of sensor available. This one:

These sensors measure the moisture of the soil through the use of a capacitor made of PCB tracks. Higher moisture results in higher capacitance which changes the output voltage. The simplified block diagram of the sensor is below, but you can also find another description of the sensor here.

The way it works is this: there is a TLC555 used as an oscillator (passives around omitted)  which produces a square wave at around 500 kHz, which has an amplitude almost equal to the power supply of the 555, since this is a rail to rail version. This wave is passed through a low pass filter formed between a resistor and a capacitor made of PCB tracks (R1, C1). This capacitor is moisture dependent, with higher capacitance resulting in a lower pass corner, which results in a more attenuated signal. To produce a DC voltage from that amplitude a simple diode and capacitor rectifier is used (D1, C2, R2).

But why all this you ask? It is quite possible (and products exist) where the soil capacity influences the frequency of the oscillator. You just count the frequency and you are done. But since the capacitor is low value, the frequency will be quite high. This poses a lot of problems to the micro counting it, since it needs to rely on some hardware capture module, which is complicated for Arduino users. As frequency to voltage conversion is more complicated to use on the variety of arduino compatible boards.

What is the problem?

The issues I encountered are probably someone else’s blessing. The sensor is designed to be operated from a supply larger than 3.3V and contains an on board 3.3V LDO which powers the whole circuit. This results in a fixed internal supply and an output which can theoretically go from 0V to 3.3V (the 555 is a rail to rail version and let’s ignore the diode for a while). This makes it easy to supply and interface to something working at 3.3V or 5V which is most platforms of micro-controllers that are mains powered. But…

… the output of the sensor is dependent on the supply of the TLC555 oscillator, which is normally 3.3V, as long as the input is larger than that and the regulator does its job. However, my battery powered sensors are normally supplied by two AA(A) batteries, meaning that a 2 to 3V supply is available. I could, of course make a node taking 3 batteries and use a 3.3V regulator, but where is the fun in that?

Solution

Since the CMOS version 555  on board can operate from 2 to 15V which covers most of the two battery range, could the sensor operate without the regulator? Obviously this means it’s output is dependent on the supply as well,  but that is something a microcontroler can know. Enter one de-regulatorized sensor:

On for some tests now. I tested the sensor in two circumstances: dry (just on the desk) and with the capacitor completely submerged in water (no, not coffee), which looked like this:

I then varied the supply between 1.8 and 5V and checked the sensor behaviour. And here it is: the sensor is so finely linear:

That means that once I know the supply, I can determine what output voltage corresponds to a completely dry and completely wet sensor:

Vdry = Vsupply*0.96-0.37
Vwet = Vsupply*0.63-0.7;

The sensor output (0% to 100% moisture) will be between the two lines (red, blue) at any given supply. The high voltage (Vdry) is as expected almost equal to Vsupply minus one diode drop due to the circuit. The low voltage however has a much lower dependence on the supply. Once I know the dry and wet expected ranges of the sensor, everything in between is scaled linearly.

I used one of my 1000²  ZEN sensor nodes to get the readout. This is a very tiny version, which attaches on top of a 2xAA battery holder.

To keep low power, the sensor VDD is coming from one of the GPIO pins and will be turned off most of the time. You really don’t need to know the plant humidity more than once per hour. The the exact output from that pin is read by the ADC to monitor the sensor’s supply and used in the calculation. This is needed because the 5mA the sensor draws causes a perceivable drop on the pin driver.

Here is the sensor in-planted in my basil pot

And now, the basil speaks to me:

The first jump (from 0 to 9%) is after the sensor is placed. The second jump is watering the plant in the morning.

Left to do

The plan is to probe quite a few other plants soon, but right now I am waiting for more sensors to arrive from 2 different sources. I will measure multiple sensors without regulators, to get some statistical data on the variation. Stay tuned.

Also need to find a way to pack these things, the top side of the circuit will need to be well covered since it will most likely get wet.

Bookmark the permalink.

8 Comments

  1. Thank you for the tip, you opened my eyes for an overseen problem.

    As for the cover you can use this one (if you have access for a 3D printer): https://www.thingiverse.com/thing:3562757

  2. The other soil moisture sensing method I’ve seen is resistance between nails in plaster of paris that absorbs moisture. I have no idea how they compare to capacitive sensors, so would be interesting to compare. I also don’t know how temperature and fertilizer affects either.

    https://hackaday.com/2010/03/15/soil-moisture-sensing/

    • Hey, thank you for the tip. I don’t think that box will help if it is rained on it. My current plan is just to dump a significant amount of hot glue on the end of the sensor where the electronics and connector are. However, I don’t know how the glue will react to the elements.

  3. Pingback: A Capacitive Soil Sensor Hack For Lower Voltage Supplies

  4. Pingback: A Capacitive Soil Sensor Hack For Lower Voltage Supplies | Ed Hagopian

  5. Indeed rezistive is possible if you use a material that will not react to many of the soil components. Unfortunately the cheap ones are not really covered in something tough and thick enough. I’ll post updates about how they behave in the soil over time.

  6. One further comment on resistive sensors, the shiny one available on Chinese webshops and tested by Andreas Spiess is indeed total crap as it will electrolyse before your eyes. Still, there is a place for resistive measuring. I am using carbon rods. Works pretty well. Other way is to use metal, but to only apply current for the few milliseconds you are measuring and use large intervals

  7. Interesting work with this sensor. Good to know it is lineair. I am still a bit worried about the coating on the sides. Time will tell if it stays ok

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.