# RC circuit: C appears to increase in size with frequency

I've come up with an RC circuit, which is using the output pins of a NodeMCU board to create an AC current for measuring conductivity of a liquid.

What I'm actually measuring is the discharge time of the capacitor, and that's what this question is about. At low frequencies (1-2 kHz) the measured time is exactly as expected based on the capacitance of 47 nF, knowing that the input pin flips when the voltage reaches 50%. That's the time I'm measuring: from fully charged to 50%.

Now at higher frequencies (by lowering the value of the load resistor) the capacitor appears to go up in size, at 120R I'm getting discharge times of around 7200 nanoseconds, that gives me a capacitance of about 120 nF.

How could this be possible?

Other possibly relevant information: the capacitor appears to be a film type (it's a rectangular block); the whole setup is operating on a solderless breadboard (I know there may be stray capacitance in there but that doesn't matter here - I don't care as much about the actual value of the cap as I care about it being constant).

J1 is three GPIO pins of the NodeMCU. The EC probe I replaced by resistors of various value just to measure the response, which I expect to be linear. C1 is first fully charged by the pins 1 and 2 (it gets 100 microseconds for that, RC is just over 15 microseconds), then discharged over pin 3 while pin 1 measures the voltage, flipping when the voltage drops below 50%. All in all a very basic RC circuit. I expect that lowering the value of the resistor over J2 decreases the time linearly - but it doesn't.

At 33k discharge time about 800 us, R/t/0.5 = 48 nF.

At 10k discharge time about 235 us, R/t/0.5 = 47 nF.

At 330R discharge time about 12 us, R/t/0.5 = 73 nF.

At 120R discharge time about 7 us, R/t/0.5 = 120 nF.

My timing is in the 12.5 ns resolution (80 MHz clock speed) so that's not the problem. Being a few ticks off doesn't explain this. • "knowing that the input pin flips when the voltage reaches 50%". I/O pins on an MCU does not behave like that. This is only true if you have an analog comparator.
– pipe
Mar 26, 2017 at 18:59
• NodeMCU is not an Arduino clone; it's an alternative firmware for ESP8266 wifi SOCs. They are very different from Arduino's in both hard- and software. Mar 26, 2017 at 19:25
• I've done some actual measurements and found it's really close to that 50% level that the pin flips in my test boards. I thought it'd be 1/3 or 2/3 Vcc but it's more like 1/2. Using that 50% level in calculations also works very well. The actual level is not important, really, as long as it's constant. The calibration factor takes care of all that. Mar 26, 2017 at 19:26
• Edited the arduino part. Mar 26, 2017 at 19:27