How to make a YL-83 rain detector with Arduino

  • The YL-83 sensor detects rain through resistance changes on its metal plate.
  • Its analog output allows you to measure the intensity of rain, while the digital output indicates its presence.
  • It is ideal for automation projects, such as alarm activation or irrigation systems.

yl-83

Have you ever wondered how to detect rain with a YL-83 sensor and an Arduino? This fascinating topic brings electronics and meteorology together in practical projects that you can carry out at home. You don't need to be an expert in programming or circuits to get started; with the right tools, a little patience and a pinch of creativity, you can put together a functional rain detector that reacts to water drops.

Today we will learn in detail how this sensor works, how to connect it to an Arduino board, and most importantly, what Practical applications has in everyday life. From setting off an alarm to automating an irrigation system, the possibilities are many. So, without further ado, let’s break down all this information.

What is the YL-83 sensor and how does it work?

The YL-83 rain sensor is a very popular component in Arduino projects due to its simplicity and low cost. This device mainly consists of two parts:

  • A conductive plate that detects water through its ability to conduct electricity.
  • A comparator module that converts signals from the board into analog or digital values.

When raindrops fall on the sensor board, they connect the metal contacts on the surface, causing a change in resistance. This change is processed by the comparator module, which generates analog values ​​between 0 and 1023 or a digital output (0 or 1) depending on how you want to use it.

Basic features of the rain sensor

This sensor is extremely versatile and can be adapted to different projects. Its main features include:

  • Power supply from 3.3 to 5V, compatible with most Arduino boards.
  • Two outputs: digital (DO) and analog (AO).
  • Adjustable sensitivity via an integrated potentiometer.
  • Compact design with oxidation resistance thanks to its nickel-plated surface.

Thanks to these features, you can use this sensor for both detect the presence of water as if to measure its intensity.

How to connect the YL-83 sensor to the Arduino

Electrical assembly is quick and easy. You will need: connection cables and of course a compatible Arduino board like the UNO, Mega or Nano. Here is a basic guide:

  • Connect the VCC pin of the sensor to the 5V pin of the Arduino.
  • The GND of the sensor must be connected to the GND of the Arduino board.
  • The digital output (DO) can be connected to any digital pin on the Arduino, for example, D2.
  • If you want to measure analog values, connect the analog output (AO) to an analog pin, such as A0.

Once everything is connected, adjust the potentiometer on the sensor module to calibrate the sensitivity threshold moisture.

Code to get started: reading values

The code is essential to interpret the different data provided by the sensor. Here is a basic example:

const int sensorPin = A0; void setup() { Serial.begin(9600); } void loop() { int value = analogRead(sensorPin); Serial.print("Analog Read: "); Serial.println(value); delay(1000); }

This code reads analog values ​​from the sensor and displays them on the serial monitor. You can wet the sensor surface and observe how the values ​​change.

More code examples

Want to do something more interactive? Try this code that classifies rain into different intensities:

const int sensorPin = A0; void setup() { Serial.begin(9600); } void loop() { int value = analogRead(sensorPin); if (value > 950) { Serial.println("There is no rain"); } else if (value > 600) { Serial.println("It's raining"); } else if (value > 300) { Serial.println("Downpour"); } else { Serial.println("Possible flood"); } delay(1000); }

This small program allows you to monitor the precipitation level risk management.

Practical applications of rain sensor

The YL-83 has a range of uses in home automation or educational projects. Here are some ideas:

  • Irrigation automation: You can connect the sensor to a water pump that will activate when it detects insufficient humidity.
  • alarms: Activates an audible alarm if the sensor detects heavy rain or flooding.
  • Awning control: Automatically extends or retracts awnings on terraces depending on weather conditions.

Thanks to its simplicity and low cost, this sensor is an excellent tool for DIY projects.

The YL-83 rain sensor is much more than just a clever accessory, it's a gateway to the fascinating world of programming and applied electronics. With a simple setup and a little creativity, you can create useful and practical systems that respond to weather conditions. If you've ever wondered how to automate tasks or just enjoyed a different educational project, this sensor is a great option. Let's get to work!