RC time constant calculator
Resistor and capacitor in → τ, time to reach a voltage and the low-pass corner. Plus the capacitor a debounced push-button needs.
Time constant
| After | Time | Charged | V charging | V discharging |
|---|---|---|---|---|
| 1 τ | 1 ms | 63.2 % | 2.09 V | 1.21 V |
| 2 τ | 2 ms | 86.5 % | 2.85 V | 0.45 V |
| 3 τ | 3 ms | 95.0 % | 3.14 V | 0.16 V |
| 4 τ | 4 ms | 98.2 % | 3.24 V | 0.06 V |
| 5 τ | 5 ms | 99.3 % | 3.28 V | 0.02 V |
Button debounce RC
Pull-up R from the pin to VCC, capacitor from the pin to GND, button across the capacitor (through 100–470 Ω to limit the discharge spike).
Slow edge, no guaranteed hysteresis. The classic ESP32 datasheet gives no input hysteresis figure, so a slow RC edge on an interrupt pin can still fire more than once. Put a 74HC14 Schmitt inverter after the RC, or keep a short software debounce as well.
Schmitt inputs built in. The ATmega328P's digital inputs have Schmitt triggers, so the slow RC edge switches cleanly once.
Schmitt on by default. RP2040 GPIO pads have the Schmitt trigger enabled after reset, so the RC edge switches cleanly.
The 74HC14 inverts. Your pin reads HIGH while the button is pressed. Power it from the same 3.3 V or 5 V as the board.
How it works
τ = R × C charging: V(t) = Vs(1 − e−t/τ) discharging: V(t) = V0·e−t/τtime to reach V: t = −τ·ln(1 − V/Vs) fc = 1 ÷ (2π·R·C)10 kΩ × 100 nF = 1 ms. After 1 τ a charging capacitor is at 63.2 % of the supply, after 3 τ at 95 %, after 5 τ at 99.3 %. The same pair is a low-pass filter with its −3 dB corner at fc — 159 Hz here, handy for smoothing a PWM or a noisy ADC input.
Sizing a debounce capacitor
When the button closes it empties the capacitor. While the contacts bounce open, the capacitor refills through the pull-up — and the pin must not climb past its HIGH threshold VIH before the bouncing stops:
C ≥ tbounce ÷ (R × −ln(1 − VIH/VCC))Most tactile switches settle within 5–10 ms; cheap or worn ones can bounce for 20 ms. The tool rounds the capacitor up to the next E6 value (1.0, 1.5, 2.2, 3.3, 4.7, 6.8) — ceramic capacitors drift ±10–20 %, so a little margin helps.
FAQ
How long does a capacitor take to charge fully?
About 5 time constants (5 × R × C) gets it to 99.3 % of the supply, which is "fully charged" for practical purposes. After 1 τ it is at 63.2 %.
Can I use the ESP32 internal pull-up for an RC debounce?
Yes, but it is roughly 45 kΩ and varies a lot between chips, so the delay is only approximate. An external 10 kΩ pull-up gives a predictable time; size the capacitor for it here.
Hardware or software debounce?
Software debounce (ignore changes for 20–50 ms) is free and fine for most buttons polled in loop(). Use an RC when the button drives an interrupt or wakes the board from deep sleep, where every bounce would fire the handler.