Jacket with touch music controls
Build it step by step
0 of 7 doneTest the MPR121 on the bench
Touch each pad.
Pair as a BLE keyboard
Check the media keys work.
Set the MT3608 to 5 V
Before connecting the ESP32.
Wire the charger and battery
Use a protected module.
Sew the patches
Spirals, no crossing threads.
Connect and test on the sleeve
Before you finish sewing.
Make the board removable
For washing.
How do you build a jacket with touch music controls?
Conductive thread patches on a jacket sleeve play, pause and skip music on your phone over BLE. You need ESP32 DevKit V1, MPR121 capacitive touch sensor, Li-Po battery 3.7 V 500 mAh, TP4056 module with protection (USB-C) and MT3608 Boost Module. It takes 7 steps and about 180 minutes.
- Level
- Intermediate
- Time
- About 180 min
- Parts
- 5
Parts list
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| MPR121 SDA and SCL | ESP32 GPIO21 and GPIO22 | I2C |
| MPR121 3V3 and GND | ESP32 3V3 and GND | Power |
| MPR121 electrodes 0 to 4 | Conductive thread patches on the sleeve | Play or pause, next, previous, volume up, volume down |
| LiPo | TP4056 B plus and B minus | Charging (use a module with battery protection) |
| TP4056 OUT plus and minus | MT3608 IN plus and minus | Battery to the boost converter |
| MT3608 OUT (set to 5.0 V first) | ESP32 VIN and GND | Power |
Code
A phone treats the ESP32 as a Bluetooth keyboard, and a keyboard can send media keys, so touching a patch is the same as pressing play or next on a keyboard. The five patches sewn with conductive thread on the sleeve are read by the MPR121, which senses the change in capacitance when a finger touches. Sew each patch as a flat spiral, keep the threads from crossing or touching, and cover the loose ends with insulation. The board, charger and battery go in a small pocket, away from sweat, with a way to unplug the board before washing. Power: the ESP32 board needs 5 V, so the LiPo goes through a charger with protection and a boost converter that you set to exactly 5.0 V with a meter first. Never connect a LiPo straight to the ESP32's 5 V or 3.3 V pins. LiPo safety for a wearable: protect the cell from bending, crushing, sweat and heat, charge it away from the jacket, and stop using any cell that swells. In the Bluetooth settings of the phone, pair with the name Jacket Remote. Arduino IDE with the ESP32 boards package 2.0.x, board "ESP32 Dev Module".
Runs on a virtual ESP32 Dev Module in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
// Touch media remote: five capacitive patches act as play or pause, next, previous, volume up and volume down over BLE.
// Libraries: HijelHID_BLEKeyboard, Adafruit MPR121. Board: ESP32. Pair it on the phone like a Bluetooth keyboard.
#include <Wire.h>
#include <Adafruit_MPR121.h>
#include <HijelHID_BLEKeyboard.h>
Adafruit_MPR121 cap;
HijelHID_BLEKeyboard keyboard("Jacket Remote", "ElectroLark", 100);
uint16_t last = 0;
void setup() {
Wire.begin();
cap.begin(0x5A);
keyboard.begin();
}
void loop() {
uint16_t now = cap.touched() & 0x1F;
uint16_t pressed = now & ~last; // newly touched this time round
if (keyboard.isConnected() && pressed) {
if (pressed & 0x01) keyboard.tap(MEDIA_PLAY_PAUSE);
if (pressed & 0x02) keyboard.tap(MEDIA_NEXT_TRACK);
if (pressed & 0x04) keyboard.tap(MEDIA_PREV_TRACK);
if (pressed & 0x08) keyboard.tap(MEDIA_VOLUME_UP);
if (pressed & 0x10) keyboard.tap(MEDIA_VOLUME_DOWN);
}
last = now;
delay(30);
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Pair the phone | Appears as Jacket Remote |
| Touch patch 1 | Music plays or pauses |
| Touch patch 2 | Next track |
| Touch the volume patches | Volume changes |
If it does not work
Phone cannot find it
Forget old pairings and restart the ESP32.
False touches
Keep the threads apart and use shorter leads.
Board resets
Check the boost converter output and battery.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the jacket with touch music controls?
ESP32 DevKit V1, MPR121 capacitive touch sensor, Li-Po battery 3.7 V 500 mAh, TP4056 module with protection (USB-C) and MT3608 Boost Module.
How long does the jacket with touch music controls take to build?
About 180 minutes for a intermediate maker, in 7 steps.
How do I know the jacket with touch music controls works?
Pair the phone: Appears as Jacket Remote. Touch patch 1: Music plays or pauses. Touch patch 2: Next track.
Phone cannot find it: what should I check?
Forget old pairings and restart the ESP32.
False touches: what should I check?
Keep the threads apart and use shorter leads.
Board resets: what should I check?
Check the boost converter output and battery.
