water level indicator using nodemcu

Water Level Indicator Using NodeMCU

IoT

Hey geeks, welcome back to Techatronic. Do you know how a water level depth detection module works with NodeMCU? In this article, we are going to teach you how you can make a water level indicator using NodeMCU. We have to dip the water level depth detection module into the water or fill the container with water in which the module is placed. This sensor is used to find the level of the water raised into the container. This technology can be used to tell that the water tank is full or not. We have also discussed the working of a water level sensor with Arduino in our previous articles. You can also make the Blynk water level indicator which displays the real-time data in the Blynk app.

How Does Water Level Indicator Work?

The water level depth detection module can generate its output depending upon the level of water. While working with this module please place it vertically inside the container. You can see the readings on the IDEs serial monitor screen. Open the serial monitor which is given in the image below. When the output value of the water level sensor is above then 400 the red LED will glow, for the output value above then 540 the green and red LED will glow, and for the output value above then 580 all three LEDs will glow. But if you are using an RGB LED module one LED will glow at a time. The LEDs will go on and off according to the conditions specified in the code.

Components Required

  • NodeMCU esp8266 board
  • Water level sensor
  • Jumper wires
  • Breadboard
  • USB cable for uploading the code
  • Three 220-ohm resistors
  • LEDs of red, yellow, and green color or KY-016 RGB LED module
S.No Component Name Quantity Buy Link
1. Nodemcu esp8266 1 https://amzn.to/3EUGhuu
2. Nodemcu cable 1 https://amzn.to/3F1ywmu
3. Water Level Sensor 1 https://amzn.to/3iHpYrl
4. RGB Led Module 1 https://amzn.to/3Fqzbhe
5. RGB led 1 https://amzn.to/3AbPECg
6. 220-ohm Resistor 3 https://amzn.to/3oioZkQ
7. Breadboard 1 https://amzn.to/39vsRX2
8. Jumper wire 40 https://amzn.to/39q43jr

Water Level Indicator nodemcu circuit

water level indicator using nodemcu

Nodemcu esp8266 LED R LED Y LED G 220 Ohm Resistor
D5 Pin Anode Pin
D6 Pin Anode Pin
D7 Pin Anode Pin
GND Terminal 1
Cathode Pin Cathode Pin Cathode Pin Terminal 2

water level indicator using nodemcu

Nodemcu esp8266 RGB Led Module
D5 Pin Terminal 1 B
D6 Pin Terminal 2 G
D7 Pin Terminal 3 R
G ( GND ) Terminal 4

You have to make the circuit according to the given diagram. Connect the VCC pin of the water level sensor with the Vin pin of the NodeMCU. Attach the GND pin of the water level sensor with the GND pin of the NodeMCU. Join the signal pin of the water level sensor with the analog-0 pin of the NodeMCU. If you are using the RGB LED module, connect the GND pin of the module with the GND pin of the NodeMCU. Join the R pin of the module with the digital-7 pin of the NodeMCU. Attach the G pin of the module with the digital-6 pin of the NodeMCU. Connect the B pin of the module with the digital-5 pin of the NodeMCU. If you are using separate LEDs then connect the negative leg of all the three LEDs with the GND pin of the NodeMCU through a 220-ohm resistance and the positive with digital-5, 6, 7 as shown above.

Water Level Indicator NodeMCU Circuit

NOTE: Please upload the code given below to the NodeMCU using Arduino IDE.

  • Use this code if you are using separate LEDs
 // TECHATRONIC.COM  
 int val = 0 ;  
 void setup()  
 {  
   Serial.begin(9600); // sensor buart rate  
   pinMode(14,HIGH);  // Red led Pin Connected To D5 Pin   
   pinMode(13,HIGH);  // Green Led Pin Connected To D7 Pin   
   pinMode(12,HIGH);  // Yellow Led Connected To D6 Pin    
 }  
 void loop()   
 {  
  int s1=analogRead(A0); // Water Level Sensor output pin connected A0  
  Serial.println(s1);  // See the Value In Serial Monitor     
  delay(100);      // for timer  
  if(s1> 400 )  
   {   
    digitalWrite(14,HIGH);   // Red led ON   
   }   
  else   
   {   
   digitalWrite(14,LOW);    // Red led OFF  
   }   
  if(s1>540 )   
   {   
   digitalWrite(12,HIGH);   // Green led ON   
   }  
   else   
   {   
   digitalWrite(12,LOW);   // Green led OFF   
   }   
   if(s1>580 )   
   {  
   digitalWrite(13,HIGH);  // Yellow led ON   
   }  
   else  
   {  
   digitalWrite(13,LOW);  // Yellow led OFF   
   }  
  }  
  • Use this code if you are using a KY-016 RGB LED module
 // TECHATRONIC.COM  
 int val = 0 ;  
 void setup()  
 {  
   Serial.begin(9600); // sensor buart rate  
   pinMode(14,HIGH);  // Blue led Pin Connected To D5 Pin   
   pinMode(13,HIGH);  // Red Led Pin Connected To D7 Pin   
   pinMode(12,HIGH);  // Green Led Connected To D6 Pin    
 }  
 void loop()   
 {  
  int s1=analogRead(A0); // Water Level Sensor output pin connected A0  
  Serial.println(s1);  // See the Value In Serial Monitor     
  delay(100);      // for timer  
  if(s1>400 && s1<500 )  
   {   
    digitalWrite(14,HIGH);   // Blue led ON   
   }   
  else   
   {   
   digitalWrite(14,LOW);    // Blue led OFF  
   }   
  if(s1>500 && s1<550 )  
   {   
   digitalWrite(12,HIGH);   // Green led ON   
   }  
   else   
   {   
   digitalWrite(12,LOW);   // Green led OFF   
   }   
   if(s1>550 )   
   {  
   digitalWrite(13,HIGH);  // Red led ON   
   }  
   else  
   {  
   digitalWrite(13,LOW);   // Red led OFF   
   }  
  }  

We hope that you like this project and now please try to make it on your own. If you are facing any difficulties while making this project feel free to ask in the comments sections below. Also, check tutorials on Arduino and Raspberry Pi written by us.

HAPPY LEARNING!

Spread the love, Share this post with friends