These are the component used

Measuring exact water level in cm or percentage from 3 floor above, without distorting beauty of your house using wiring is difficult task but by using IOT it is easy to send data on internet. so now if data is on internet it is easy to monitor throw any mobile device connected to internet.

Though data can transmit wireless over long distance but power can’t. Therefore in this project solar panel is use with 3.7 volt battery. to powered the circuit when sun is not available

To measure water level ultrasound is the best option. but it is water to be measured so chances of short circuit is high,Therefore waterproof sensor is used.

In this circuit measuring ultrasound with Arduino pro mini and sending measured data to node MCU throw usart and then note MCU is sending data to local WiFi modem so the data can be monitor from anywhere using blynk mobile app.

blynk app displaying temperature and humidity and tank level

sensor is water proof and will be inside the tank facing to words water and solar power is also rain proof its terminal is near-about 5 cm apart so not possible of short circuit but remaining circuit is not waterproof they all need to be covered moreover its open area direct sunlight can overheat the components. Therefore all the circuit is sandwiched between thick thermacole plates and placed inside air tight box.

circuit are pleased on thermacole base inside box, solar and sensor wire are taken out.
circuit is Sandwiched between thermacole

THIS IS THE CODE FOR ARDUINO COPY PAST IN THE ARDUINO IDE AND INSTALL #INCLUDE LIBRARIES

// iot water level monitoring

#include <SoftwareSerial.h>
SoftwareSerial nodemcu(2,3);

#define trigpin 7 // digital pin 7 
#define echopin 6 // digital pin 6

int wpump = 13; // water pump
int flag = 0; 
int led1 = A0; 
int led2 = A1; 
int led3 = A2; 
int led4 = A3; 
int led5 = A4; 
 int duration, distance;

int firstVal;
String myString; // complete message from Arduino, which consistors of snesors data
char rdata; // received charactors
String cdata; // complete data


void setup()
{
Serial.begin(9600);
nodemcu.begin(9600);
pinMode(trigpin, OUTPUT);
pinMode(echopin, INPUT);
pinMode(wpump, OUTPUT); 
digitalWrite(wpump, LOW); 

  pinMode(led1, OUTPUT); 
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(led5, OUTPUT);

  digitalWrite(led1, LOW); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  digitalWrite(led4, LOW);
  digitalWrite(led5, LOW);
  

 delay(1000); 
}

void loop()
{

      if(nodemcu.available() == 0 )
      {
       
        ultrasonic(); 
       
      }

      if ( nodemcu.available() > 0 ) 
{

      rdata = nodemcu.read(); 
    myString = myString+ rdata; 
    //Serial.print(rdata);
    if( rdata == '\n')
    {
Serial.println(myString);
// new code
String l = getValue(myString, ',', 0);
firstVal = l.toInt(); // 


  myString = "";


            if ( (firstVal == 10)&& ( flag == 0) ) // turn off pump
            {

             digitalWrite(wpump, LOW); 
              flag = 1; 
                
            } 

                        if ( (firstVal == 11)&& ( flag == 1) ) // turn ON pump
            {

             digitalWrite(wpump, HIGH); 
              flag = 0;                
            } 

            
    }
  
}
  
}

void ultrasonic()
{

   digitalWrite(trigpin, HIGH);

delayMicroseconds(1000);  
digitalWrite(trigpin, LOW);


duration = pulseIn(echopin,HIGH);

distance = ( duration / 2) / 29.1;
Serial.println("cm:"); 
nodemcu.println(distance); // send to nodemcu module


if(  (distance > 0) && (distance <= 10)   ) 
{
  digitalWrite(led1, HIGH); 
  digitalWrite(led2, HIGH);
  digitalWrite(led3, HIGH);
  digitalWrite(led4, HIGH);
  digitalWrite(led5, HIGH); 
  
} else
if(  (distance > 10) && (distance <= 20)  ) 
{

  digitalWrite(led1, LOW); 
  digitalWrite(led2, HIGH);
  digitalWrite(led3, HIGH);
  digitalWrite(led4, HIGH);
  digitalWrite(led5, HIGH); 

} else

if(  (distance > 20) && (distance <= 30)  ) 
{

  digitalWrite(led1, LOW); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, HIGH);
  digitalWrite(led4, HIGH);
  digitalWrite(led5, HIGH);
} else

if(  (distance > 30) && (distance <= 40)  ) 
{

  digitalWrite(led1, LOW); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  digitalWrite(led4, HIGH);
  digitalWrite(led5, HIGH);
} else

if(  (distance > 50) && (distance <= 60)  ) 
{

  digitalWrite(led1, LOW); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  digitalWrite(led4, LOW);
  digitalWrite(led5, HIGH);
} else

if(  distance > 60 ) 
{

  digitalWrite(led1, LOW); 
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  digitalWrite(led4, LOW);
  digitalWrite(led5, LOW);
}
}

String getValue(String data, char separator, int index)
{
    int found = 0;
    int strIndex[] = { 0, -1 };
    int maxIndex = data.length() - 1;

    for (int i = 0; i <= maxIndex && found <= index; i++) {
        if (data.charAt(i) == separator || i == maxIndex) {
            found++;
            strIndex[0] = strIndex[1] + 1;
            strIndex[1] = (i == maxIndex) ? i+1 : i;
        }
    }
    return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
}

\/ THIS LOWER CODE IS FOR NODE MCU, JUST CHANGE WIFI USERNAME AND PASSWORD AND INSTALL LIBRARIES

#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SoftwareSerial.h>
#include <SimpleTimer.h>

int pinValue1;


String v2Arduino; // values to Arduino

char auth[] = "dfb3d11fbe874cd69ab413c8bb45f613";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "ZONG MBB-E8231-6E63";
char pass[] = "08659650";

SimpleTimer timer;

String myString; // complete message from Arduino, which consistors of snesors data
char rdata; // received charactors


int firstVal;  
// This function sends Arduino's up time every second to Virtual Pin (1).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V1, millis() / 1000);
  
}



void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);

    timer.setInterval(1000L,sensorvalue1); 

}

void loop()
{

  
  
   if (Serial.available() == 0 ) 
   {
  Blynk.run();
  timer.run(); // Initiates BlynkTimer
  toArduino();
   }
   
  if (Serial.available() > 0 ) 
  {
    rdata = Serial.read(); 
    myString = myString+ rdata; 
   // Serial.print(rdata);
    if( rdata == '\n')
    {

// new code
String l = getValue(myString, ',', 0);



firstVal = l.toInt();


  myString = "";
// end new code
    }
  }

}

void sensorvalue1()
{
int sdata = firstVal;
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V2, sdata);

}





String getValue(String data, char separator, int index)
{
    int found = 0;
    int strIndex[] = { 0, -1 };
    int maxIndex = data.length() - 1;

    for (int i = 0; i <= maxIndex && found <= index; i++) {
        if (data.charAt(i) == separator || i == maxIndex) {
            found++;
            strIndex[0] = strIndex[1] + 1;
            strIndex[1] = (i == maxIndex) ? i+1 : i;
        }
    }
    return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
}

// in Blynk app writes values to the Virtual Pin V3
BLYNK_WRITE(V10)
{
   pinValue1 = param.asInt(); // assigning incoming value from pin V10 to a variable

   if ( pinValue1 > 60 ) 
   {

    pinValue1 = 60;
   }

}


void toArduino()
{
v2Arduino = v2Arduino + pinValue1 + ","; 
Serial.println(v2Arduino); 
delay(100); 
v2Arduino = ""; 
}

Leave a Reply