Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nrf52840-capacitance-meter

A simple nRF52840-based learning project for measuring capacitor values using RC timing, SAADC measurements, and a hardware timer.

RC Circuit

nRF52840 capacitance meter circuit

How it works

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:

$$V_C(t) = V_{final}\left(1 - e^{-t/RC}\right)$$

After one time constant, $t = RC$, the capacitor reaches approximately 63.2% of its final voltage:

$$V_C(RC) \approx 0.632V_{final}$$

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:

$$C = \frac{t}{R}$$

The meter has been tested across several capacitor values, with measurements compared against a multimeter.

Hardware

nRF52840 capacitance meter breadboard setup

Breadboard setup used for testing the capacitance meter.

Implementation

  • 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

Serial output

UARTE output can be viewed with Minicom at 1M baud:

minicom -D /dev/ttyACM0 -b 1000000

Measurements

0.1 µF disc capacitor

Firmware measurement of a 0.1 uF disc capacitor

Reference (multimeter): 75.7 pF

10 µF electrolytic capacitor

Firmware measurement of a 10 uF electrolytic capacitor

Reference (multimeter): 10.06 µF

22 µF electrolytic capacitor

Firmware measurement of a 22 uF electrolytic capacitor

Reference (multimeter): 22.47 µF

100 µF electrolytic capacitor

Firmware measurement of a 100 uF electrolytic capacitor

Reference (multimeter): 100.5 µF

1000 µF electrolytic capacitor

Firmware measurement of a 1000 uF electrolytic capacitor

Reference (multimeter): 877 µF

Note: Larger capacitors take longer to measure because the charging time increases with the RC time constant, τ = RC.

Measurement results

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

$$\text{Error (\%)} = \frac{\left|\text{Firmware} - \text{Reference}\right|} {\text{Reference}} \times 100$$

Implementation checklist

See PROGRESS.md for the implementation checklist.

Notes

About

A simple nRF52840-based tool for measuring small capacitors using RC timing and ADC measurements.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages