How a Rain Sensor Works and Wiring It to Arduino

Engineering illustration: How a Rain Sensor Works and Wiring It to Arduino

We covered a complete project for a window that closes automatically when it rains in an earlier article; this article focuses on the prior question: how does a rain sensor work internally, and what are the details of wiring it?

The internal principle: a variable resistor

The sensing board contains exposed copper traces that act as a variable resistor much like a potentiometer; the resistance changes inversely with the presence of water, since rain droplets improve electrical conduction between the traces and lower the resistance, while it rises in the dry state. This change produces an output voltage that scales directly with the amount of water on the surface.

The conversion circuit: the LM393 comparator

The sensor includes an LM393 circuit that converts the analog signal into a digital one, with a built-in potentiometer to adjust the detection sensitivity threshold. When moisture exceeds this threshold, the digital output drops to LOW; otherwise it stays HIGH. The sensor also includes two LED indicators showing power status and detection state.

Wiring it up

The sensor connects with four pins: power and ground (3.3-5V), an analog output (AO) giving a continuous voltage reading between 0 and 5V reflecting the moisture level, and a digital output (DO) giving the comparator's binary signal to any Arduino digital pin.

Technical note: it's recommended to power the sensor through a digital pin instead of continuously, since constant voltage speeds up corrosion of the exposed copper traces; the sensor draws only about 8mA, making it perfectly safe to control its power through an Arduino pin.

You can find rain sensors at Juthour Tech.

اترك تعليقا

*
*
يمكن للأعضاء المسجلين فقط ترك تعليقات.