Skip to content

[Example] Touché swept frequency capacitive sensing

David A. Mellis edited this page Aug 2, 2016 · 6 revisions

Overview

This example uses swept-frequency capacitive sensing to identify how someone is grasping an object or touching a surface. It's a version of the Touché project by Ivan Poupyrev et al. We're using an Arduino circuit by DZL and started from code by Mads Hobye.

Circuit

We're using the following circuit. The labeling of the Arduino pins is a little confusing. The 10K resistor at the top is connected to digital pin 9 of the Arduino (labeled as pin 22 in the diagram); the 1M resistor is connected to analog input pin 0 (A0) (pin 7 in the diagram).

Touché circuit.

Components: 100 pF capacitor, 10 nF (10,000 pF) capacitor, 10 mH inductor, 1N4148 diode, 10K resistor, 3.3K resistor, 1M resistor.

Arduino Code

Input Only

We've modified Mads's code to create an Arduino example that generates different frequencies on pin 9 and, for each, measures the capacitive on analog input 0. These are sent over serial to ESP.

Download: https://raw.githubusercontent.com/damellis/ESP/master/Arduino/Touche/Touche.ino

Input and Output

We've also made a version that receives predictions from ESP and turns on an LED that correspond to the prediction. To use, connect LEDs to pins 2, 3, and 4.

Download: https://raw.githubusercontent.com/damellis/ESP/master/Arduino/Touche_LEDs/Touche_LEDs.ino

ESP Example

We're using the user_touche.cpp example in the ESP download. For the moment, there's no pre-compiled binary for this example, so you'll need to compile ESP from source. See the installation instructions.

Usage

This example looks for different configurations of capacitance. Remember capacitance is created by proximity between two conductive surfaces or objects. So you might alligator clip to a conductive object like a metal tray, the water in some container, a plant, a banana, etc. (The alligator clip goes one of the legs of the 10 nF capacitor to the object, as shown in the circuit diagram above.) Then, depending on how you touch the object, the detected capacitance will change, allowing ESP to recognize the different touches or grasps. Specifically, this system is good at detecting how much close contact there is between you and the object, e.g. distinguishing a one finger touch from a full hand grasp. You can also connect use one of your hands as the touch-sensitive object, and then detect how it touches your other hand.

If you use a highly conductive object like metal, you may want to add a thin insulating layer between the object and your hands. For less conductive objects like water or organic material, you should be able to touch the objects directly.

See the Touché paper (PDF) for more details on potential applications.