Rain sensor
A plate of interleaved traces. Rain on it and AO falls; past the trimmer DO goes low.
- 4 pins
- 1 setting
- In 2 projects
- In 2 lessons
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
4 pins
Named as the editor names them, so a wire lands where you expect 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.
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.
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);
}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.
See the Rain sensor in a project
2 built-in projects use it. Each opens in the editor, already wired.
Where it turns up in a lesson
2 lessons place it in their own circuits.
The boards it is shown on
This board has a built-in project with the Rain sensor in it.
The rest of the bench
Every one of these is drawn and simulated the same way.
Wire up the Rain sensor
Open the editor and push it into the breadboard. It is free, and it runs on your own machine.