Today’s tutorial is about the interfacing of Raindrop sensor with NodeMcu. The rain sensor module is Vary easy tool for rain detection. It can be used as a switch when raindrop falls through the raining board and also for measuring rainfall intensity. The module features, a rain board and the control board that is separate for more convenience, power indicator LED and an adjustable sensitivity though a potentiometer.


Working Principle of Raindrop Sensor

Raindrop sensor is basically a board on which nickel is coated in the form of lines. It works on the principal of resistance. When there is no rain drop on board. Resistance is high so we gets high voltage according to V=IR. When rain drop present it reduces the resistance because water is conductor of electricity and presence of water connects nickel lines in parallel so reduced resistance and reduced voltage drop across it.
Raindrop Sensor


Pin Configuration Raindrop Sensor


It consists of two parts one is a black board with nickel layers on it and other is an integrated chip provided with some output pins.Board has 2 output pin and chip has 6 pin

Pin Configuration Raindrop Sensor

  • ESP8266 (NodeMCU): Link
  • Raindrop Sensor: Link
  • LED: Link
  • Breadboard: Link
  • Jumper Wires: Link
  • Circuit Diagram of raindrop sensor interfacing with NodeMcu

    The analog output is used in detection of drops in the amount of rainfall. Connected to 3,3Vpower supply, the LED will turn Off when induction board has no rain drop, and  output is Low. When dropping a little amount water, output is High, the switch indicator will turn on. Brush off the water droplets, and when restored to the initial state, outputs high level.When no rain digital output is 1 and analog output gives 1023 max value. When rain is present digital output is 0 and analogue output is much less than 1023.

    Code
    /*
    Agu 2018
    Author: Sarful hassan
    Website: https://mechatronicslabrpi.blogspot.com
    */ 
    //library esp
    #include <ESP8266WiFi.h>
    const char* ssid = "rows";                                  //fill in your wifi name
    const char* password = "007892";                              //fill in your wifi password
    WiFiClient client;
    int sensorPin = A0;    
    int enable2 = 13;      // enable reading Rain sensor
    int sensorValue2 = 0;  // variable to store the value coming from sensor Rain sensor
    //--------------------------setup-------------------------
    void setup() {
    // declare the enable and ledPin as an OUTPUT:
    pinMode(enable2, OUTPUT);
    Serial.begin(115200);
    delay(10);
    WiFi.begin(ssid, password);
    Serial.println();
    Serial.println();
    Serial.print("Connecting to ");
    Serial.println(ssid);
    Serial.print("..........");
    Serial.println();
    WiFi.begin(ssid, password);
    while (WiFi.status() != WL_CONNECTED) {
    delay(500);

    }
    Serial.println("WiFi connected");
    Serial.println();

    }
    void loop() {

    //--------------------------Rain Sensor-------------------------

    delay(500);
    sensorValue2 = analogRead(sensorPin);
    sensorValue2 = constrain(sensorValue2, 150, 440); 
    sensorValue2 = map(sensorValue2, 150, 440, 1023, 0); 
    if (sensorValue2>= 20)
    {
      Serial.print("rain is detected");
      
    digitalWrite(enable2, HIGH);
      }
      else
      
    {
      Serial.print("rain not detected");
      digitalWrite(enable2, LOW); 
      }
    //Serial.print("Rain value:       ");
    //Serial.println(sensorValue2);
    Serial.println();
    delay(100);

    }

    Video





    Download Code Click Here



    No comments

    Theme images by Dizzo. Powered by Blogger.