I’ve been using capacitive touch sensors in a number of my projects recently and just wanted to share a really quick and easy way to build one for yourself that works with Arduinos.
You’ll need:
- Tin foil
- An arduino capable development board (https://amzn.to/2BUbDRU)
- 10k Ohm (1k – 1M all work) (https://amzn.to/2Rn4wLU)
- Bread board and leads (https://amzn.to/2GXfO5A)
- Soldering Iron & Solder (https://amzn.to/2C2u6Mz)
Start by soldering a lead to a small piece of tin foil. Additional flux seemed to really help this process.
Connect the resistor to a digital out pin (I used D0 on my Wemos D1 Mini) and the breadboard.
On the same row of the breadboard connect both the sensor (tin foil lead) and a Digital In pin (I used D1).
That’s it. Now just upload the following sketch, making sure to identify the correct GPIO pins in the code.
// touch sensor
#include <CapacitiveSensor.h>
// touch sensor config
CapacitiveSensor capSensor1 = CapacitiveSensor(D0, D1);
void setup() {
Serial.begin(115200);
}
void loop() {
long sensorValue1 = capSensor1.capacitiveSensor(30);
Serial.println(sensorValue1);
delay(500);
}
The CapacitiveSensor library is available in the Library Manager and is the one by Paul Bagder and Paul Stoffregen.
Here’s a video of the project. Have fun, and happy hacking!