Water level indicator using Nodemcu and ultrasonic sensor – Step by step instructions
Water level indicator using Nodemcu and ultrasonic sensor
Hello, welcome back to the IoT-based tutorial from SriTu Hobby. Today we are going to talk about how to make a water level indicator using Nodemcu and the ultrasonic sensor. This project can be used mainly for the water tank in our house. It is also designed to monitor the water level online and turn the water pump ON / OFF even when we are not at home. Also, the Nodemcu ESP8266 board and the Blynk application are mainly used for this project. An ultrasonic sensor is used to measure the amount of water and a relay module is used to turn the water pump ON / OFF.
The process of this tutorial
- Nodemcu ESP8266 x 1 — Amazon / Our Store
- Ultrasonic sensor x 1 — Amazon / Our Store
- Relay module x 1 — Amazon / Our Store
- Jumper wires — Amazon / Our Store
- Breadboard x 1 — Amazon / Our Store
Step 1
Nodemcu ESP8266
Ultrasonic sensor
Relay module
Jumper wires
Breadboard
Step 2
Step 3
- First, click the “New Project” button. After, enter the project name as you like. Then select the device and connection type. Finally, click the “Confirm” button.
- Next, click the “+” button and includes a “Button” and “Level V” widget. OK, let’s set up this button. For that, click this “Button”. Now, enter the button name as you like. After, select “Virtual V0” for the PIN and drag the button below it to the “Switch” side.
- OK, let’s set up the “level V” widget. For that, click this widget. Now, enter the widget name as you like. Then, select “Virtual V1” for the PIN and enter your water tank level. Then turns ON the flip axis button.
- Lastly, arrange these widgets as you like.
Step 4
/*Water level monitoring system.
* This code creates by the SriTu Hobby team.
* https://srituhobby.com
*/
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
char auth[] = "";//Enter your Auth token
char ssid[] = "";//Enter your WIFI name
char pass[] = "";//Enter your WIFI password
BlynkTimer timer;
bool pinValue = 0;
#define trig D3
#define echo D4
#define relay D5
void setup() {
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
pinMode(relay, OUTPUT);
Wire.begin(D2, D1);
lcd.init();
lcd.backlight();
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
timer.setInterval(10L, Wlevel);
digitalWrite(relay, HIGH);
}
BLYNK_WRITE(V0) {
pinValue = param.asInt();
}
void loop() {
Blynk.run();
timer.run();
}
void Wlevel() {
if (pinValue == 1) {
digitalWrite(relay, LOW);
lcd.setCursor(0, 1);
lcd.print("Motor is ON ");
} else if (pinValue == 0) {
digitalWrite(relay, HIGH);
lcd.setCursor(0, 1);
lcd.print("Motor is OFF");
}
digitalWrite(trig, LOW);
delayMicroseconds(4);
digitalWrite(trig, HIGH);
delayMicroseconds(10);
digitalWrite(trig, LOW);
long t = pulseIn(echo, HIGH);
long cm = t / 29 / 2;
Blynk.virtualWrite(V1, cm);
Serial.println(cm);
lcd.setCursor(0, 0);
lcd.print("Water Level: ");
lcd.print(cm);
lcd.print(" ");
}
Code explanation
Step 6
Water level indicator using Nodemcu and ultrasonic sensor – Step by step instructions
i want programerd node mcu buy
9081812000
Not for sale. You can buy it from another place.
ONE OF THE BEST TUTORIALS I HAVE SEEN IN A LONG TIME. WILL BE DOING THIS AT HTE WEEKEND FOR MY FISH TANK. NOT REALLY NEEDED BUT LOOKS FUN. THANK YOU.
Thanks, dude
This is one of the simplest procedure i found. Nice job Sritu.
could you clarify on the installation of libraries you mentioned in step 4 in to Arduiono IDE.
I downloaded the ESP8266wifi library as you mentioned in step 4 , but unable to install this specific library in to Arduino IDE hence not able to see the ESP8266 board in Tools/Board.
For that use this link.
http://srituhobby.com/blynk-app-setup-up-tutorial-blynk-app-with-nodemcu-esp8266/
I mean, how to install this downloaded library in to Arduiono IDE?
For that please check my pervious articles.
Very Informative