Guide for Rain Sensor FC-37 or YL-83 with Arduino

The rain sensor is used to detect water and it can detect beyond of what a humidity sensor do. This article explains how to use the FC-37 rain sensor module with the Arduino.

The FC-37 rain sensor (or other versions like YL-83) is set up by two pieces: the electronic board (at the left) and the collector board (at the right) that collects the water drops, as you can see in the following figure:

rain sensor

The rain sensor has a built-in potentiometer for sensitivity adjustment of the digital output (D0). It also has a power LED that lights up when the sensor is turned on and a digital output LED.

labeled sensor

You can also read this guide for the Soil Moisture Sensor YL-69 or HL-69 with the Arduino.

How does it work?

Basically, the resistance of the collector board varies accordingly to the amount of water on its surface.

When the board is:

  • Wet: the resistance increases, and the output voltage decreases
  • Dry: the resistance is lower, and the output voltage is higher

rainsensor

Example: Rain Sensor with Arduino

This is a simple example for you to understand how you can use the rain sensor in your projects with Arduino.

In this example, you will just read the analog sensor values using the Arduino and printing those readings in the Arduino IDE serial monitor.

Parts required

For this example, you’ll need:

You can use the preceding links or go directly to MakerAdvisor.com/tools to find all the parts for your projects at the best price!

Pin wiring

Wiring your sensor to the Arduino is pretty straightforward:

Pin  Wiring to Arduino
A0 Analog pins
D0 Digital pins
GND GND
VCC 5V

Schematics

Follow these schematics to complete the project:

rain-sensor_bb

Code

Upload the following sketch to your Arduino board (feel free to adjust the variable thresholdValue with a different threshold value):

/*
 
 All the resources for this project:
 https://randomnerdtutorials.com/
 
*/

int rainPin = A0;
int greenLED = 6;
int redLED = 7;
// you can adjust the threshold value
int thresholdValue = 500;

void setup(){
  pinMode(rainPin, INPUT);
  pinMode(greenLED, OUTPUT);
  pinMode(redLED, OUTPUT);
  digitalWrite(greenLED, LOW);
  digitalWrite(redLED, LOW);
  Serial.begin(9600);
}

void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(rainPin);
  Serial.print(sensorValue);
  if(sensorValue < thresholdValue){
    Serial.println(" - It's wet");
    digitalWrite(greenLED, LOW);
    digitalWrite(redLED, HIGH);
  }
  else {
    Serial.println(" - It's dry");
    digitalWrite(greenLED, HIGH);
    digitalWrite(redLED, LOW);
  }
  delay(500);
}

View raw code

Open the Arduino IDE serial monitor to see the values. Then you can start adding drops of water to the collector board.

When the value goes below a certain threshold, a red LED will turn on, and when the value goes above a certain threshold, a green LED will turn on.

Wrapping up

If you want to know when it’s raining,  you need to set up your rain sensor with the Arduino outside.

However, be aware that you should protect your Arduino and your circuit from water. A waterproof project box can be pretty handy in this situation (or any plastic box). Make sure you protect all your electronic components and only leave the collector board outside.

box

I hope you’ve found this guide useful. Have you done any project with this sensor?

Let me know by leaving a comment below.

If you like this post probably you might like my next ones (click here to subscribe my blog). Thanks for reading,

Rui



Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »
Learn how to build a home automation system and we’ll cover the following main subjects: Node-RED, Node-RED Dashboard, Raspberry Pi, ESP32, ESP8266, MQTT, and InfluxDB database DOWNLOAD »

Enjoyed this project? Stay updated by subscribing our newsletter!

10 thoughts on “Guide for Rain Sensor FC-37 or YL-83 with Arduino”

  1. Thank you for this easy explanation. I will use this sensor for my diploma project most definitely (along with an array of many other sensors).
    Your tutorial made it very easy to understand the working principle.
    Thanks a lot.

    Reply
  2. Olá Sara,

    Sabes como funciona o output digital deste sensor?
    Ou tem água ou não tem simplesmente? Ou algo tipo PWM?

    Obrigado

    Reply
    • Olá.
      Este sensor tem um output digital (DO) e um output analógico (AO).
      Podes receber um HIGH ou LOW se leres a partir do DO. Neste caso ele emite um HIGH quando a quantidade de água está acima de um terminado valor, ou LOW, quando está abaixo desse mesmo valor. Esse valor de “threshold” pode ser ajustado através do potenciómetro que vem com o sensor.
      Se usares o AO, podes ler um valor entre 0 e 1023 dependendo da quantidade de água.
      Espero que isto ajude.
      Sara 🙂
      P.S. Da próxima vez tenta postar as questões em inglês para que todos os utilizadores possam perceber. Obrigada.

      Reply
  3. Hi
    Super article with rain sensor HL-83 and an Arduino.
    Can’t use a Wemos D1 mini instead of Arduino and can one use the same code ??
    Thanks

    Reply
    • Yes.
      You just need to use different pins to connect the LEDs and do those adjustments on the code.
      Regards,
      Sara

      Reply

Leave a Comment

Download Our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.