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
Post a Comment