Previous Articles »
« Recent Articles


Stuff about my projects
Synfig | Voria | darcness

Capacitance Sensing

Thursday, August 4, 2011 by darco

Update: After building out a few more boards and doing some additional testing, it seems as though things aren't quite as bad as I originally portrayed them in this post—the boards I made may still be usable as designed, albeit with a few quirks. However, I will be incorporating the design changes outlined below into the project for future devices to improve the consistency and performance.

After building out a few of the soil moisture sensor boards, I'm starting to think I may have been a bit hasty in ordering forty of them. The biggest problem I'm running into is noise. Lots of noise. Practically unfilterable noise, the nature of which is entirely dependent on material the sensor is embedded in. It is as if the sensing plane is acting like a large antenna, picking up all sorts of crap.

Some noise is actually a good thing, because it acts as a dither. allows me to super sample the capacitance and get a filtered result that is of a higher resolution than that of a single sample. Without any noise supersampling would not yield any better results.

But this kind of noise is on a whole different level. About the only thing these sensors (as currently designed) are good for at the moment is as a touch sensor... Which happens to be exactly what the capacitive circuit I borrowed from the QTouch guidelines was originally intended for.


QTouch capacitive sensing channel schematic from the Atmel QTouch Library User Guide.

I am not an electrical engineer, so when the QTouch sensor design guide said on page 2-1 that the measurement circuit was capable of measuring capacitance down to a few femto-farads, I believed it—even though the circuit made no sense to me (See figure above). Initial testing seemed to indicate that the method did work to some degree, so I went with it. I now see that was a mistake; I should have trusted my instincts more.

This is not to say that my original capacitance sensing circuit (which simply discharged a capacitor thru a known resistance) was any better. Looking back at it, I think that it would likely be just as susceptible to noise as the QTouch design.

In order to keep moving forward with this project, I've come up with an entirely different circuit that should hopefully prove to be far less noisy than the previous methods:


New low-noise capacitive sensing circuit.

The circuit actually works in the way that I originally imagined how the QTouch sensing circuit would work. What we do is charge up the capacitor we want to measure using a pulse, and then wait a little bit for this charge to distribute to the holding capacitor. We calculate the capacitance of the target by counting the number of pulses it takes before the sensing pin goes high.

While we end up operating this circuit in close to the same way as the QTouch method, the results are interpreted a bit differently. For example with the previous capacitance measurement fewer pulses meant less capacitance and more pulses meant more capacitance. In this circuit however the opposite is true: fewer pulses means more capacitance, and more pulses means less.

There are three things I really like about this circuit:

  1. It effectively has a built-in low-pass filter, so it should be less prone to noise.
  2. It doesn't increase the part count.
  3. There are upper and lower bounds on the capacitance reading, whereas with the previous method there was no upper bound on the number of pulses required to measure a capacitance.

Unfortunately the resulting pulse count does not have a linear relationship with the actual capacitance. This means that some sort of compensation (via a look-up table or other methods) will have to be performed to get a linear output.

New sensor orientation

Since I'm going to be re-designing the board yet again, I might as well make a few more radical changes, right?

One of the problems with this sensor is the fact that the electrodes are not only parallel, but they are also co-linear to each other. Ideally a capacitor is made like a sandwich: two electrodes with a dielectric between them.

While the "ideal" case might not be such a good idea in this case, I think I may have come up with a compromise: have two circuit boards that slide together so that the electrodes are oriented 90° from each other. I took a Dremel to two of the boards to start to put together a prototype:


Dual-board moisture sensor prototype. Work in progress.

As an added bonus, this sensor should be significantly more sturdy than the previous single-board design, while being more sensitive. Of course, it could just not work at all. We'll see.

Read the rest of this entry »

Moisture Sensors Arrive

Wednesday, July 20, 2011 by darco

The circuit boards for my soil moisture sensors arrived yesterday. I ordered four panels with ten sensors each, for a total of forty sensors. I ended up receiving five panels—25% more than I ordered—at no additional cost.


I populated one sensor last night and put it thru a quick smoke test this morning. No smoke, and it seems to be working fine. Unfortunately I won't have time to populate any more until next week.

The carefully observant will notice that despite my previous claim that I had created the "final" layout weeks ago, the layout has indeed changed once again. It turned out the edge connector wasn't the best idea, so I've settled on a shrouded locking 3x2 right-angle header for the connector.

Strange Oscillations

Tuesday, July 5, 2011 by darco

I stuck one of my soil moisture sensors in a potted plant last Friday before I left for a weekend trip. It was working fantastically. I watched as the soil moisture reading increased as I added water to the plant—working exactly as expected. However, when I returned Monday evening, I noticed that the values were all over the place. I took some samples on 100ms intervals and plotted the results:


Oh my. It's oscillating with an amplitude of around 10% of the capacitance reading. Not only that, my readings are an order of magnitude larger than what I was getting on Friday—when if anything they should be smaller.

I'm wondering if the 60Hz mains frequency is somehow affecting my readings, which would imply that what I'm looking at is the alias of 60Hz sampled at whatever interval I'm polling sensor. The power company regularly adjusts the frequency by ±1Hz or so, which could explain why I didn't notice the ripple earlier (Slight changes in the mains frequency would yield large changes in the alias frequency). This doesn't explain the large increase in the reading, however.

I also noticed some interesting behavior back on Friday. Whenever I grasped the stem of the plant, it caused the moisture level to increase. This makes sense, now that I think about it, but the implications are that each soil moisture sensor may have to be individually calibrated for differences in soil type, amount of soil in potted plants, etc. Not ideal, but not a show-stopper either.

Obviously, still some kinks to work out.

I hope to have the wire protocol solidified this week, at which point I'll actually deploy a few of these things in the yard to see what kind of readings I get. Should be interesting.

Final Soil Moisture Sensor Design

Tuesday, June 28, 2011 by darco

I think this is the final re-design of the soil moisture sensor that I will be sending off to Gold Phoenix for panelization and a small production run.



Just seven parts: two capacitors, three resistors, one ATTiny25 and a circuit board. I switched over to largish surface-mount parts and an edge connector instead of a standard 3x2 header. This board will be able to temperature-compensate using the on-board temperature sensor on the ATTiny25. I've also increased the length of the sensor to nine inches. Here is the schematic:


By my calculations I should get back around twenty to thirty boards. Should be more than enough to cover the front and back lawns and the garden. Now to just work out how to wire them all up...

Soil Moisture Sensor Update

Friday, June 24, 2011 by darco

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.

Read the rest of this entry »

Updates and Musings

Sunday, February 27, 2011 by darco

Late last year I decided that I need to go ahead and get my workshop finished before I continued my work on my home automation network. Since that time I never seemed to find the proper time to get back to working on it. The longer I wait, the more difficult it will be to get back up to speed. I've got a lot of parts just waiting to be soldered up in the garage, but due to the recent construction work on the house, the garage (and, thus, my workshop area) is a total mess. Grr...

I'm looking forward to getting back to work on the home automation front. From what I can tell, there is still no CC2350 or ATmega128RFA support natively in Contiki, so it sounds like I may have to do the heavy-lifting myself after all.

Smart Switch

Monday, February 7, 2011 by darco

I've been working on the design of my Smart Switch almost a year now, and the other day I finally received my first set of circuit boards for making my first prototype. I'm not finished populating them, but I figured I would go ahead and show it off anyway.


The board in the upper right is the power and communications module. The board in the lower right is the load module, which in this case is a simple relay.

The board on the right is the touch sensor board. This board will eventually have a small piece of white-backed frosted glass glued to the white outline on the front of the board. This is what the user will touch to control the switch.

The board in the middle is the main board. It contains the microcontroller which controls almost all of the functions of the switch.

SmartSwitchPics/DSC_8266 SmartSwitchPics/DSC_8269

All of the other circuit boards plug into the main board like this:


Read the rest of this entry »

Late Blast-from-the-Past Link Day

Tuesday, January 25, 2011 by darco

Last week, Shawn Blanc started a trend called Blast from the Past Link Day. That was on the 20th, so I'm pretty late to the game on this one. Nonetheless, it seems like the perfect excuse to make a post while I bide my time waiting for more circuit boards from BatchPCB.

Here are a few of my favorite posts from deep darc, in chronological order:

Here are some posts related to projects that I am proud of:

Previous Articles »
« Recent Articles