A typical 12V resistance touch sensor driving a 12V relay
A few days ago, i uploaded a theory page explaining how the touch sensors work. I presented different ways of touch sensing techniques, and i promised that i will post a circuit with many variations for each method. Well, here i begin with the first method, the resistance touch sensor.
Resistance Touch Momentary Button circuit
Here is the very simple and reliable resistance touch sensor schematic:
R1 is a simple protective resistor. On pins E1 and E2, the two electrodes are connected to perform the touch plates. T1 is a transistor amplifier. I choose to use a darlington pair transistor, because i want to have enough current amplification to drive loads such as a relay, even if your skin is completely dry. You could use a simple transistor as well if you plan to drive simple LEDs or other low current loads. The next transistor is a power switching transistor, able to deliver enough current for the relay. A capacitor is connected to its base, to eliminate bounces or other parasitic noise. It causes a slight ON-OFF delay, but it is extremely fast to notice.
The load is connected to pins L1 (positive) and L2 (ground). The current must be taken into account when connecting the load. 2N2222 can handle up to 800mA. Should you need more current, consider another transistor instead. R3 is a protective resistor for the T2. It should be selected according to the load.
With the electrodes touchesd
In case that you want to control high current loads, you can use a relay. In that case, R3 can be totally omitted:
Do not forget the flyback diode! The diode must be connected parallel to the relay's coil, with reverse polarity. I have test the circuit with 5 and 12 volts, and works with no component change. Make sure that the relay has the same voltage for the coil as your power supply.
The LEDs are switched through the 12v relay
Bill Of Materials
Resistor 330 Ohm 1/4 Watt 5% Carbon Film
Resistor 1 KOhm 1/4 Watt 5% Carbon Film
Selected according to your load
Ceramic Capacitor 0.1 uF 50 Volts
BC517 NPN Darlington Transistor
2N2222 Switching NPN Transistor
1N4004 General Purpose Diode Rectifier
Resistance Toggle Touch Switch circuit
Things are getting a little bit more stiffer here. The previous circuits act as pushbuttons. As long as the two electrodes are touched, the load is actuated. When released, the load is deactivated. To make a toggle switch, i added a D-Flip Flop, more specifically i added the CD4013 CMOS chip that i had in stock. It has two Flip-Flop modules. I will use one of them as an one-shot debouncer, and the other will be connected as a toggle Flip-Flop to drive the output. Here is the schematic: (click to enlarge)
So, E1 and E2 are the two electrodes, then comes the darlington pair amplifier to sense the touch. The next transistor is to provide enough current to drive both the Set input of the Flip Flop (B), and to load the capacitor C2. This capacitor is a large electrolytic, and this is the one that will generate the one-shot delay. When it is charged, it will hold the Set input HIGH, even if the electrodes are not touched any more. It will then slowly discharge through the parallel large discharging resistor R5. Changing this capacitor will result into more (if more capacitance) or less (if less capacitance) time interval of the one-shot action.
The output of the first Flip-Flop is then driven to the second Flip-Flop, which is connected as a toggle switch. This is done by driving the S and R inputs LOW, and giving a negative feedback to the D input. On each pulse of the Clock input (which comes from the first F-F), the output state is changed.
Finally, we only have to add a large resistor and connect an output transistor to the F-F. This resistor must be big enough to kinda separate the transistor from the feedback of the F-F, but not that large, because the transistor may not provide enough current for the load. If you need more, add a second amplification stage. The final transistor can be of any type, but i used the 2N2222 to drive high-current loads like a relay. Similarly as before, in case that you drive a relay, the R8 can be totally omitted. The load is connected to pins L1 (+) and L2 (Gnd).
@Colin Mitchell An emitter follower connection is not "bad" as you said. It may not be proper for your application, your supply. Indeed a CE connection could be more adaptive though. If you do not know how to change the connection, i can send you details.
I gave a shot at building the first circuit.
However, I didn't have the right transistor but tried anyway with 3x 2n2222. With these part the led was alway on, and touching the led only made it brighter.
Anyway, I solved this behaviour: Instead of 2 transistors as a darlington, I used only one 2n2222 as T1 and R2= 330ohm.
anyone else had this problem too?
transistor used had HFE (gain) ~180
i was able to rebuild your schematic (the first one) with success. But unfortunately i was not able to adapt this to a circuit by replacing the BC517 with a Darlingto Array (tried ULN2001A and ULN2803A). I connected the two open cables via 220Ohm with Pin1(i.e. Input) and the LED via 1,1kOhm with Pin 16 (i.e. Output). Both resistors were connected to Vcc (5Volts). But I was struggled with the emittor. Is it Pin8 (GND) or Pin9 (COM) which I have to connect with GND. Right now I am lost as I don't understand what I am doing wrong.
Hi Giorgos, thank you very much for this cool introduction and presentation.
That is exactly what I've been looking for.
However one problem still remains:
I need 8 touch sensors like this, but would like to use a darlington array (e.g. ULN2803) Can someone explain how I should wire the first sensor to the darlington array? I understood that pin-9 is gnd and pin-1 is IN and pin-18 the corresponding OUT. However I do not know if I need some resistors to allow the input react on the current of the human body.
driven low will still mean current flows. The only way not to flow current is to let it float, which does not work for microcontroller inputs (as you saw). High and Low are same in digital electronics, with only difference that we talk about electron or hole movement. So, what you can do, is only decrease the current to minimum. Use a huge resistor as R3. How big? Well, you need to know the minimum current needed for the microcontroller. It is in its specifications. Usually a 22 Kohms resistor works, and can limit the current down to 0.2mA.
@Kammenos - thanks for the tip. It works great! However, my only concern is now the circuit is driving HIGH all the time. I want to keep this running all the time and was hoping to minimize power draw. Is it possible to make it drive LOW and then HIGH only when touched?
Hi Dave. I think that the problem is that when the electrode is not touched, the input is floating. I suggest that you convert it into an inverting amplifier (the T2 i mean). Here is how to do it. R3 must be 1K5 or 2K2. I would use a 2K2. Then, the emitter of T2 (the one that goes to L1) should be driven directly to ground (as if you bridge L1-L2). Then, you connect the analog input of arduino in between the collector of T2 and R3. Keep in mind that now, the output works different. You get HIGH when input is NOT touched, and LOW when is touched. Please inform me if it works.
Hi, glad I found this site. I am working on a DIY dimmable LED light for my desk and am using the Resistance Touch Momentary Button circuit you have above (the one without the 4013 that only turns the LED on when touched and off when not touched). I have the based of T2 (2n2222) going to an Arduino and reading it using AnalogRead(). However, I am having difficulties as it translates the voltage values into values between 0 and 1023. The problem is, if the circuit is powered and I dont touch the contacts, the values being returned seem to fluctuate and sometimes jump. For example, powering up - get the range of 470-480, but then for no reason, it will jump up to 530-540. This would be ok, as i can just set my Arduino to trigger at values above 550. However, the opposite is true as when I am triggering the dimming code, and my finger is on the contacts, it sometimes falls be low 550 (when most values are 680+).
Sorry for all the detail - my question is this - can I add something to the output of T1 (BC517) that will help smooth this, or only trigger a reading when the voltage is above a limit. Note- I measured the voltage and during non-touch operation, it is about 0.04V, when touched it is ~2.5V. Problem is, the Arduino does not seem to see it this way (because I think its AnalogRead function normalizes the values.
hmmmm, most unlikely. Do you have a darlington transistor for T1? If yes, what you can do is reduce R1 to 220 or 150 ohms. If still not working, add another darlington amplifier, but imo this is overkill. it should work with one darlington.