A simple nRF52840-based learning project for measuring capacitor values using RC timing, SAADC measurements, and a hardware timer.
The capacitor is charged and discharged through a known resistor using GPIO P0.27. The capacitor voltage is measured at the RC junction using P0.04 / AIN2.
For a charging capacitor:
After one time constant,
The firmware first discharges the capacitor close to 0 V, then starts charging it while sampling the voltage through the SAADC. A hardware timer measures the elapsed time until the voltage crosses the ~63.2% threshold.
With the resistance known, capacitance is calculated from:
The meter has been tested across several capacitor values, with measurements compared against a multimeter.
Breadboard setup used for testing the capacitance meter.
- Bare-metal firmware without an SDK or RTOS
- GPIO-controlled capacitor charge/discharge
- 12-bit SAADC measurements using EasyDMA
- Hardware timer with 1 µs resolution
- Integer-based voltage and capacitance calculations
- UARTE output for measurement results
UARTE output can be viewed with Minicom at 1M baud:
minicom -D /dev/ttyACM0 -b 10000000.1 µF disc capacitor
Reference (multimeter): 75.7 pF
10 µF electrolytic capacitor
Reference (multimeter): 10.06 µF
22 µF electrolytic capacitor
Reference (multimeter): 22.47 µF
100 µF electrolytic capacitor
Reference (multimeter): 100.5 µF
1000 µF electrolytic capacitor
Reference (multimeter): 877 µF
Note: Larger capacitors take longer to measure because the charging time increases with the RC time constant, τ = RC.
| Capacitor | Multimeter reference | Firmware average | Error |
|---|---|---|---|
| 0.1 µF | 75.7 nF | ~72.4 nF | ~4.36% |
| 10 µF | 10.06 µF | ~9.488 µF | ~5.69% |
| 22 µF | 22.47 µF | ~21.460 µF | ~4.49% |
| 100 µF | 100.5 µF | ~95.143 µF | ~5.33% |
| 1000 µF | 877 µF | ~844.214 µF | ~3.74% |
Calculation
See PROGRESS.md for the implementation checklist.
- Some low-level code is reused from my earlier nRF52840 bare-metal project.
- The UARTE logging code is based on this code from that project. Read more about it here.





