Banana, Spoon or Houseplant? Weird Things That Work as ESP32 Touch Buttons
The ESP32's touch pins are not fussy about what you connect them to. They are looking for a change in capacitance, which is a fancy way of saying "something that can hold a little charge, and that changes when your body gets close". Conductive fabric is my favourite, but plenty of things around your house can work too. Here are some to try on a quiet afternoon.
The setup
Clip one end of an alligator clip jumper to the object and plug the other end into a touch pin. GPIO 4 (T0) on a classic ESP32 is a good start. Then upload this as src/main.cpp and open the serial monitor:
#include <Arduino.h>
const int TOUCH_PIN = 4; // T0
void setup() {
Serial.begin(115200);
}
void loop() {
Serial.println(touchRead(TOUCH_PIN));
delay(100);
}
Watch the number with nothing touching the object, then touch it. On the original ESP32 the number drops when you touch. A big, clear change means you have a good button. (On S2 and S3 boards the number goes up instead.)
Things to try
1. A banana, or any fruit
Fruit is mostly water with a bit of salt and sugar, which makes it a surprisingly good touch pad. Line up four pieces of fruit on four touch pins and you have a fruit piano. Add a buzzer and you have a very silly instrument.
2. A metal spoon
Metal cutlery usually gives a big, reliable reading. Try a fork, a key or a coin while you are at it, and see which gives the biggest jump.
3. Kitchen foil
Fold foil into any shape: a star, a letter, a moon. Tape it to card and you have a flat button. Now for the fun part: put a sheet of paper over the foil and touch the paper. It often still works, because capacitive sensing can work through thin non-conductive layers. That is the idea behind hidden buttons in clothing.
4. A pencil drawing
Graphite conducts. Shade a thick, dark patch with a soft pencil (6B or softer), clip onto the edge, and touch your drawing. Results depend on how heavily you shade, which is half the fun.
5. A glass of water
Drop the end of a wire into a glass of water, keeping the clip and the board well away and dry. Dip a finger in and watch the reading. Then add a pinch of salt and compare.
6. A houseplant
Push a wire into the soil near the stem. Some plants give a clear change when you touch a leaf, and some barely respond. Be kind to the plant.
7. Conductive fabric (the one I always come back to)
Soft, cuttable into any shape, and sewable. It is the one you can actually wear. My latest video and the soft touch button tutorial show how to turn a small square into a proper button.
Things that will not work
Plastic, dry wood, rubber and glass on their own will not give you a useful reading, because they do not conduct. Which is exactly why we use them to insulate things.
A few ground rules
- Only use USB power from your computer or a small battery. Never connect anything to mains power.
- Keep the board and connections dry. The water goes in the glass, not near the board.
- Long wires act like antennas and make readings jumpy, so keep them short.
- If a reading is noisy, average several readings or tune your threshold, as in the tutorial.
Your turn
What is the strangest thing you can turn into a button? I would love to see it. Bring it to the Wednesday Workbench live stream, or tag CMozMaker so I can find it.
Starter bits if you need them: an ESP32 Development Board 30-Pin (USB-C), some alligator clip to jumper wires, and a bag of conductive fabric off-cuts for when you are ready to make it wearable.
Christine