You are on page 1of 2

learn design share

Capacitive Liquid Detection


With the help of Arduino
By Paul Cordonnier (Belgium)

Some time ago, Elektor published my siphonic rain gauge with no moving parts, in which the water
that passes when a little siphon empties is detected by short-circuiting two electrodes [2]. At the same
moment, articles were in preparation showing that capacitive detection would have a decisive impact [3].
Here I investigate if the “approaches” can be joined.

+5V +5V
1 K1
2
3
2
16 15 14 13 12 11 10 9
C1 1
ON
S1
100n

1 2 3 4 5 6 7 8
IC1 16
1 2 3 4 5 6 7 8

CTR14 7
R1 3
5
100k 4
K2 11 !G 4
R2 RCX 5
2 10 + 6
10k RX 6
1 9 14
CX 7
CT 13
8
15
9
1
11
A 12 2
CT=0 12
3
13
B
8
74HC4060
140130 - 11

The idea of a technical bridge between the above publications of code later, and the die was cast! And the right-hand corner of
only appeared in the comments posted on the Elektor Labs my forehead is a little flatter than before.
website. That was where I read the remark from a reader (I
later learnt it wasn’t just any reader) suggesting the capaci- I hope like me you’ll learn this lesson of the rain gauge: instead
tive approach [4] for detecting the water passing through the of falling flat on your face all alone with some stubborn idea,
pluviometer drain instead of a short-circuit on the electrodes. take a few minutes to talk about it on Elektor Labs website.
Then I recalled that a few years earlier I had myself success-
fully built a capacitive-detection water level monitor using a There’s water in the “condenser”
Basic Stamp. Why didn’t I think of this idea for the rain gauge? The type 4060 logic counter/divider (Figure 1) is cheerfully
The sparks of creativity are capricious and don’t just pop up open to the world: its three pins RCX, RX, and CX are acces-
to order. Whence the interest of working on ideas together. As sible from outside, and that’s exactly where we connect the
it happens, my neighbor and the author of the comment was capacitor made from the two pieces of copper foil stuck on
none other than David Ardouin, whose recent articles testify the walls of the pipe to be monitored. The capacitance of this
to the capabilities of capacitive. assembly will not be the same, depending on whether there is
water in the pipe or not. So with that, the oscillator frequency
I tested the idea successfully with the help of two small pieces will change too. To find out what is flowing or not in the pipe,
of self-adhesive copper foil (which you can find from Farnell, in all we have to do is measure the length of the pulses at the
particular) stuck opposite one another on the flexible tube. The counter/divider output. Do I need to point out that this will
advantage of this ultra-simple process, which can be applied work with rubber or silicone, but not with metal pipes?
in other fields for detecting the presence or absence of liquids
within pipes, is to eliminate drilling through the wall to insert The oscillator signal is not used as is for discrimination, but
the electrodes, as I had done for the rain gauge. No Stamp its frequency is first reduced using the divider in the 4060.
this time, I used an Arduino: a little “pulseIn” and a few lines The 8-way DIP switch lets us pick off one of the division fre-

108 November & December 2016 www.elektormagazine.com


labs project reader’s project

quencies available. Note: only turn one of S1’s eight switches


on at a time. This squarewave, applied via K1 to an Arduino, Component List
will be “analyzed” using a little detector evaluation program Resistors (0.25W)
(Listing 1). R2 = 10kΩ
R1 = 100kΩ
The “cleanness” of the information obtained will depend on the
construction of the detector, which affects the discrimination Capacitors
between the two extreme states (presence or absence of liq- C1 = 100nF
uid). The absolute values are trivial, the only thing that counts
Semiconductors
is the detection threshold mid-way between them. IC1 = 74HC4060N
By way of an example, on the Elektor Labs prototype, using
a 1 nF capacitor in place of the detector, the frequency noted Miscellaneous
K1 = 3-pin pinheader
on Q7 (pin 6 of IC1) was of the order of 2.5 kHz.
K2 = 2-way PCB screw terminal, 0.2’’ pitch
Using the detector in the photo (Figure 2) — the pipe is 6 mm S1 = 8-way DIP switch block
OD and 4 mm ID, and the two self-adhesive copper strips are PCB # 140130-1 v1.0
around 20 × 7 mm — the difference in frequency obtained
was of the order of 1.5%. It’s not much — but for a micro-
controller, it’s doable.
Listing 1.
Longer strips ought to make it possible to increase the sensi- int freqPin = 7; // probe input
tivity. On my own prototype, tested using water and diesel, at int beepPin = 6; // buzzer
appreciably lower frequencies, I obtained a clearer distinction
unsigned long duration;
(nearly 10%). The frequency with no water of 166 Hz gave
pulseIn = 3128, while 151 Hz with water gave pulseIn = 3229.
void setup()
I adopted 3178 as the switching point.
To be quite honest, here we’re only at the experimental stage; {
it’s going to be necessary not only to refine this measurement, Serial.begin(9600);
but also to carry out periodic calibration of the detector to pinMode(freqPin, INPUT);
compensate for likely drifts. Nonetheless, the project seemed pinMode(beepPin, OUTPUT);
serious enough for us to offer a PCB layout, the EAGLE format }
files for which can be downloaded [6].
Now it’s your turn now to tell us [1] about your own exper- void loop()
iments. {
(140130)
duration = pulseIn(freqPin, HIGH);
Web Links Serial.println(duration);

[1] www.elektormagazine.com/labs

// delay(1000);
[2] Siphonic Rain Gauge: www.elektormagazine.com/120554
if (duration > 3200)
[3] Touch-2-Switch, multi-purpose wall-mounting switch:
{
www.elektormagazine.com/130272
tone(beepPin, 600, 100);
[4]  http://goo.gl/TcCE94
}
[5] Pattern Lock: www.elektormagazine.com/120579
[6] www.elektormagazine.com/140130 }

Advertisement

T choice is yours.
The
• Enclosure for all round
protection
Housings for Raspberry • Platform for all round
Pi, Arduino and many access
other bareboard • Design-specific versions
computers for all popular models
• Enclosure • Visit hammondmfg.com
• Platform for full details
+ 44 1256 812812
sales@hammondmfg.eu /1593HAM.htm /1593HAMEGG.htm
/15
593HAMEGG.htm
593HAMEGG.htm
HA
AMEGG ht

www.elektormagazine.com November & December 2016 109

You might also like