The assignment for this week was to measure something—add a sensor to a microcontroller board that I had designed and read it.
I reused my custom Week 6 ESP32-S3 board and turned it into an input device by using its copper pads as capacitive touch sensors.
The pads TOUCH_PLAY and TOUCH_VOL are connected to pins D9 and D10 of the XIAO ESP32S3, which map to GPIO 8 (TOUCH8) and GPIO 9 (TOUCH9)—both capacitive-sensing capable pins.
The process began with cleaning and reinstalling the Arduino IDE, adding the ESP32 board support package from Espressif, and selecting the correct board configuration:
After initially using the wrong board definition (“ESP32 Family Device”), I reinstalled the correct Espressif Systems ESP32 core. That unlocked the missing “USB CDC On Boot” option and fixed the upload and Serial Monitor issues.
I verified communication with the board using a simple Serial “heartbeat” sketch:
void setup() {
Serial.begin(115200);
delay(1000);
while (!Serial) { delay(10); }
Serial.println("Hello Carlotta ✨ The ESP32S3 is alive!");
}
void loop() {
Serial.println("Still alive...");
delay(1000);
}
After enabling USB CDC on boot, the Serial Monitor displayed the message successfully.
With serial communication working, I programmed the board to measure capacitance on the two copper pads. The first attempt using GPIO 4 and 5 failed—touchRead() returned 4194303 (2²²−1), meaning invalid pins.
After checking the schematic and Seeed’s pinout, I corrected the mapping:
// XIAO ESP32S3 touch pads
const int touchPlayPin = 8; // D9 on XIAO, TOUCH8
const int touchVolPin = 9; // D10 on XIAO, TOUCH9
void setup() {
Serial.begin(115200);
delay(1000);
while (!Serial) { delay(10); }
Serial.println("Capacitive sensing on XIAO ESP32S3 🎨");
}
void loop() {
int valPlay = touchRead(touchPlayPin);
int valVol = touchRead(touchVolPin);
Serial.print("Play pad: ");
Serial.print(valPlay);
Serial.print("\tVolume pad: ");
Serial.println(valVol);
delay(200);
}
When untouched, values sit around 70–90. When a finger touches a pad, the reading drops to around 30–40.
4194303 is a great debugging clue—it means “invalid touch pin.”