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.
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
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
|
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
More project
1.Intoduction to nodemcu8266 & Steps to Import ESP Board Libraries
2.NodeMCU8266 Basic Project-Blink a LED
3.NodeMCU8266 Digital Read (Push Button)
4.Analog Data read using NodeMcu8266
5. NodeMcu LED control Use in Blynk app in IOT platform
2.NodeMCU8266 Basic Project-Blink a LED
3.NodeMCU8266 Digital Read (Push Button)
4.Analog Data read using NodeMcu8266
5. NodeMcu LED control Use in Blynk app in IOT platform
6.NodeMcu to DHT Interface in Blynk app| On IOT Platform
7.The Best Way To nodemcu gps tracker blynk app |in IOT platform
7.The Best Way To nodemcu gps tracker blynk app |in IOT platform
No comments