Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
[Example] Touché swept frequency capacitive sensing
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.
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).
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.
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.
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. Be sure to uncomment the
#include "examples/user_touche.cpp" line in user.cpp (and comment out any other #included example).
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.