Part

Rain sensor

A plate of interleaved traces. Rain on it and AO falls; past the trimmer DO goes low.

See every part
  • 4 pins
  • 1 setting
  • In 2 projects
  • In 2 lessons
Drawn live by the editor's own code, at the size you see it.
At a glance

The Rain sensor in brief

What it is, and every setting the properties panel gives it.

The rain sensor is the FC-37 or YL-83 kit: a plate of interleaved traces wired to a small LM393 comparator board with a blue trimmer. The board’s pins are VCC, GND, DO and AO, at 3.3 to 5 volts. On an Uno, VCC goes to 5 V, AO to an analog pin and DO to any digital pin; on an ESP32, power it from 3.3 V so AO and the DO pull-up stay inside what its pins take. The plate sits under a 10 k pull-up, so dry reads the full supply and wet reads lower, and DO pulls low and lights its lamp when AO falls under the trimmer, the threshold property, half the supply by default. As the slider goes from dry to 100 percent wet, Mokxi takes the plate from open circuit to 5 k x (100 / w)^1.2, which on a 5 V Uno reads 1023 dry, the high hundreds with a few drops and the low three hundreds soaked. The classic mistake is powering it all the time; feed VCC from a pin only while reading. Corrosion, drying time and how salty the water is are not modeled.

Family
Sensors
Pins
4
threshold
0.5
Pins

4 pins

Named as the editor names them, so a wire lands where you expect it.

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

How to use a rain sensor module with an Arduino

The plate wires to the little comparator board, and the board’s four pins go to the Uno: VCC to 5 V, GND to GND, AO to an analog pin and DO to a digital pin. In the plant monitor, AO is on A1 and DO on pin 7, beside a soil sensor and a water level sensor.

analogRead(A1) gives 1023 dry and falls as the plate gets wetter, so lower means more rain. DO is the board’s own answer, low when AO drops under the blue trimmer, so digitalRead(7) == LOW is a plain “it is raining” with no arithmetic. The plant monitor lights its lamp only when the soil is dry and it is not raining.

A real plate powered all the time corrodes in weeks. Feed VCC from a digital pin, set it HIGH, wait a few milliseconds, read, and set it LOW again; an unpowered board drives nothing here either, so the same sketch runs in the simulator.

Part pin
Board pin
VCC
5 V
GND
GND
DO
Pin 7
AO
A1

On an ESP32, power the board from 3.3 V: AO then tops out at 3.3 V and DO’s 10 k pull-up goes to 3.3 V, both safe for its pins.

Arduino Uno: plant monitorlive0.000 s 0.00x
Click to open it in the editor
This is the simulator itself, running here. Click anything to open it in the editor.
Both outputs of a rain sensor
const int RAIN_AO = A1;
const int RAIN_DO = 7;
void setup() {
  pinMode(RAIN_DO, INPUT);
  Serial.begin(115200);
}
void loop() {
  int rain = analogRead(RAIN_AO);
  bool raining = digitalRead(RAIN_DO) == LOW;
  Serial.print(rain);
  Serial.println(raining ? " raining" : " dry");
  delay(1000);
}
How it is modeled

What is true about the Rain sensor, here

In its help article’s own words: what the simulation gets right, and where it stops.

Modeled

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.

Not modeled

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.

From Rain sensor, in full.

Projects

See the Rain sensor in a project

2 built-in projects use it. Each opens in the editor, already wired.

Lessons

Where it turns up in a lesson

2 lessons place it in their own circuits.

Boards

The boards it is shown on

This board has a built-in project with the Rain sensor in it.

Wire up the Rain sensor

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.