Robo India presents tutorial on how to measure water level through float sensor using ESP8266 and connection with blynk app.
1. Introduction:
This module is used to measure water level using float sensor, ESP8266 and connecting it to blynk app.
2. Hardware required
S.No. | Item | Quantity |
1. | NodeMCU | 1 |
2. | Breadboard | 1 |
3. | Float Sensor | 2 |
3. Connections:
Make the following connections with NodeMCU-
First(Bottom) Sensor-
Connect one end to D1 and another to GND.
Second(Top) Sensor-
Connect one end to D2 and another to GND.
4. Programming:
Select NodeMCU 1.0( ESP-12E Module ) in Boards.
You may download this Arduino Sketch from here.
#define BLYNK_PRINT Serial #include <BlynkSimpleEsp8266.h> BlynkTimer timer; char auth[]="...."; char ssid[]="...."; char pass[]="...."; int flagB=0; int flagT=0; void Buttonstate() { int isBS = digitalRead(5); int isTS = digitalRead(4); if (isBS==1 && flagB==0){ Serial.println("water level above the Bottom sensor"); Blynk.virtualWrite(V1,1); Blynk.virtualWrite(V2,50); flagB=1; } else if (isBS==0 && flagB==1) { Serial.println("Lower than Bottom sensor"); Blynk.notify("Lower than Bottom sensor"); Blynk.virtualWrite(V1,0); Blynk.virtualWrite(V2,0); flagB=0; } if (isTS==1 && flagT==0){ Serial.println("Water level above the Top sensor"); Blynk.notify("Water level above the Top sensor"); Blynk.virtualWrite(V0,1); Blynk.virtualWrite(V2,100); flagT=1; } else if (isTS==0 && flagT==1) { Serial.println("Lower than Top sensor"); Blynk.virtualWrite(V0,0); Blynk.virtualWrite(V2,50); flagT=0; } } void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(5, INPUT_PULLUP); pinMode(4, INPUT_PULLUP); Blynk.begin(auth, ssid, pass); Blynk.virtualWrite(V0,0); Blynk.virtualWrite(V1,0); Blynk.virtualWrite(V2,0); timer.setInterval(2000L,Buttonstate); delay(1000); } void loop() { // put your main code here, to run repeatedly: Blynk.run(); timer.run(); }
5. Output
Upload the above code to the NodeMCU and open serial monitor. Following output should be shown on the serial monitor.
If you have any query please write us at support@roboindia.com
Thanks and Regards
Content Development Team
Robo India
https://roboindia.com