ARTICLE AD BOX
I am a beginner working with an ESP32-C3 Supermini. I recently learned that this specific model lacks native capacitive touch pins, so I am trying to implement a manual RC (Resistor-Capacitor) sensing method as a workaround.
I want to make sure my hardware setup won't damage the MCU and that my logic is correct.
Send Pin (GPIO 1): Toggles HIGH/LOW to charge the circuit.
Receive Pin (GPIO 2): Measures the time to reach the logic threshold.
Resistor: 10 MΩ between GPIO 1 and GPIO 2.
Electrode: A 16 cm2 aluminum plate covered with thin insulating tape.
Safety concern: I do not have TVS diodes. I'm worried about static electricity (ESD) from the plate hitting the GPIO.
My questions are:
Is the 10 MΩ resistor enough to protect the ESP32-C3 from ESD when someone touches the insulated plate? Should I add a small resistor (e.g., 1 kΩ) in series with the electrode?
Is 10 MΩ too high? I've seen some projects use 3-5 MΩ, but I'm not sure how it affects sensitivity with a 16 cm2 plate.
Is micros() precise enough for this, or should I use a simple while loop with a counter variable to get better resolution?
#define SEND_PIN 1 #define RECEIVE_PIN 2 uint32_t readTouch() { //Dicharge pinMode(RECEIVE_PIN, OUTPUT); digitalWrite(SEND_PIN, LOW); digitalWrite(RECEIVE_PIN, LOW); delayMicroseconds(10); pinMode(RECEIVE_PIN, INPUT); uint32_t startTime = micros(); //Charge digitalWrite(SEND_PIN, HIGH); //Wait for touch while (digitalRead(RECEIVE_PIN) == LOW) { if (micros() - startTime > 3000) break; // Safety timeout } return micros() - startTime; }