ESP8266- Rain drop Sensor Interfacing


Program


#define DO_PIN    D2  // The ESP8266 pin connected to DO pin of the rain sensor

void setup() {

    Serial.begin(9600);

    pinMode(DO_PIN, INPUT);

}

void loop() {

   delay(10);                      // wait 10 milliseconds

  int rain_state = digitalRead(DO_PIN);

  if (rain_state == HIGH)

    Serial.println("The rain is NOT detected");

  else

    Serial.println("The rain is detected");

  delay(1000);  // pause for 1 sec to avoid reading sensors frequently to prolong the sensor lifetime

}

Comments

Popular posts from this blog

System Bus Types, Functions, and Features

Motherboard form factor

ESP 8266- Ultrasonic Sensor Interfacing