To build a reliable voltage RC circuit for smoothing a 5V microcontroller PWM signal into a steady DC voltage, use a 3.3 kΩ resistor and a 100 nF X7R ceramic capacitor. This specific pairing yields a 482 Hz cutoff frequency and a 330 µs time constant, effectively stripping 5 kHz switching ripple while allowing the output to settle to a new target voltage in under 1.5 ms. Below is the complete design framework, failure analysis, and testing protocol to implement this on the bench.
The Core Topology: Nodes, Components, and Voltage Behavior
The standard low-pass voltage RC circuit relies on a series resistor and a parallel capacitor to ground. The topology is defined by three primary nodes:
- Vin (Input Node): The raw switching signal (e.g., 5V PWM from an ESP32 GPIO).
- Vout (Output Node / Node_A): The junction between the resistor and capacitor. This is where the smoothed DC voltage is measured.
- GND (Reference Node): The common ground shared by the microcontroller, the capacitor, and the measuring equipment.
When a high-frequency voltage is applied at Vin, the resistor limits the instantaneous current flow, while the capacitor integrates the charge over time. The voltage at Vout cannot change instantaneously; it follows an exponential curve dictated by the time constant (τ = R × C). For a PWM signal, if the RC time constant is significantly longer than the PWM period, the capacitor voltage averages out the pulses into a proportional DC level.
Why a Passive Voltage RC Circuit Over LC or Active Alternatives?
Makers often debate whether to use a simple RC filter, an LC (inductor-capacitor) filter, or an active op-amp filter. Here is why the passive RC topology wins for general-purpose microcontroller DAC and timing tasks.
| Criterion | Passive RC Filter | Passive LC Filter | Active Op-Amp Filter |
|---|---|---|---|
| Component Cost | < $0.05 | $0.20 - $1.50 | $0.50 - $3.00 |
| Resonance Risk | None (overdamped) | High (can ring/overshoot) | Low (depends on design) |
| Output Impedance | High (equals R) | Low (DC resistance of coil) | Very Low (op-amp output) |
| Power Requirement | None | None | Requires VCC/VEE rails |
The Verdict: Choose the voltage RC circuit when your load is high-impedance (like an ADC input or a MOSFET gate) and you need a cheap, stable, non-resonant solution. Choose an LC or active filter only if you need to drive a low-impedance load (like a motor or speaker) where the RC resistor would cause an unacceptable voltage drop.
Behavior Matrix: How Component Shifts Alter the Output
Understanding how component tolerances and value changes affect the circuit is critical for debugging. Here is what happens when you deviate from the baseline design.
| Change | Effect on Cutoff Frequency (fc) | Effect on Ripple Voltage | Effect on Step Settling Time |
|---|---|---|---|
| Increase R | Decreases | Decreases (smoother DC) | Increases (slower response) |
| Decrease R | Increases | Increases (more ripple) | Decreases (faster response) |
| Increase C | Decreases | Decreases (smoother DC) | Increases (slower response) |
| Decrease C | Increases | Increases (more ripple) | Decreases (faster response) |
Design Walkthrough: Smoothing ESP32 5kHz PWM into Steady DC
Let's calculate the exact values for smoothing a 5 kHz, 0-5V PWM signal from an ESP32 into a clean 0-5V analog control voltage.
1. Define the Target Cutoff Frequency (fc)
A good rule of thumb for PWM smoothing is to set the cutoff frequency to 1/10th of the PWM frequency. This provides -20dB of attenuation at the fundamental switching frequency.
Target fc = 5,000 Hz / 10 = 500 Hz.
2. Select the Capacitor (C)
We need a capacitor large enough to hold charge between PWM pulses, but small enough to fit on a breadboard and respond quickly to duty cycle changes. A standard 100 nF (0.1 µF) X7R ceramic capacitor is the ideal starting point. It has low equivalent series resistance (ESR) and is universally available in 0603 or through-hole packages.
3. Calculate the Resistor (R)
Using the standard low-pass filter formula from All About Circuits:
R = 1 / (2 × π × fc × C)
R = 1 / (2 × 3.14159 × 500 × 0.0000001)
R = 3,183 Ω
4. Pick the Standard Value and Verify
The closest standard E24 resistor value is 3.3 kΩ. Let's recalculate the actual cutoff frequency and time constant with this real-world part:
- Actual fc: 1 / (2 × π × 3300 × 0.0000001) = 482 Hz (Perfectly acceptable).
- Time Constant (τ): R × C = 3300 × 0.0000001 = 330 µs.
- Settling Time: A capacitor reaches ~99.3% of its final voltage in 5τ. 5 × 330 µs = 1.65 ms. If you change the PWM duty cycle, the output voltage will settle to the new level in under 2 milliseconds.
Failure Modes: What Breaks at the Extremes?
When troubleshooting a dead or noisy voltage RC circuit, you must understand how the topology behaves when a component fails open or short. This failure-mode contrast is what separates theoretical knowledge from bench competence.
- Resistor Shorts (R = 0Ω): Vout becomes directly tied to Vin. The filtering action is completely lost. You will see the raw 5 kHz PWM square wave on your oscilloscope. Risk: If the capacitor subsequently shorts, the microcontroller GPIO will source maximum current, potentially frying the pin.
- Resistor Opens (R = ∞): The charging path is broken. Vout will float or remain stuck at whatever voltage was last trapped on the capacitor. Leakage currents will eventually pull it to an unpredictable state.
- Capacitor Shorts (C = 0Ω): Vout is pulled directly to GND (0V). The output is dead. Safety Note: With our 3.3 kΩ design, a shorted cap only draws 1.5 mA from the ESP32 (5V / 3300Ω), which is well below the 40 mA absolute maximum rating. If you had designed this with a 100 Ω resistor, a shorted cap would draw 50 mA and destroy the GPIO.
- Capacitor Opens (C = ∞): The integration element is gone. The circuit acts as a simple wire (minus the 3.3 kΩ series resistance). Vout will mirror Vin, passing the high-frequency ripple directly to the load.
Step-by-Step Breadboard Verification
Do not trust SPICE simulations blindly; parasitic breadboard capacitance and component tolerances alter real-world behavior. Follow this verification protocol using an oscilloscope.
- Wire the Topology: Insert the 3.3 kΩ resistor into the breadboard. Connect one leg to the ESP32 PWM output (Vin). Connect the 100 nF capacitor between the other leg of the resistor (Vout) and the common ground rail.
- Verify DC Baseline: Set the ESP32 PWM duty cycle to 0%. Measure Vout with a multimeter. It should read < 0.05V. Set duty cycle to 100%. It should read ~4.95V (accounting for the tiny voltage drop across the resistor due to multimeter input impedance).
- Measure Ripple (AC Coupling): Connect the oscilloscope probe to Vout. Set the scope channel to AC Coupling and adjust the vertical scale to 50 mV/div. Set the PWM to 50% duty cycle. You should see a sawtooth ripple waveform. With our 3.3k/100nF values, the peak-to-peak ripple should be under 40 mV.
- Measure Step Response: Switch the scope back to DC Coupling (2V/div). Program the ESP32 to toggle the PWM duty cycle between 10% and 90% once per second. Trigger the scope on the rising edge. Verify that the exponential curve reaches the 90% target voltage within 1.65 ms (the 5τ mark).
Decision Tree: Finalizing Your Component Pick
Use this decision matrix to lock in your final component values based on your specific project constraints. For further reading on filter phase shifts and impedance matching, refer to the Electronics Tutorials low-pass filter guide.
| Project Constraint | If True... | Then Pick... |
|---|---|---|
| Load draws > 5 mA of continuous current | The 3.3k resistor will cause a massive voltage drop (V = IR). | Abandon RC. Use an LC filter or an op-amp voltage follower. |
| Settling time must be < 100 µs (fast response) | 330 µs is too slow for your control loop. | Drop R to 1 kΩ and C to 33 nF. (fc = 4.8 kHz, τ = 33 µs). |
| Ripple must be absolutely minimal (< 5 mV) | First-order RC roll-off (-20dB/decade) isn't steep enough. | Use a two-stage RC filter (e.g., two 1.6k resistors and two 100nF caps in series) or an active Sallen-Key topology. |
| General-purpose DAC / LED dimming / Motor speed reference | Standard maker use-case; high impedance load, moderate speed. | Default Pick: 3.3 kΩ Resistor (1%) + 100 nF X7R Capacitor. |
For 90% of hobbyist and prototyping tasks involving microcontroller PWM smoothing, GPIO debouncing, or simple analog timing delays, the 3.3 kΩ / 100 nF voltage RC circuit is the definitive starting point. It balances component availability, GPIO safety, and predictable time-domain behavior without requiring complex impedance matching or external power rails.






