Rain sensor

The rain sensor, FC-37 and YL-83 style: a plate of interleaved traces wired to an LM393 comparator board. Aliases: raindrop sensor, water sensor plate.

The plate is two combs of copper whose teeth lie between each other and never touch. Dry, it is an open circuit. A drop of water across two teeth is a resistor, and more drops are more resistors in parallel. The board puts the plate under a 10 k pull-up, so dry reads the full supply on AO and wet reads lower, and the comparator pulls DO low and lights its lamp when AO falls under the trimmer.

Pins

Pin What it does
VCC Supply, 3.3 V to 5 V.
GND Ground.
DO Low when the plate is wet enough. Open collector with a 10 k pull-up.
AO The plate under its pull-up: lower means wetter.

Properties

threshold is the trimmer as a fraction of the supply, 0.5 by default.

While it runs

Drag the slider to rain on the plate, 0 (dry) to 100% (soaked). Drops gather on the plate as it gets wetter.

What the model gets right

The plate's resistance falls as a power of how wet it is, 5 k x (100 / w)^1.2, and it is open when dry. On a 5 V Arduino that reads 1023 dry, the high hundreds with a few drops, the middle in a good shower and the low three hundreds soaked, which is what people see. An unpowered board drives nothing at all, which matters because of the advice below.

What it does not model

That curve is a shape, not a measurement: what a wet plate reads depends on how much salt is in the water as much as on how much water there is, and rain, tap water and a finger read nothing like one another. The plate corroding is not modeled: a DC current through wet traces is electrolysis, and a real plate powered all the time corrodes in weeks. Nor is how long the water takes to dry off, which is what makes a real one slow to say the rain has stopped. The comparator has no hysteresis, as on the real board.

Common mistakes

Powering it all the time. Power VCC from a pin, switch it on, wait a few milliseconds, read, and switch it off again; the plate lasts for years that way.

See it in action

Plant monitor reads the rain sensor beside a soil sensor and a water level sensor. Open it at /templates.