Why the capacitor
A 1 MΩ source is too weak for an ADC to read directly: an Uno samples through a 14 pF capacitor for 12 µs and asks for a source of 10 kΩ or less. The 100 nF on SIGNAL holds seven thousand times that charge, so each sample takes 0.014 % of it. The price is a time constant: 1 MΩ × 100 nF, a tenth of a second.
An ADC takes a sip
An analog-to-digital converter does not measure a pin continuously. For an instant it joins a small capacitor inside the chip to the pin, lets it fill to the pin's voltage, then lets go and measures that. On an Uno's ATmega328P the capacitor is 14 pF, behind 1 to 100 kΩ inside the chip, and the Arduino core gives it 12 µs. Microchip's data sheet says the ADC is made for sources of about 10 kΩ or less.
The divider is a megohm source. Through a megohm, 14 pF takes 15 µs per time constant to fill: longer than the window.
Press Play without the 100 nF. The window closes with the sampling capacitor about halfway, and the Uno reads about half the true value. With it, the 14 pF fills from the 100 nF through the 150 Ω in a few microseconds, and takes 0.014 % of the 100 nF's charge doing it: less than one count in 1023. The 1 MΩ tops the 100 nF up long before the next reading.
Espressif does not publish the ESP32's sampling capacitance, so there is no number here for it; the same reasoning applies to any ADC that samples.
What it costs: a tenth of a second
Every path into the 100 nF runs through the 1 MΩ or the water. So SIGNAL cannot jump. It moves with a time constant of 1 MΩ × 100 nF = 0.1 s when the board is nearly dry, and faster when it is wet.
Most of the time that is invisible: water arrives and evaporates far more slowly than 0.1 s. It matters in one place, when VCC is switched on just before a reading, which power it only to read works through.
When it does not work
Only for the first half second. The 100 nF empties through the 1 MΩ with a time constant of 0.1 s, gone in about 0.5 s. A reading that takes seconds or minutes to fall is the water evaporating, not the circuit.
Yes, and the 100 nF is why. When an ADC switches from another pin, its sampling capacitor starts from that pin's voltage and has to be refilled. It refills from the 100 nF, through 150 Ω, in a few microseconds.
It would settle sooner, and give each sample less charge to draw on. With 1 nF, one Uno sample from empty would take 1.4 % of it, up to 14 counts. The 100 nF is the size that makes the sample invisible; the half-second settle is its cost.
Edit this page — content/books/steam-sensor/why-the-capacitor.mdx
Questions about this product
See what other owners have asked, and read their solutions.
Steam Sensor
Loading discussions…
Discuss this article
Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.