- Sun Feb 26, 2017 6:48 am
#63041
Not sure how one would do this with one pin, but there might be a way with two!
Pin1 (output) connects to capacitor to be measured via a resistor. Pin 2 (A/D input) connects to top of capacitor.
Pin 1 goes high and charges capacitor via resistor. Pin 2 measures fully charged voltage. Pin 1 then goes low, discharging capacitor via resistor. Pin 2 detects when Vcap drops to 0.69 of original fully charged value. Then capacitor value can be found from t = 0.69CR.
Only problem is, with the kinds of value you mention, a 40pF capacitor with a 1Meg resistor would take around 28uS to discharge to that level, and I don't know any way of measuring periods that short using ESPbasic.
Which brings me to a general point for MM: the TIMER function is very useful, but only has a resolution of milliseconds. Is there any chance of getting a similar function for microseconds?