I had to play a little and worked out a working example .
I used a 4.7 Kohm resistor and the following capacitors: 0.1, 1, 2.2, 3.3, 10, 22, 33, 47, 100 and 220 microfarad.
Connections: resistor between pin7 and pin A0, from pin A0 to the plus side of a capacitor, the negatives of the capacitors are to ground.
pin7 supplies the full voltage of 3.3v when turned on, ground when off.
pi A0 measures the voltage on the capacitor after t time from voltage on.
The results were not consistent so I had to introduce a calibration function.
Sub Process_Globals
Public Serial1 As Serial
Private pin7 As Pin
Private tmr As Timer
Private d1 As D1Pins
Private sense As Pin
Private cval As Double
Private sval As Int
Private cal As Double
Private t As Int = 13000
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
pin7.Initialize(d1.D7,pin7.MODE_OUTPUT)
pin7.DigitalWrite(False)
sense.Initialize(sense.A0,sense.MODE_INPUT)
tmr.Initialize("tmr_Tick",60000)
tmr.Enabled = True
Delay(5000)
tmr_tick
End Sub
Sub tmr_tick
pin7.DigitalWrite(False)
Delay(1000)
t = 13000
pin7.DigitalWrite(True)
DelayMicroseconds(t)
sval = sense.AnalogRead
Log(t, " ",sval)
get_cal
If t < 13000 Then
pin7.DigitalWrite(False)
Delay(1000)
pin7.DigitalWrite(True)
Log(t)
DelayMicroseconds(t)
sval = sense.AnalogRead
Log(sval)
End If
cval = -t / 4700 / Logarithm(1.0 - sval*cal/1023,cE )
Log("c = " ,cval , " microfarad")
pin7.DigitalWrite(False)
Log("*******************")
End Sub
Sub get_cal
Select True
Case sval < 30
cal = 0.475
Case sval < 50
cal = 0.68
Case sval < 320
cal = 0.8
Case sval < 700
cal = 0.895
Case Else
cal = 0.94
End Select
If sval > 1015 Then
t = 500
cal = 0.7
End If
Log("cal= " , cal, " t= ", t)
End Sub
To measure connect the specific capacitor and either reset the card or wait for the timer tick.
I didn't check other values of capacitors, they will probably require some more calibration values.