Soil Moisture Sensor Update

Friday, June 24, 2011 by darco
Posted in ,

I've heard a lot of feedback on my soil moisture sensor project, and I wanted to update everyone on how it is going.

Last weekend I did a lot of work on these devices and I've made some significant progress. I now have the firmware to a point where I can remotely communicate with the sensor, perform readings, etc. I've also made a few observations after working with the most recent board layout.

My original prototype had both a sensing plane and a ground plane, something like this:

MoistureSensor

After some experimentation, I prematurely concluded that if capacitive touch interfaces don't need a ground plane, then a capacitive soil moisture sensor might not either. I re-designed the prototype layout to instead feature one sense plane which was as large as possible, thinking that this would provide the best results.

single-zone

I was excited last weekend as I was putting all of the pieces together that the device easily detected my hand as it closed around the sensor—it appeared to be much more sensitive than my previous prototype. I then went to fetch a glass of water and dropped the sensor about two-thirds of the way in. I looked at the reading and was startled to notice that it barely registered anything!

Not sure what might be wrong, I added a pinch of salt to ensure that the water was electrically conductive. This made barely any difference at all. I reached for the glass and then I noticed that as my hand got closer to the glass, the readings increased. The glass of water had simply become an extension of the capacitive sensor.

So, practically speaking, what does this mean? It means that, as it is currently designed, this moisture sensor is definitely not going to work properly with potted plants without adding an (insulated) grounding rod. While this thing works great as a touch sensor, I'm not making a touch sensor. The moisture sensor might possibly work outside (due to the large capacity of the earth), but I'm thinking that the readings might not be very accurate or precise.

As a result of this observation, I've re-designed the sensor to once again have both sensing and ground planes, like the original prototype. Both will be insulated. This should allow the device to work with both potted plants and outside.

Another observation I made was something that I missed in earlier readings of the ATTiny13 datasheet: the 'high' threshold voltage for an I/O pin is a measly 0.6-0.7 volts. This is a far cry from the VCC/2 I was hoping for, and would explain why my readings were always so low. VCC/2 would have made the readings somewhat voltage independent, but since the actual threshold voltage is independent of VCC that means that I have a few options:

  1. Use the ATTiny13's built-in comparator to compare the voltage in the storage capacitor to VCC/2. This would mean that I would need to use one more I/O pin for VCC/2, adding two parts to the BOM.
  2. Add a 3 volt zener diode to the circuit, theoretically keeping the readings consistent as long as VCC is larger than 3.3 volts, adding one more part to the BOM.
  3. Measure VCC using the integrated ADC and compensate for the difference in software. I don't think there is currently enough room in flash to add this without switching to the ATTiny25, but aside from that it involves zero additional parts.

I'm not sure which approach to take yet, but I'm leaning toward #3 because it is flexible and won't increase the part count.

I think I'll be switching from the ATTiny13 to the ATTiny25, as the later has an integrated temperature sensor. I'm anticipating that I'll need to compensate for how temperature will affect the capacitive readings, so this will help avoid the need of adding additional components. Also, the ATTiny25 has double the code space of the ATTiny13, which will come in handy considering that my current code just barely fits into the 1k of flash that the ATTiny13 has.

The wire protocol for the moisture sensor is inspired by (and currently compatible with) Maxim's 1-wire protocol, allowing the devices to be easily strung together on the same bus. However, the 1-wire protocol patented, so I may need to create an alternate ad-hoc protocol which is incompatible with and distinct from 1-wire to avoid any legal problems.

Anyway, that's the current state of things. Do you have any ideas or suggestions regarding these sensors? I'd love to hear your comments!