SlideShare a Scribd company logo
DEPARTMENTAL VISION & MISSION
ELECTRONICS & TELECOMMUNICATION
ENGINEERING DEPARTMENT
VISION
“Electronics & Telecommunication Department will strive to empower
students with excellent technical knowledge and practical skills
to meet the challenges of the industry and the society.”
MISSION
• To provide quality technical education through continuous faculty
training and industry institute interaction.
• To develop and create technical ambience in the department with
latest infrastructure facilities.
Project report
On
“IoT BASED WATER MANAGEMENT AND
SUPERVISION SYSTEM”
Submitted by
KAUSHIK GUPTA
Project Guide
MRS. KAVITA SINGH
DEPARTMENT OF
ELECTRONICS & TELECOMMUNICATION
ENGINEERING
ZAGDU SINGH CHARITABLE TRUST (REGD.)
THAKUR POLYTECHNIC
(An ISO 9001:2008 Certified Institute)
Thakur Complex, Next to W.E. Highway, Kandivali (E), Mumbai – 400 101.
2018-2019
PROJECT APPROVAL SHEET
This Project work entitled
IoT BASED WATER MANAGEMENT AND
SUPERVISION SYSTEM
By
KAUSHIK GUPTA
LAVESH LALWANI
SLEEVA RAJ
SURAJ JADHAV
Is approved for the award of the
DIPLOMA IN
DEPARTMENT OF
ELECTRONICS & TELECOMMUNICATION
ENGINEERING
MRS. KAVITA SINGH
Project Guide
--------------------------------- ---------------------------------
EXTERNAL EXAMINER INTERNAL EXAMINER
Affiliated to Maharashtra State Board of Technical Education
(MSBTE) Mumbai
C E R T I F I C A T E
This is to certify that
KAUSHIK GUPTA
LAVESH LALWANI
SLEEVA RAJ
SURAJ JADHAV
Have submitted this project work entitled “IoT Based Water Management
and Supervision System” is a bonafied record of project work carried out in
partial fulfilment for the award of the
DIPLOMA
IN
DEPARTMENT OF ELECTRONICS &
TELECOMMUNICATION ENGINEERING
This is a record of their own work carried out by them under our supervision and
guidance.
--------------------------------
PROJECT GUIDE
(MRS. KAVITA SINGH)
----------------------- ------------------------
H.O.D. (DEPT) PRINCIPAL
(MR. GANESH AKOLIYA) (Dr. S.M. GANECHARI)
2018-2019
1
ACKNOWLEDGEMENT
We are thankful to a number of individuals who have contributed towards our final year project and
without whose help it would not have been possible. We would like to express our deep sense of
gratitude to our Principal, Dr. S.M. Ganechari for his valuable guidance in this endeavour. We are
also highly grateful to our Head of Department, Mr. Ganesh Akoliya for his thought-provoking
comments, valuable suggestions, constant motivation, encouragement and support.
We offer our sincere thanks to our Project guide, Mrs. Kavita Singh for her constant support and
timely help and guidance throughout our preparation. Her involvement right from conceptualization
of the study through its execution and meticulous perusal of the manuscript ensured its timely
completion.
We wish to take this opportunity to render thanks towards all the Electronics and
Telecommunication Engineering faculty at Thakur Polytechnic for their help and encouragement
towards making this project successful. Heartfelt thanks to our family for their unconditional support
and last but not the least our friends and colleagues for their help and cooperation.
Mumbai, February 2019.
Thanking you,
Kaushik Gupta
Lavesh Lalwani
Sleeva Raj
Suraj Jadhav
2
ABSTRACT
Water resource management is becoming increasingly important. We've built a system that senses
the water levels in a tank, calls you when water levels are too low, and allows you to remotely refill
from a reserve.
This project focuses on monitoring of use of water, consider, by one block of house in a flat system,
where at the partition of pipeline from where gets diverted to various part of a block. This paper
presents an IOT device which helps to manage and plan the usage of water. This system can be
easily installed in residential societies. Sensors placed in the tank which continuously informs the
water level at the current time. This information will be updated on the cloud and using an android
application, user can visualize the water level on a smartphone anywhere that is connected to
Internet. According to the level of water in the tank the motor functioning will be automatically
controlled at low level of water motor will automatically turn on and when tank is about to fill up it
will cut off.
3
INDEX
SR NO. CONTENTS PAGE NO.
1. INTRODUCTION 4
2. BLOCK DIAGRAM 5
3. CIRCUIT DIAGRAM 6
4. EXPLANATION OF PROJECT COMPONENTS 7
5. FIRMWARE REQUIRED 19
6. PROGRAM 21
7. ADVANTAGES 37
8. LIMITATIONS 37
9. PROGRAMMING WIFI MODULE 38
10. CONCLUSION 39
11.
PROBLEMS FACED DURING THE MAKING OF
THE PROJECT 40
12. REFERENCES 41
13. PICTURES RELATED TO THE PROJECT 42
4
1.INTRODUCTION
Nearly the third quarterly portion of the earth which estimates up to 71 % portion of it is covered
with water. But out of which only 0.08% fresh water is available for human purposes and for living
beings the main sources of fresh water available for living purposes and for human use is the surface
water available as a result of rainfall which also recharges the lakes, different water resources like
aquifers Water scarcity is the problem faced by the Living creatures throughout the history and
whose intensity has increased during the last centenary It's estimated by next decade approximately
25% of the population of earth will live in perpetual scarcity of water It's a well- known fact that
physical factors affect the availability of water which is the culmination of the rainfall received by
that area due to number of geographical reasons. But it is also well documented fact that human
intervention is also affecting this factor which leads to unseasonal as well as in abnormal proportion
of water fall and as a result the priorities of the available water changes drastically. Improvements /
applications to appraise the IOT based water management, it can be ramified as diligent, frugal for
water management in a symbiotic panty way. Which will constrict the water resource evenly
according to the in-situ factors. According to scientists and organizations as Intergovernmental Panel
on Climate Change state has come, since a long lime. Where water management as such implies to
maximizing use of water and minimizing the wastage of water and thus preventing the domino effect
cycle arises as wastage of water. The sensors will sense the flow of water to each pipe which
ultimately tells the usage of water at one block readily.
This water usage data would be sent to cloud using the IOT space. This cloud data would be
sent to the concern resident's person's mobile app reporting the water used and altering the user to
limit the water use if it gets extended to the limit usage set by municipal government or corporation
If the limit gets extended the user have to pay accordingly. This will be real time operation. The
objective of doing so is for limiting and minimizing the usage of water for an average of per person.
And secondly, the cloud data will be used as statistic data for use of water at every season that is
winter, summer and monsoon so that measuring steps for water management can be taken with the
appropriate statistics. Yielding an avenue for predictive measure Improvements/Applications to
appraise the IOT based water management. It can be ramified as diligent, frugal for water
management in a symbiotic panty way, which will constrict the water resource evenly according to
the in-situ factors.
5
2.BLOCK DIAGRAM
6
3.CIRCUIT DIAGRAM
7
4.EXPLAINATION OF COMPONENTS
LIST OF COMPONENTS
Sr.
No.
Components Value Quantity
1 Node MCU Wi-Fi development board ESP8266 1
2
Ultrasonic / Sonar Distance measuring
Sensor
HC – SR04 1
3 5V Relay REES52 1
4 Resistors
470Ω 1
1k Ω 1
10k Ω 1
4.7k Ω 1
5 Voltage Regulator 7805 IC 1
6 Step Down Transformer 6 Volts 1
7 Electrolytic Capacitor
0.01uF / 50V 1
2.5uF / 50V 1
470uF / 50V 1
100uF / 50V 1
8 Diodes 1N4007 4
9 Transistor BC548 1
10 LED 2V 4
8
Node MCU Wi-Fi development board
NodeMCU is an open source IoT platform. It includes firmware which runs on the ESP8266 Wi-
Fi SoC from Espressif Systems, and hardware which is based on the ESP-12 module. The term
"Node MCU" by default refers to the firmware rather than the development kits. The firmware uses
the Lua scripting language. It is based on the eLua project, and built on the Espressif Non-OS SDK
for ESP8266. It uses many open source projects, such as lua-cjson and SPIFFS. The ESP8266 is a
Wi-Fi SoC integrated with a Tensilica Xtensa LX106 core, widely used in IoT applications.
It can be programmed directly through USB port using LUA programming or Arduino IDE. By
simple programming we can establish a Wi-Fi connection and define input/output pins according to
your needs exactly like Arduino, turning into a web server and a lot more.
NodeMCU is the Wi-Fi equivalent of ethernet module. It combines the features of Wi-Fi access point
and station + microcontroller. These features make the NodeMCU extremely powerful tool for Wi-Fi
networking. It can be used as access point and/or station, host a web server or connect to internet to
fetch or upload data.
9
Features
• Finally, programable WiFi module.
• Arduino-like (software defined) hardware IO.
• Can be programmed with the simple and powerful Lua programming language or
Arduino IDE.
• USB-TTL included, plug & play.
• 10 GPIOs D0-D10, PWM functionality, IIC and SPI communication, 1-Wire and
ADC A0 etc. all in one board.
• Wi-Fi networking (can be used as access point and/or station, host a web server),
connect to internet to fetch or upload data.
• Event-driven API for network applications.
• PCB antenna.
Specifications.
Memory: 128kBytes
Developer: ESP8266 Open source Community
Operating system: XTOS
Storage: 4MBytes
CPU: ESP8266(LX106)
Power: USB
10
I/O
index
ESP8266
pin
0 [*] GPIO16
1 GPIO5
2 GPIO4
3 GPIO0
4 GPIO2
5 GPIO14
6 GPIO12
7 GPIO13
8 GPIO15
9 GPIO3
10 GPIO1
11 GPIO9
12 GPIO10
11
Ultrasonic / Sonar Distance measuring Sensor
The Ultrasonic Sensor HC-SR04 is one of the most commonly used distance measuring
ultrasonic sensors and works extremely well with Arduino.
An ultrasonic sensor is an instrument that measures the distance to an object using ultrasonic
sound waves. It uses a transducer to send and receive ultrasonic pulses that relay back
information about an object’s proximity. High-frequency sound waves reflect from
boundaries to produce distinct echo patterns.
Ultrasound is reliable in any lighting environment and can be used inside or
outside. Ultrasonic sensors can handle collision avoidance for a robot, and being moved
often, as long as it isn’t too fast.
Ultrasonic Sensors are so widely used, they can be reliably implemented in grain bin sensing
applications, water level sensing, drone applications and sensing cars at your local drive-thru
restaurant or bank.
12
Technical Specs:
Ultrasonic Sensor HC-SR04
Operating Voltage: 5V
Static current: 2mA max
Induction Angle: 15°
Detection Range: 2 – 200cm
High precision up to 3mm
Pins:
This module has 4 pins- VCC (5V), Trig, Echo, GND. Trig (trigger) is used to send out an
ultrasonic high-level pulse for at least 10μs and the Echo pin then automatically detects the
returning pulse.
Measuring Distance:
The time it takes the sound wave to be sent, hit the object and return back to the sensor is
measured. This time is then multiplied by the speed of sound (343m/sec = 0.0343cm/μs =
[1/29.1] cm/μs approx.) to give the total distance travelled by the ultrasonic wave, which is
then divided by 2 (to account for the fact that the wave was sent, hit the object, and then
returned back to the sensor, hence covering twice the distance to the object)
Distance = (Time for wave to return * Speed of sound) / 2.
13
NodeMCU Usage:
This sensor module uses 2 digital pins (D1 and D2 ) on the NodeMCU for Trig and Echo,
and does not necessarily have to be pins 1 and 2. The code for measuring distance
with NodeMCU is given as:
// Generic Code for the working of UltraSonic Sensor connected to the NodeMcu (used in
the project)
// defines pins numbers
const int trigPin = 2; //D4
const int echoPin = 0; //D3
// defines variables
long duration;
int distance;
void setup () {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Serial.begin(9600); // Starts the serial communication
}
void loop() {
// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
14
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance= duration*0.034/2;
// Prints the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.println(distance);
delay(2000);
}
15
5Volts Relay
A relay is nothing more than a remote switch that uses an electromagnet to close a set of
contact points. Relays are often used in circuits to reduce the current that flows through the
primary control switch. A relatively low amperage switch, timer, or sensor can be used to
turn a much higher capacity relay on and off. As relay diagrams show, when a relay contact
is normally open (NO), there is an open contact when the relay is not energized. The other
side has three low voltage pins (Ground, VCC, and Signal) which connect to the Arduino.
Inside the relay is a 120-240V switch that's connected to an electromagnet. When the relay
receives a HIGH signal at the signal pin, the electromagnet becomes charged and moves the
contacts of the switch open or closed.
This is a 5V 4-channel relay interface board, and each channel needs a 15-20mA driver
current. It can be used to control various appliances and equipment with large current. It is
16
equipped with high-current relays that work under AC250V 10A or DC30V 10A. It has a
standard interface that can be controlled directly by microcontroller.
Principle
When the signal port is at low level, the signal light will light up and the opt coupler 817c (it
transforms electrical signals by light and can isolate input and output electrical signals) will
conduct, and then the transistor will conduct, the relay coil will be electrified, and the
normally open contact of the relay will be closed. When the signal port is at high level, the
normally closed contact of the relay will be closed. So you can connect and disconnect the
load by controlling the level of the control signal port.
Features:
• Size: 75mm (Length) * 55mm (Width) * 19.3mm (Height)
• Weight: 61g
• PCB Colour: Blue
• There are four fixed screw holes at each corner of the board, easy for install and fix.
The diameter of the hole is 3.1mm
• High quality Single relay is used with single pole double throw, a common terminal, a
normally open terminal, and a normally closed terminal
• Optical coupling isolation, good anti-interference.
• Closed at low level with indicator on, released at high level with indicator off
• VCC is system power source, and JD_VCC is relay power source. Ship 5V relay by
default. Plug jumper cap to use
• The maximum output of the relay: DC 30V/10A, AC 250V/10A
17
Code:
if(liters<=waterLevelLowerThreshold)
waterLevelDownCount++;
else waterLevelDownCount=0;
if(liters>=waterLevelUpperThreshold)
waterLevelUpCount++;
else waterLevelUpCount=0;
waterLevel.publish(liters);
if(waterLevelDownCount==2)
{
//TURN ON RELAY
Serial.println("motor turned on");
digitalWrite(MOTOR_CONTROL_PIN,LOW);//Relay is active LOW
}
if(waterLevelUpCount==5)
{
//TURN OFF RELAY
Serial.println("motor turned off");
digitalWrite(MOTOR_CONTROL_PIN,HIGH);//Relay is active HIGH
}
}
18
void runPeriodicFunc()
{
static const unsigned long REFRESH_INTERVAL1 = 1000; // 1sec
static unsigned long lastRefreshTime1 = 0;
if(millis() - lastRefreshTime1 >= REFRESH_INTERVAL1)
{
measure_Volume();
lastRefreshTime1 = millis();
}
}
19
5.FIRMWARE REQUIRED
For the following project, you use Arduino IDE to program the NodeMcu, to interface with
other components and successfully work. Let’s get into the details for the same.
The industry-standard Keil C Compilers, Macro Assemblers, Debuggers, Real-time Kernels,
Single-board Computers, and Emulators support all 8051 derivatives are used for the
following project.
Keil is a German based Software development company. It provides several development
tools like
• IDE (Integrated Development environment)
• Project Manager
• Simulator
20
• Debugger
• C Cross Compiler , Cross Assembler, Locator/Linker
Keil Software provides with software development tools for the 8051 family of
microcontrollers. With these tools, you can generate embedded applications for the multitude
of 8051 derivatives. Keil provides following tools for 8051 development
1. C51 Optimizing C Cross Compiler,
2. A51 Macro Assembler,
3. 8051 Utilities (linker, object file converter, library manager),
4. Source-Level Debugger/Simulator,
5. µVision for Windows Integrated Development Environment.
The Keil 8051 tool kit includes three main tools, assembler, compiler and linker.
An assembler is used to assemble your 8051 assembly program
A compiler is used to compile your C source code into an object file
A linker is used to create an absolute object module suitable for your in-circuit emulator.
8051 project development cycle: - these are the steps to develop 8051 project using keil
1. Create source files in C or assembly.
2. Compile or assemble source files.
3. Correct errors in source files.
4. Link object files from compiler and assembler.
5. Test linked application.
21
6.PROGRAM
#include <ESP8266WiFi.h>
#include <HCSR04.h>
#include <ESP8266WebServer.h>
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
const char index_html[] PROGMEM={"<!DOCTYPE html>n"
"<html>n"
"<head>n"
"<title>IoT Based WMSS</title>n"
"<script type="text/javascript"
src="http://static.fusioncharts.com/code/latest/fusioncharts.js"></script>n"
"<script type="text/javascript"
src="http://static.fusioncharts.com/code/latest/themes/fusioncharts.theme.fint.js?cacheBust=56"></
script>n"
"<script src="https://cdnjs.cloudflare.com/ajax/libs/zepto/1.2.0/zepto.min.js"></script>n"
"<script src="https://simeydotme.github.io/jQuery-ui-Slider-Pips/dist/js/jquery-plus-
ui.min.js"></script>n"
"<script src="https://simeydotme.github.io/jQuery-ui-Slider-Pips/dist/js/jquery-ui-slider-
pips.js"></script>n"
"<link rel="stylesheet" href="https://simeydotme.github.io/jQuery-ui-Slider-
Pips/dist/css/jqueryui.min.css">n"
22
"<link rel="stylesheet" href="https://simeydotme.github.io/jQuery-ui-Slider-Pips/dist/css/jquery-
ui-slider-pips.min.css">n"
"<link rel="stylesheet" href="https://simeydotme.github.io/jQuery-ui-Slider-
Pips/dist/css/app.min.css">n"
"<style>n"
".raphael-group-7-background rect {n"
"fill: rgb(218, 218, 218) !important;n"
"}n"
"[id*=flat-slider].ui-slider.ui-slider-vertical {n"
"theight: 220px;n"
"tmargin-top: 90px;n"
" margin-right: 15%;n"
" margin-bottom: 90px;n"
" margin-left: 15%;n"
"}n"
"$bg: #434d5a;n"
"[id*=flat-slider].ui-slider,n"
"[id*=flat-slider].ui-slider .ui-slider-pip .ui-slider-line {n"
" background: lighten($bg, 15%);n"
"}n"
"[id*=flat-slider].ui-slider .ui-slider-handle .ui-slider-tip:after {n"
" border-left-color: #434d5a;n"
"}n"
23
"[id*=flat-slider].ui-slider .ui-slider-handle.ui-state-hover, n"
"[id*=flat-slider].ui-slider .ui-slider-handle.ui-state-focus, n"
"[id*=flat-slider].ui-slider .ui-slider-handle.ui-state-active {n"
" border-color: white; }n"
"body {n"
"background-image:
url("https://drive.google.com/uc?id=1wzmcOg69BzaMNBezx7QgP1rjLyqNbpv1");n"
" n"
" font-family: "Roboto";n"
"}n"
".stuff { n"
" padding: 10px 5px 5px;n"
" max-width: 150px; n"
"tmax-height: 550px; n"
"}n"
"div.inline { float:left; }n"
".clearBoth { clear:both; }n"
"n"
"</style>n"
"<script>n"
"$(document).ready(function() {n"
" setInterval("get_motor_status()", 2000);n"
" });n"
24
"ttttn"
" function get_motor_status() {n"
" var someUrl = "/motor_status";n"
" $.ajax({url: someUrl,dataType: "text",success: function(response) {n"
" if (response == "on")n"
" $("#status").html("Motor ON")n"
" elsen"
" $("#status").html("Motor OFF")n"
" }})}ttn"
"ttttn"
" </script>n"
"tn"
"<script type="text/javascript">n"
" FusionCharts.ready(function(){n"
" var fusioncharts = new FusionCharts({n"
" "type": "cylinder",n"
" "dataFormat": "json",n"
" "id": "fuelMeter",n"
" "renderAt": "chart-container",n"
" "width": "200",n"
" "height": "350",n"
" "dataSource": {n"
" "chart": {n"
25
" "theme": "fint",n"
" "caption": "Water Level in Tank",n"
" "subcaption": "at Home",n"
" "lowerLimit": "0",n"
" "upperLimit": "6.96",n"
" "lowerLimitDisplay": "Empty",n"
" "upperLimitDisplay": "Full",n"
" "numberSuffix": " ltrs",n"
" "showValue": "1",n"
" "chartBottomMargin": "25"n"
" },n"
" "value": "10"n"
" },n"
" "events": {n"
" "rendered": function(evtObj, argObj) {n"
"tsetInterval(function() {n"
"tvar someUrl = "/level";n"
"ttttt$.ajax({n"
"tttttturl: someUrl,n"
"ttttttdataType: "text",n"
"ttttttsuccess: function(response) {n"
"ttttttt evtObj.sender.feedData("&value=" + response);n"
"tttttt},n"
26
"tttttttimeout: 2000n"
"ttttt})tn"
"ttn"
" }, 1000); n"
" }n"
"}n"
"});n"
" fusioncharts.render();n"
" });n"
"</script>n"
"</head>n"
"<body>n"
"<div style="width:600px;margin:auto;">n"
"n"
"<div class="stuff">n"
" n"
" <main> n"
" <div class="inline" id="flat-slider-vertical-1"></div> n"
" </main>n"
" n"
"</div>n"
" <div style="margin-left: 10px;" class="inline" id="chart-container">FusionCharts XT will
load here!</div>n"
27
"t<div class="inline" id="status" style="background-color: lightgrey;n"
" width: 100px;n"
" border: 10px solid;n"
"tborder-color: coral;n"
" padding: 2px;n"
" margin: 1px;">Motor OFF</div>n"
" </div>n"
"n"
"<script>n"
"$.extend( $.ui.slider.prototype.options, { n"
" animate: 300n"
"});n"
"n"
"n"
"$("#flat-slider-vertical-1")n"
" .slider({n"
" max: 6.96,n"
" min: 0,n"
" range: true,n"
" values: [2, 5],n"
" orientation: "vertical",n"
"ttn"
"ttslide: function( event, ui ) {n"
28
"ttconsole.log(ui.values);n"
"ttvar someUrl = "/configRange?lower=" + ui.values[0]+"&upper="+ui.values[1];n"
" $.ajax(n"
"ttt{n"
"tttturl: someUrl,dataType: "text",success: function(response) {}n"
"ttt}) n"
" }n"
" })n"
" .slider("pips", {n"
" first: "pip",n"
" last: "pip"n"
" })n"
" .slider("float");n"
"</script>n"
"n"
"t</body>n"
"</html>"
};
//create new adafruit IO feed and name it as 'waterLevel'
//uncomment these two lines and write your wifi ssid/password
const char* ssid = "TP-LINK_E4C6";
const char* password = "91527516";
//also uncomment and write here your own adafruit IO username and key.
29
#define AIO_USERNAME "kaushikgupta"
#define AIO_KEY "32df83ee9d4e42f1a1716e3ccdc15ccb"
//uncomment these lines as well, write radius of tank and total height in units of inches,
#define RADIUS 3
#define MAX_HEIGHT 15
//modify this line if you have to connect relay to some pin other than D4
#define MOTOR_CONTROL_PIN D4
//Connect trig of ultrasonic sensor at D1 and echo at D2, modify this line otherwise
UltraSonicDistanceSensor distanceSensor(D1,D2); //D1 trig, D2=echo
//these are default water level limits, these values will be applied on reset until user sends new limits
from webpage.
int waterLevelLowerThreshold=2;
int waterLevelUpperThreshold=5;
#define AIO_SERVER "io.adafruit.com"
#define AIO_SERVERPORT 1883 // use 8883 for SSL
float volume;
float liters;
// Create an ESP8266 WiFiClient class to connect to the MQTT server.
WiFiClient client;
// or... use WiFiFlientSecure for SSL
//WiFiClientSecure client;
30
// Setup the MQTT client class by passing in the WiFi client and MQTT server and login details.
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME,
AIO_KEY);
Adafruit_MQTT_Publish waterLevel = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME
"/feeds/waterLevel");
Adafruit_MQTT_Subscribe onoff = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME
"/feeds/onoff");
/*************************** Sketch Code ************************************/
void MQTT_connect();
String inputString = ""; // a string to hold incoming data
String dataToSend="";
int waterLevelDownCount=0,waterLevelUpCount=0;
ESP8266WebServer server(80);
void handleRoot() {
server.send_P(200, "text/html;charset=UTF-8", index_html);
}
void handleLevelRequest(){
server.send(200,"text",String(liters));
}
void handleNotFound(){
String message = "File Not Foundnn";
31
server.send(404, "text/plain", message);
}
void handleStatus()
{
if(digitalRead(MOTOR_CONTROL_PIN)==0)//MOTOR ON
server.send(200, "text/plain","on");
else server.send(200, "text/plain","off");
}
void handleRangeSetting(){
waterLevelLowerThreshold=(server.arg(0)).toInt();
waterLevelUpperThreshold=(server.arg(1)).toInt();
Serial.print(waterLevelLowerThreshold);
Serial.print(":");
Serial.println(waterLevelUpperThreshold);
server.send(200, "text/plain", "");
}
void measure_Volume()
{
float heightInch=0.393701*distanceSensor.measureDistanceCm();
Serial.println(heightInch);
if(heightInch>MAX_HEIGHT)
32
heightInch=MAX_HEIGHT;
if(heightInch<0)
heightInch=0;
volume=3.14*RADIUS*RADIUS*(MAX_HEIGHT-heightInch);//MAX_HEIGHT-distance will
give actual height,
liters=volume*0.0164 ;
Serial.println(liters);
if(liters<=waterLevelLowerThreshold)
waterLevelDownCount++;
else waterLevelDownCount=0;
if(liters>=waterLevelUpperThreshold)
waterLevelUpCount++;
else waterLevelUpCount=0;
waterLevel.publish(liters);
if(waterLevelDownCount==2)
{//TURN ON RELAY
Serial.println("motor turned on");
digitalWrite(MOTOR_CONTROL_PIN,LOW);//Relay is active LOW
}
33
if(waterLevelUpCount==5)
{//TURN OFF RELAY
Serial.println("motor turned off");
digitalWrite(MOTOR_CONTROL_PIN,HIGH);//Relay is active HIGH
}
}
void runPeriodicFunc()
{
static const unsigned long REFRESH_INTERVAL1 = 1000; // 1sec
static unsigned long lastRefreshTime1 = 0;
if(millis() - lastRefreshTime1 >= REFRESH_INTERVAL1)
{
measure_Volume();
lastRefreshTime1 = millis();
}
}
void MQTT_connect() {
int8_t ret;
// Stop if already connected.
if (mqtt.connected()) {
34
return;
}
Serial.print("Connecting to MQTT... ");
while ((ret = mqtt.connect()) != 0) { // connect will return 0 for connected
Serial.println(mqtt.connectErrorString(ret));
Serial.println("Retrying MQTT connection in 5 seconds...");
mqtt.disconnect();
delay(5000); // wait 5 seconds
}
Serial.println("MQTT Connected!");
}
void setup(void){
Serial.begin(115200);
delay(100);
pinMode(MOTOR_CONTROL_PIN, OUTPUT);
WiFi.begin(ssid, password);
Serial.println("");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
35
Serial.print(".");
}
Serial.print("IP address:");
Serial.println(WiFi.localIP());
server.on("/", handleRoot);
server.on("/level",handleLevelRequest);
server.on("/configRange",handleRangeSetting);
server.on("/motor_status",handleStatus);
server.onNotFound(handleNotFound);
server.begin();
Serial.println("HTTP server started");
mqtt.subscribe(&onoff);
}
void loop(){
runPeriodicFunc();
Adafruit_MQTT_Subscribe * subscription;
while ((subscription = mqtt.readSubscription(5000)))
{
//If we're in here, a subscription updated...
if (subscription == &onoff)
36
{
//Print the new value to the serial monitor
Serial.print("onoff: ");
Serial.println((char*) onoff.lastread);
//If the new value is "ON", turn the light on.
//Otherwise, turn it off.
if (!strcmp((char*) onoff.lastread, "ON"))
{
//active low logic
digitalWrite(D4, LOW);
}
else
{
digitalWrite(D4, HIGH);
}
}}
MQTT_connect();
server.handleClient();
}
37
7.ADVANTAGES
• Can be controlled from anywhere in the world.
• Beneficial for both Rural and Urban Areas.
• Helpful in saving water. (using Water flow Sensor)
• Easier to compute water consumption.
• Helpful to cease water overflow.
• Saves electricity in long run.
• Easy to install and operate.
• Bugs can be fixed and systems updates are easy
8.LIMITATIONS
• Cannot be operated without an internet connection.
• Periodic maintenance of the connected sensors.
• Only 1 user can operate the system (via app) at a time.
• Limited UX Design.
38
9.FUTURE SCOPE
• Can also be used in irrigation systems with few modifications.
• Helpful to detect water theft.
• We may include location data, water quality, temperature, humidity and various other
factors.
• Similarly, GPS shield can be integrated in the system to obtain location data of the
water source dynamically.
• Can be integrated with Prime Minister’s Smart Village Initiative.
39
10. CONCLUSION
This IoT based proposed system is used to acquire water level and water consumption details
of a water source in real time from any location, any device connected to Internet. This water
level data can be used for various purposes for better management of water source.
Monitoring water level from remote location may be very useful when it is not possible to
visit location physically every time. The system can be implemented for different sources of
water by replacing sensor device suitable for the condition. In future, the proposed system
can be used to monitor and analyse water usage of the specific water source thus require
developing such logic for the application. The system can also be used to collect and study
the environmental data of water source and its surrounding area by integrating other sensor to
the system. The study may include location data, water quality, temperature, humidity and
various other factors. For example, Arduino GPS shield can be integrated in the system to
obtain location data of the water source dynamically. Similarly, Ethernet shield can also be
replaced with Wi-Fi shield/module for wireless connectivity if required. Concluding the
proposed IoT based water level monitoring system will be helpful to collect, analyse and
predict the water level detail, water usage and other information of particular water source at
particular location in real-time remotely.
40
11. PROBLEMS FACED DURING THE MAKING OF
THE PROJECT
• To add the manual on-off control of motor (with also having the autonomous feature
enabled) in the same program was a bit difficult to do.
• To integrate all circuity in one module (PCB) was the main task to do and designing
of the PCB was initially a little confusion.
• The calibration of the ultrasonic sensor for the water tank was difficult
• Our project is based on water, it was necessary to make sure that the complete setup is
water tight and no leakages occur. We had to fix some leakage points, throughout the
making of the project.
41
12. REFERENCES
While making this project, we referred to several books, technical magazines, websites and
visited some technical exhibitions. We have listed these references below:
• Institute of Electrical and Electronics Engineers.
• Sakthipriya, N.: An Effective Method for Crop Monitoring Using Wireless Sensor
Network, Journal of Scientific Research.
• Arduino liquid level indicator tutorial, https://goo.gl/fQMjDg.
• Arduino official software downloads.
• adafruit.io
• lastminuteengineers.com
• instructables.com
42
13. PICTURES RELATED TO THE
PROJECT
43
44
(Left) Motor turns ON as water level is
low in the tank. Water tank starts filling.
(Below) A water in the tank reaches the
upper threshold limit (when water is full
in the tank) the motor automatically turns
off.

More Related Content

PPT
PPTX
Introduction to myanmar Text-To-Speech
PDF
Healthcare Monitoring Using Wireless Sensor Networks
PPTX
3d passwords
KEY
Green IT Concept
PPTX
Security issues and attacks in wireless sensor networks
PDF
Collaborating Using Cloud Services
PPTX
energy efficient unicast
Introduction to myanmar Text-To-Speech
Healthcare Monitoring Using Wireless Sensor Networks
3d passwords
Green IT Concept
Security issues and attacks in wireless sensor networks
Collaborating Using Cloud Services
energy efficient unicast

What's hot (20)

PDF
Chronic Kidney Disease Prediction Using Machine Learning
PPTX
Using prior knowledge to initialize the hypothesis,kbann
PPTX
Autobahn primer
PPT
Cloud Computing: The Green Grid
PPTX
Energy consumption of wsn
PDF
Forest Fire Detection Using Deep Learning and Image Recognition
PDF
Federated Cloud Computing - The OpenNebula Experience v1.0s
PDF
Intoduction to TinyOS, nesC and TOSSIM
PDF
Internet of medical things (IOMT)
PPTX
Advanced Wireless Technologies
PPTX
Unit 4 ec8702 - ad hoc and wireless sensor networks unit -4 mr.darwin nesaku...
PPT
Ieee slide format
PPTX
SENSOR NETWORK PLATFORMS AND TOOLS
PPTX
Graphical password authentication system with association of sound
PPTX
Schedule and Contention based MAC protocols
PDF
OIT552 Cloud Computing - Question Bank
PDF
IRJET- Crop Yield Prediction based on Climatic Parameters
PPTX
Basics of Wireless sensor networks
PDF
Crop Yield Prediction using Machine Learning
Chronic Kidney Disease Prediction Using Machine Learning
Using prior knowledge to initialize the hypothesis,kbann
Autobahn primer
Cloud Computing: The Green Grid
Energy consumption of wsn
Forest Fire Detection Using Deep Learning and Image Recognition
Federated Cloud Computing - The OpenNebula Experience v1.0s
Intoduction to TinyOS, nesC and TOSSIM
Internet of medical things (IOMT)
Advanced Wireless Technologies
Unit 4 ec8702 - ad hoc and wireless sensor networks unit -4 mr.darwin nesaku...
Ieee slide format
SENSOR NETWORK PLATFORMS AND TOOLS
Graphical password authentication system with association of sound
Schedule and Contention based MAC protocols
OIT552 Cloud Computing - Question Bank
IRJET- Crop Yield Prediction based on Climatic Parameters
Basics of Wireless sensor networks
Crop Yield Prediction using Machine Learning
Ad

Similar to IoT Based Water Management and Supervision System (20)

PDF
Water Supply Measurement and Management System Based on IoT with Water Leakag...
PDF
IRJET- Smart Water Meter Reading and Distribution
PDF
IRJET- Smart Water Management
PDF
Dam Water Monitoring System Using IOT
DOCX
Batch--7 Smart meter for liquid flow monitoring and leakage detection system ...
PDF
IRJET- Automated Household Water Monitoring and Billing System
PDF
IRJET- IoT based Smart Water Manangement System
PDF
IRJET- Smart Water Monitoring System using IoT
PDF
Intelligent_water_flow_monitoring_system_based_on_ (1).pdf
PDF
IRJET- IoT based Water Management System using Arduino
PDF
IRJET- Automated Water Conservation and Theft Detection using IOT
PDF
IOT BASED RIVER WATER QUALITY MONITORING SYSTEM USING NODE MCU
PDF
IRJET-Smart and Automatic Water Distribution Control System
PDF
IRJET- Digital Water Management and Automatic Bill Generation System
PDF
IRJET- Water Management System using IoT with WSN
PDF
SOC Module for IOT Based Smart Water Monitoring
PDF
IRJET - Water Monitoring System – IoT
PPTX
Automation Water Dispenser for there........
PDF
IRJET- Water Level Monitoring System in Water Dispensers using Iot
PPTX
Smart irrigation system
Water Supply Measurement and Management System Based on IoT with Water Leakag...
IRJET- Smart Water Meter Reading and Distribution
IRJET- Smart Water Management
Dam Water Monitoring System Using IOT
Batch--7 Smart meter for liquid flow monitoring and leakage detection system ...
IRJET- Automated Household Water Monitoring and Billing System
IRJET- IoT based Smart Water Manangement System
IRJET- Smart Water Monitoring System using IoT
Intelligent_water_flow_monitoring_system_based_on_ (1).pdf
IRJET- IoT based Water Management System using Arduino
IRJET- Automated Water Conservation and Theft Detection using IOT
IOT BASED RIVER WATER QUALITY MONITORING SYSTEM USING NODE MCU
IRJET-Smart and Automatic Water Distribution Control System
IRJET- Digital Water Management and Automatic Bill Generation System
IRJET- Water Management System using IoT with WSN
SOC Module for IOT Based Smart Water Monitoring
IRJET - Water Monitoring System – IoT
Automation Water Dispenser for there........
IRJET- Water Level Monitoring System in Water Dispensers using Iot
Smart irrigation system
Ad

Recently uploaded (20)

PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
Geodesy 1.pptx...............................................
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
Digital Logic Computer Design lecture notes
PPTX
Construction Project Organization Group 2.pptx
PPTX
Welding lecture in detail for understanding
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
OOP with Java - Java Introduction (Basics)
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
Sustainable Sites - Green Building Construction
PPT
Project quality management in manufacturing
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Geodesy 1.pptx...............................................
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Foundation to blockchain - A guide to Blockchain Tech
bas. eng. economics group 4 presentation 1.pptx
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Digital Logic Computer Design lecture notes
Construction Project Organization Group 2.pptx
Welding lecture in detail for understanding
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
OOP with Java - Java Introduction (Basics)
R24 SURVEYING LAB MANUAL for civil enggi
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Lecture Notes Electrical Wiring System Components
Sustainable Sites - Green Building Construction
Project quality management in manufacturing

IoT Based Water Management and Supervision System

  • 1. DEPARTMENTAL VISION & MISSION ELECTRONICS & TELECOMMUNICATION ENGINEERING DEPARTMENT VISION “Electronics & Telecommunication Department will strive to empower students with excellent technical knowledge and practical skills to meet the challenges of the industry and the society.” MISSION • To provide quality technical education through continuous faculty training and industry institute interaction. • To develop and create technical ambience in the department with latest infrastructure facilities.
  • 2. Project report On “IoT BASED WATER MANAGEMENT AND SUPERVISION SYSTEM” Submitted by KAUSHIK GUPTA Project Guide MRS. KAVITA SINGH DEPARTMENT OF ELECTRONICS & TELECOMMUNICATION ENGINEERING ZAGDU SINGH CHARITABLE TRUST (REGD.) THAKUR POLYTECHNIC (An ISO 9001:2008 Certified Institute) Thakur Complex, Next to W.E. Highway, Kandivali (E), Mumbai – 400 101. 2018-2019
  • 3. PROJECT APPROVAL SHEET This Project work entitled IoT BASED WATER MANAGEMENT AND SUPERVISION SYSTEM By KAUSHIK GUPTA LAVESH LALWANI SLEEVA RAJ SURAJ JADHAV Is approved for the award of the DIPLOMA IN DEPARTMENT OF ELECTRONICS & TELECOMMUNICATION ENGINEERING MRS. KAVITA SINGH Project Guide --------------------------------- --------------------------------- EXTERNAL EXAMINER INTERNAL EXAMINER
  • 4. Affiliated to Maharashtra State Board of Technical Education (MSBTE) Mumbai C E R T I F I C A T E This is to certify that KAUSHIK GUPTA LAVESH LALWANI SLEEVA RAJ SURAJ JADHAV Have submitted this project work entitled “IoT Based Water Management and Supervision System” is a bonafied record of project work carried out in partial fulfilment for the award of the DIPLOMA IN DEPARTMENT OF ELECTRONICS & TELECOMMUNICATION ENGINEERING This is a record of their own work carried out by them under our supervision and guidance. -------------------------------- PROJECT GUIDE (MRS. KAVITA SINGH) ----------------------- ------------------------ H.O.D. (DEPT) PRINCIPAL (MR. GANESH AKOLIYA) (Dr. S.M. GANECHARI) 2018-2019
  • 5. 1 ACKNOWLEDGEMENT We are thankful to a number of individuals who have contributed towards our final year project and without whose help it would not have been possible. We would like to express our deep sense of gratitude to our Principal, Dr. S.M. Ganechari for his valuable guidance in this endeavour. We are also highly grateful to our Head of Department, Mr. Ganesh Akoliya for his thought-provoking comments, valuable suggestions, constant motivation, encouragement and support. We offer our sincere thanks to our Project guide, Mrs. Kavita Singh for her constant support and timely help and guidance throughout our preparation. Her involvement right from conceptualization of the study through its execution and meticulous perusal of the manuscript ensured its timely completion. We wish to take this opportunity to render thanks towards all the Electronics and Telecommunication Engineering faculty at Thakur Polytechnic for their help and encouragement towards making this project successful. Heartfelt thanks to our family for their unconditional support and last but not the least our friends and colleagues for their help and cooperation. Mumbai, February 2019. Thanking you, Kaushik Gupta Lavesh Lalwani Sleeva Raj Suraj Jadhav
  • 6. 2 ABSTRACT Water resource management is becoming increasingly important. We've built a system that senses the water levels in a tank, calls you when water levels are too low, and allows you to remotely refill from a reserve. This project focuses on monitoring of use of water, consider, by one block of house in a flat system, where at the partition of pipeline from where gets diverted to various part of a block. This paper presents an IOT device which helps to manage and plan the usage of water. This system can be easily installed in residential societies. Sensors placed in the tank which continuously informs the water level at the current time. This information will be updated on the cloud and using an android application, user can visualize the water level on a smartphone anywhere that is connected to Internet. According to the level of water in the tank the motor functioning will be automatically controlled at low level of water motor will automatically turn on and when tank is about to fill up it will cut off.
  • 7. 3 INDEX SR NO. CONTENTS PAGE NO. 1. INTRODUCTION 4 2. BLOCK DIAGRAM 5 3. CIRCUIT DIAGRAM 6 4. EXPLANATION OF PROJECT COMPONENTS 7 5. FIRMWARE REQUIRED 19 6. PROGRAM 21 7. ADVANTAGES 37 8. LIMITATIONS 37 9. PROGRAMMING WIFI MODULE 38 10. CONCLUSION 39 11. PROBLEMS FACED DURING THE MAKING OF THE PROJECT 40 12. REFERENCES 41 13. PICTURES RELATED TO THE PROJECT 42
  • 8. 4 1.INTRODUCTION Nearly the third quarterly portion of the earth which estimates up to 71 % portion of it is covered with water. But out of which only 0.08% fresh water is available for human purposes and for living beings the main sources of fresh water available for living purposes and for human use is the surface water available as a result of rainfall which also recharges the lakes, different water resources like aquifers Water scarcity is the problem faced by the Living creatures throughout the history and whose intensity has increased during the last centenary It's estimated by next decade approximately 25% of the population of earth will live in perpetual scarcity of water It's a well- known fact that physical factors affect the availability of water which is the culmination of the rainfall received by that area due to number of geographical reasons. But it is also well documented fact that human intervention is also affecting this factor which leads to unseasonal as well as in abnormal proportion of water fall and as a result the priorities of the available water changes drastically. Improvements / applications to appraise the IOT based water management, it can be ramified as diligent, frugal for water management in a symbiotic panty way. Which will constrict the water resource evenly according to the in-situ factors. According to scientists and organizations as Intergovernmental Panel on Climate Change state has come, since a long lime. Where water management as such implies to maximizing use of water and minimizing the wastage of water and thus preventing the domino effect cycle arises as wastage of water. The sensors will sense the flow of water to each pipe which ultimately tells the usage of water at one block readily. This water usage data would be sent to cloud using the IOT space. This cloud data would be sent to the concern resident's person's mobile app reporting the water used and altering the user to limit the water use if it gets extended to the limit usage set by municipal government or corporation If the limit gets extended the user have to pay accordingly. This will be real time operation. The objective of doing so is for limiting and minimizing the usage of water for an average of per person. And secondly, the cloud data will be used as statistic data for use of water at every season that is winter, summer and monsoon so that measuring steps for water management can be taken with the appropriate statistics. Yielding an avenue for predictive measure Improvements/Applications to appraise the IOT based water management. It can be ramified as diligent, frugal for water management in a symbiotic panty way, which will constrict the water resource evenly according to the in-situ factors.
  • 11. 7 4.EXPLAINATION OF COMPONENTS LIST OF COMPONENTS Sr. No. Components Value Quantity 1 Node MCU Wi-Fi development board ESP8266 1 2 Ultrasonic / Sonar Distance measuring Sensor HC – SR04 1 3 5V Relay REES52 1 4 Resistors 470Ω 1 1k Ω 1 10k Ω 1 4.7k Ω 1 5 Voltage Regulator 7805 IC 1 6 Step Down Transformer 6 Volts 1 7 Electrolytic Capacitor 0.01uF / 50V 1 2.5uF / 50V 1 470uF / 50V 1 100uF / 50V 1 8 Diodes 1N4007 4 9 Transistor BC548 1 10 LED 2V 4
  • 12. 8 Node MCU Wi-Fi development board NodeMCU is an open source IoT platform. It includes firmware which runs on the ESP8266 Wi- Fi SoC from Espressif Systems, and hardware which is based on the ESP-12 module. The term "Node MCU" by default refers to the firmware rather than the development kits. The firmware uses the Lua scripting language. It is based on the eLua project, and built on the Espressif Non-OS SDK for ESP8266. It uses many open source projects, such as lua-cjson and SPIFFS. The ESP8266 is a Wi-Fi SoC integrated with a Tensilica Xtensa LX106 core, widely used in IoT applications. It can be programmed directly through USB port using LUA programming or Arduino IDE. By simple programming we can establish a Wi-Fi connection and define input/output pins according to your needs exactly like Arduino, turning into a web server and a lot more. NodeMCU is the Wi-Fi equivalent of ethernet module. It combines the features of Wi-Fi access point and station + microcontroller. These features make the NodeMCU extremely powerful tool for Wi-Fi networking. It can be used as access point and/or station, host a web server or connect to internet to fetch or upload data.
  • 13. 9 Features • Finally, programable WiFi module. • Arduino-like (software defined) hardware IO. • Can be programmed with the simple and powerful Lua programming language or Arduino IDE. • USB-TTL included, plug & play. • 10 GPIOs D0-D10, PWM functionality, IIC and SPI communication, 1-Wire and ADC A0 etc. all in one board. • Wi-Fi networking (can be used as access point and/or station, host a web server), connect to internet to fetch or upload data. • Event-driven API for network applications. • PCB antenna. Specifications. Memory: 128kBytes Developer: ESP8266 Open source Community Operating system: XTOS Storage: 4MBytes CPU: ESP8266(LX106) Power: USB
  • 14. 10 I/O index ESP8266 pin 0 [*] GPIO16 1 GPIO5 2 GPIO4 3 GPIO0 4 GPIO2 5 GPIO14 6 GPIO12 7 GPIO13 8 GPIO15 9 GPIO3 10 GPIO1 11 GPIO9 12 GPIO10
  • 15. 11 Ultrasonic / Sonar Distance measuring Sensor The Ultrasonic Sensor HC-SR04 is one of the most commonly used distance measuring ultrasonic sensors and works extremely well with Arduino. An ultrasonic sensor is an instrument that measures the distance to an object using ultrasonic sound waves. It uses a transducer to send and receive ultrasonic pulses that relay back information about an object’s proximity. High-frequency sound waves reflect from boundaries to produce distinct echo patterns. Ultrasound is reliable in any lighting environment and can be used inside or outside. Ultrasonic sensors can handle collision avoidance for a robot, and being moved often, as long as it isn’t too fast. Ultrasonic Sensors are so widely used, they can be reliably implemented in grain bin sensing applications, water level sensing, drone applications and sensing cars at your local drive-thru restaurant or bank.
  • 16. 12 Technical Specs: Ultrasonic Sensor HC-SR04 Operating Voltage: 5V Static current: 2mA max Induction Angle: 15° Detection Range: 2 – 200cm High precision up to 3mm Pins: This module has 4 pins- VCC (5V), Trig, Echo, GND. Trig (trigger) is used to send out an ultrasonic high-level pulse for at least 10μs and the Echo pin then automatically detects the returning pulse. Measuring Distance: The time it takes the sound wave to be sent, hit the object and return back to the sensor is measured. This time is then multiplied by the speed of sound (343m/sec = 0.0343cm/μs = [1/29.1] cm/μs approx.) to give the total distance travelled by the ultrasonic wave, which is then divided by 2 (to account for the fact that the wave was sent, hit the object, and then returned back to the sensor, hence covering twice the distance to the object) Distance = (Time for wave to return * Speed of sound) / 2.
  • 17. 13 NodeMCU Usage: This sensor module uses 2 digital pins (D1 and D2 ) on the NodeMCU for Trig and Echo, and does not necessarily have to be pins 1 and 2. The code for measuring distance with NodeMCU is given as: // Generic Code for the working of UltraSonic Sensor connected to the NodeMcu (used in the project) // defines pins numbers const int trigPin = 2; //D4 const int echoPin = 0; //D3 // defines variables long duration; int distance; void setup () { pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output pinMode(echoPin, INPUT); // Sets the echoPin as an Input Serial.begin(9600); // Starts the serial communication } void loop() { // Clears the trigPin digitalWrite(trigPin, LOW); delayMicroseconds(2);
  • 18. 14 // Sets the trigPin on HIGH state for 10 micro seconds digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); // Reads the echoPin, returns the sound wave travel time in microseconds duration = pulseIn(echoPin, HIGH); // Calculating the distance distance= duration*0.034/2; // Prints the distance on the Serial Monitor Serial.print("Distance: "); Serial.println(distance); delay(2000); }
  • 19. 15 5Volts Relay A relay is nothing more than a remote switch that uses an electromagnet to close a set of contact points. Relays are often used in circuits to reduce the current that flows through the primary control switch. A relatively low amperage switch, timer, or sensor can be used to turn a much higher capacity relay on and off. As relay diagrams show, when a relay contact is normally open (NO), there is an open contact when the relay is not energized. The other side has three low voltage pins (Ground, VCC, and Signal) which connect to the Arduino. Inside the relay is a 120-240V switch that's connected to an electromagnet. When the relay receives a HIGH signal at the signal pin, the electromagnet becomes charged and moves the contacts of the switch open or closed. This is a 5V 4-channel relay interface board, and each channel needs a 15-20mA driver current. It can be used to control various appliances and equipment with large current. It is
  • 20. 16 equipped with high-current relays that work under AC250V 10A or DC30V 10A. It has a standard interface that can be controlled directly by microcontroller. Principle When the signal port is at low level, the signal light will light up and the opt coupler 817c (it transforms electrical signals by light and can isolate input and output electrical signals) will conduct, and then the transistor will conduct, the relay coil will be electrified, and the normally open contact of the relay will be closed. When the signal port is at high level, the normally closed contact of the relay will be closed. So you can connect and disconnect the load by controlling the level of the control signal port. Features: • Size: 75mm (Length) * 55mm (Width) * 19.3mm (Height) • Weight: 61g • PCB Colour: Blue • There are four fixed screw holes at each corner of the board, easy for install and fix. The diameter of the hole is 3.1mm • High quality Single relay is used with single pole double throw, a common terminal, a normally open terminal, and a normally closed terminal • Optical coupling isolation, good anti-interference. • Closed at low level with indicator on, released at high level with indicator off • VCC is system power source, and JD_VCC is relay power source. Ship 5V relay by default. Plug jumper cap to use • The maximum output of the relay: DC 30V/10A, AC 250V/10A
  • 21. 17 Code: if(liters<=waterLevelLowerThreshold) waterLevelDownCount++; else waterLevelDownCount=0; if(liters>=waterLevelUpperThreshold) waterLevelUpCount++; else waterLevelUpCount=0; waterLevel.publish(liters); if(waterLevelDownCount==2) { //TURN ON RELAY Serial.println("motor turned on"); digitalWrite(MOTOR_CONTROL_PIN,LOW);//Relay is active LOW } if(waterLevelUpCount==5) { //TURN OFF RELAY Serial.println("motor turned off"); digitalWrite(MOTOR_CONTROL_PIN,HIGH);//Relay is active HIGH } }
  • 22. 18 void runPeriodicFunc() { static const unsigned long REFRESH_INTERVAL1 = 1000; // 1sec static unsigned long lastRefreshTime1 = 0; if(millis() - lastRefreshTime1 >= REFRESH_INTERVAL1) { measure_Volume(); lastRefreshTime1 = millis(); } }
  • 23. 19 5.FIRMWARE REQUIRED For the following project, you use Arduino IDE to program the NodeMcu, to interface with other components and successfully work. Let’s get into the details for the same. The industry-standard Keil C Compilers, Macro Assemblers, Debuggers, Real-time Kernels, Single-board Computers, and Emulators support all 8051 derivatives are used for the following project. Keil is a German based Software development company. It provides several development tools like • IDE (Integrated Development environment) • Project Manager • Simulator
  • 24. 20 • Debugger • C Cross Compiler , Cross Assembler, Locator/Linker Keil Software provides with software development tools for the 8051 family of microcontrollers. With these tools, you can generate embedded applications for the multitude of 8051 derivatives. Keil provides following tools for 8051 development 1. C51 Optimizing C Cross Compiler, 2. A51 Macro Assembler, 3. 8051 Utilities (linker, object file converter, library manager), 4. Source-Level Debugger/Simulator, 5. µVision for Windows Integrated Development Environment. The Keil 8051 tool kit includes three main tools, assembler, compiler and linker. An assembler is used to assemble your 8051 assembly program A compiler is used to compile your C source code into an object file A linker is used to create an absolute object module suitable for your in-circuit emulator. 8051 project development cycle: - these are the steps to develop 8051 project using keil 1. Create source files in C or assembly. 2. Compile or assemble source files. 3. Correct errors in source files. 4. Link object files from compiler and assembler. 5. Test linked application.
  • 25. 21 6.PROGRAM #include <ESP8266WiFi.h> #include <HCSR04.h> #include <ESP8266WebServer.h> #include "Adafruit_MQTT.h" #include "Adafruit_MQTT_Client.h" const char index_html[] PROGMEM={"<!DOCTYPE html>n" "<html>n" "<head>n" "<title>IoT Based WMSS</title>n" "<script type="text/javascript" src="http://static.fusioncharts.com/code/latest/fusioncharts.js"></script>n" "<script type="text/javascript" src="http://static.fusioncharts.com/code/latest/themes/fusioncharts.theme.fint.js?cacheBust=56"></ script>n" "<script src="https://cdnjs.cloudflare.com/ajax/libs/zepto/1.2.0/zepto.min.js"></script>n" "<script src="https://simeydotme.github.io/jQuery-ui-Slider-Pips/dist/js/jquery-plus- ui.min.js"></script>n" "<script src="https://simeydotme.github.io/jQuery-ui-Slider-Pips/dist/js/jquery-ui-slider- pips.js"></script>n" "<link rel="stylesheet" href="https://simeydotme.github.io/jQuery-ui-Slider- Pips/dist/css/jqueryui.min.css">n"
  • 26. 22 "<link rel="stylesheet" href="https://simeydotme.github.io/jQuery-ui-Slider-Pips/dist/css/jquery- ui-slider-pips.min.css">n" "<link rel="stylesheet" href="https://simeydotme.github.io/jQuery-ui-Slider- Pips/dist/css/app.min.css">n" "<style>n" ".raphael-group-7-background rect {n" "fill: rgb(218, 218, 218) !important;n" "}n" "[id*=flat-slider].ui-slider.ui-slider-vertical {n" "theight: 220px;n" "tmargin-top: 90px;n" " margin-right: 15%;n" " margin-bottom: 90px;n" " margin-left: 15%;n" "}n" "$bg: #434d5a;n" "[id*=flat-slider].ui-slider,n" "[id*=flat-slider].ui-slider .ui-slider-pip .ui-slider-line {n" " background: lighten($bg, 15%);n" "}n" "[id*=flat-slider].ui-slider .ui-slider-handle .ui-slider-tip:after {n" " border-left-color: #434d5a;n" "}n"
  • 27. 23 "[id*=flat-slider].ui-slider .ui-slider-handle.ui-state-hover, n" "[id*=flat-slider].ui-slider .ui-slider-handle.ui-state-focus, n" "[id*=flat-slider].ui-slider .ui-slider-handle.ui-state-active {n" " border-color: white; }n" "body {n" "background-image: url("https://drive.google.com/uc?id=1wzmcOg69BzaMNBezx7QgP1rjLyqNbpv1");n" " n" " font-family: "Roboto";n" "}n" ".stuff { n" " padding: 10px 5px 5px;n" " max-width: 150px; n" "tmax-height: 550px; n" "}n" "div.inline { float:left; }n" ".clearBoth { clear:both; }n" "n" "</style>n" "<script>n" "$(document).ready(function() {n" " setInterval("get_motor_status()", 2000);n" " });n"
  • 28. 24 "ttttn" " function get_motor_status() {n" " var someUrl = "/motor_status";n" " $.ajax({url: someUrl,dataType: "text",success: function(response) {n" " if (response == "on")n" " $("#status").html("Motor ON")n" " elsen" " $("#status").html("Motor OFF")n" " }})}ttn" "ttttn" " </script>n" "tn" "<script type="text/javascript">n" " FusionCharts.ready(function(){n" " var fusioncharts = new FusionCharts({n" " "type": "cylinder",n" " "dataFormat": "json",n" " "id": "fuelMeter",n" " "renderAt": "chart-container",n" " "width": "200",n" " "height": "350",n" " "dataSource": {n" " "chart": {n"
  • 29. 25 " "theme": "fint",n" " "caption": "Water Level in Tank",n" " "subcaption": "at Home",n" " "lowerLimit": "0",n" " "upperLimit": "6.96",n" " "lowerLimitDisplay": "Empty",n" " "upperLimitDisplay": "Full",n" " "numberSuffix": " ltrs",n" " "showValue": "1",n" " "chartBottomMargin": "25"n" " },n" " "value": "10"n" " },n" " "events": {n" " "rendered": function(evtObj, argObj) {n" "tsetInterval(function() {n" "tvar someUrl = "/level";n" "ttttt$.ajax({n" "tttttturl: someUrl,n" "ttttttdataType: "text",n" "ttttttsuccess: function(response) {n" "ttttttt evtObj.sender.feedData("&value=" + response);n" "tttttt},n"
  • 30. 26 "tttttttimeout: 2000n" "ttttt})tn" "ttn" " }, 1000); n" " }n" "}n" "});n" " fusioncharts.render();n" " });n" "</script>n" "</head>n" "<body>n" "<div style="width:600px;margin:auto;">n" "n" "<div class="stuff">n" " n" " <main> n" " <div class="inline" id="flat-slider-vertical-1"></div> n" " </main>n" " n" "</div>n" " <div style="margin-left: 10px;" class="inline" id="chart-container">FusionCharts XT will load here!</div>n"
  • 31. 27 "t<div class="inline" id="status" style="background-color: lightgrey;n" " width: 100px;n" " border: 10px solid;n" "tborder-color: coral;n" " padding: 2px;n" " margin: 1px;">Motor OFF</div>n" " </div>n" "n" "<script>n" "$.extend( $.ui.slider.prototype.options, { n" " animate: 300n" "});n" "n" "n" "$("#flat-slider-vertical-1")n" " .slider({n" " max: 6.96,n" " min: 0,n" " range: true,n" " values: [2, 5],n" " orientation: "vertical",n" "ttn" "ttslide: function( event, ui ) {n"
  • 32. 28 "ttconsole.log(ui.values);n" "ttvar someUrl = "/configRange?lower=" + ui.values[0]+"&upper="+ui.values[1];n" " $.ajax(n" "ttt{n" "tttturl: someUrl,dataType: "text",success: function(response) {}n" "ttt}) n" " }n" " })n" " .slider("pips", {n" " first: "pip",n" " last: "pip"n" " })n" " .slider("float");n" "</script>n" "n" "t</body>n" "</html>" }; //create new adafruit IO feed and name it as 'waterLevel' //uncomment these two lines and write your wifi ssid/password const char* ssid = "TP-LINK_E4C6"; const char* password = "91527516"; //also uncomment and write here your own adafruit IO username and key.
  • 33. 29 #define AIO_USERNAME "kaushikgupta" #define AIO_KEY "32df83ee9d4e42f1a1716e3ccdc15ccb" //uncomment these lines as well, write radius of tank and total height in units of inches, #define RADIUS 3 #define MAX_HEIGHT 15 //modify this line if you have to connect relay to some pin other than D4 #define MOTOR_CONTROL_PIN D4 //Connect trig of ultrasonic sensor at D1 and echo at D2, modify this line otherwise UltraSonicDistanceSensor distanceSensor(D1,D2); //D1 trig, D2=echo //these are default water level limits, these values will be applied on reset until user sends new limits from webpage. int waterLevelLowerThreshold=2; int waterLevelUpperThreshold=5; #define AIO_SERVER "io.adafruit.com" #define AIO_SERVERPORT 1883 // use 8883 for SSL float volume; float liters; // Create an ESP8266 WiFiClient class to connect to the MQTT server. WiFiClient client; // or... use WiFiFlientSecure for SSL //WiFiClientSecure client;
  • 34. 30 // Setup the MQTT client class by passing in the WiFi client and MQTT server and login details. Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY); Adafruit_MQTT_Publish waterLevel = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/waterLevel"); Adafruit_MQTT_Subscribe onoff = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME "/feeds/onoff"); /*************************** Sketch Code ************************************/ void MQTT_connect(); String inputString = ""; // a string to hold incoming data String dataToSend=""; int waterLevelDownCount=0,waterLevelUpCount=0; ESP8266WebServer server(80); void handleRoot() { server.send_P(200, "text/html;charset=UTF-8", index_html); } void handleLevelRequest(){ server.send(200,"text",String(liters)); } void handleNotFound(){ String message = "File Not Foundnn";
  • 35. 31 server.send(404, "text/plain", message); } void handleStatus() { if(digitalRead(MOTOR_CONTROL_PIN)==0)//MOTOR ON server.send(200, "text/plain","on"); else server.send(200, "text/plain","off"); } void handleRangeSetting(){ waterLevelLowerThreshold=(server.arg(0)).toInt(); waterLevelUpperThreshold=(server.arg(1)).toInt(); Serial.print(waterLevelLowerThreshold); Serial.print(":"); Serial.println(waterLevelUpperThreshold); server.send(200, "text/plain", ""); } void measure_Volume() { float heightInch=0.393701*distanceSensor.measureDistanceCm(); Serial.println(heightInch); if(heightInch>MAX_HEIGHT)
  • 36. 32 heightInch=MAX_HEIGHT; if(heightInch<0) heightInch=0; volume=3.14*RADIUS*RADIUS*(MAX_HEIGHT-heightInch);//MAX_HEIGHT-distance will give actual height, liters=volume*0.0164 ; Serial.println(liters); if(liters<=waterLevelLowerThreshold) waterLevelDownCount++; else waterLevelDownCount=0; if(liters>=waterLevelUpperThreshold) waterLevelUpCount++; else waterLevelUpCount=0; waterLevel.publish(liters); if(waterLevelDownCount==2) {//TURN ON RELAY Serial.println("motor turned on"); digitalWrite(MOTOR_CONTROL_PIN,LOW);//Relay is active LOW }
  • 37. 33 if(waterLevelUpCount==5) {//TURN OFF RELAY Serial.println("motor turned off"); digitalWrite(MOTOR_CONTROL_PIN,HIGH);//Relay is active HIGH } } void runPeriodicFunc() { static const unsigned long REFRESH_INTERVAL1 = 1000; // 1sec static unsigned long lastRefreshTime1 = 0; if(millis() - lastRefreshTime1 >= REFRESH_INTERVAL1) { measure_Volume(); lastRefreshTime1 = millis(); } } void MQTT_connect() { int8_t ret; // Stop if already connected. if (mqtt.connected()) {
  • 38. 34 return; } Serial.print("Connecting to MQTT... "); while ((ret = mqtt.connect()) != 0) { // connect will return 0 for connected Serial.println(mqtt.connectErrorString(ret)); Serial.println("Retrying MQTT connection in 5 seconds..."); mqtt.disconnect(); delay(5000); // wait 5 seconds } Serial.println("MQTT Connected!"); } void setup(void){ Serial.begin(115200); delay(100); pinMode(MOTOR_CONTROL_PIN, OUTPUT); WiFi.begin(ssid, password); Serial.println(""); while (WiFi.status() != WL_CONNECTED) { delay(500);
  • 39. 35 Serial.print("."); } Serial.print("IP address:"); Serial.println(WiFi.localIP()); server.on("/", handleRoot); server.on("/level",handleLevelRequest); server.on("/configRange",handleRangeSetting); server.on("/motor_status",handleStatus); server.onNotFound(handleNotFound); server.begin(); Serial.println("HTTP server started"); mqtt.subscribe(&onoff); } void loop(){ runPeriodicFunc(); Adafruit_MQTT_Subscribe * subscription; while ((subscription = mqtt.readSubscription(5000))) { //If we're in here, a subscription updated... if (subscription == &onoff)
  • 40. 36 { //Print the new value to the serial monitor Serial.print("onoff: "); Serial.println((char*) onoff.lastread); //If the new value is "ON", turn the light on. //Otherwise, turn it off. if (!strcmp((char*) onoff.lastread, "ON")) { //active low logic digitalWrite(D4, LOW); } else { digitalWrite(D4, HIGH); } }} MQTT_connect(); server.handleClient(); }
  • 41. 37 7.ADVANTAGES • Can be controlled from anywhere in the world. • Beneficial for both Rural and Urban Areas. • Helpful in saving water. (using Water flow Sensor) • Easier to compute water consumption. • Helpful to cease water overflow. • Saves electricity in long run. • Easy to install and operate. • Bugs can be fixed and systems updates are easy 8.LIMITATIONS • Cannot be operated without an internet connection. • Periodic maintenance of the connected sensors. • Only 1 user can operate the system (via app) at a time. • Limited UX Design.
  • 42. 38 9.FUTURE SCOPE • Can also be used in irrigation systems with few modifications. • Helpful to detect water theft. • We may include location data, water quality, temperature, humidity and various other factors. • Similarly, GPS shield can be integrated in the system to obtain location data of the water source dynamically. • Can be integrated with Prime Minister’s Smart Village Initiative.
  • 43. 39 10. CONCLUSION This IoT based proposed system is used to acquire water level and water consumption details of a water source in real time from any location, any device connected to Internet. This water level data can be used for various purposes for better management of water source. Monitoring water level from remote location may be very useful when it is not possible to visit location physically every time. The system can be implemented for different sources of water by replacing sensor device suitable for the condition. In future, the proposed system can be used to monitor and analyse water usage of the specific water source thus require developing such logic for the application. The system can also be used to collect and study the environmental data of water source and its surrounding area by integrating other sensor to the system. The study may include location data, water quality, temperature, humidity and various other factors. For example, Arduino GPS shield can be integrated in the system to obtain location data of the water source dynamically. Similarly, Ethernet shield can also be replaced with Wi-Fi shield/module for wireless connectivity if required. Concluding the proposed IoT based water level monitoring system will be helpful to collect, analyse and predict the water level detail, water usage and other information of particular water source at particular location in real-time remotely.
  • 44. 40 11. PROBLEMS FACED DURING THE MAKING OF THE PROJECT • To add the manual on-off control of motor (with also having the autonomous feature enabled) in the same program was a bit difficult to do. • To integrate all circuity in one module (PCB) was the main task to do and designing of the PCB was initially a little confusion. • The calibration of the ultrasonic sensor for the water tank was difficult • Our project is based on water, it was necessary to make sure that the complete setup is water tight and no leakages occur. We had to fix some leakage points, throughout the making of the project.
  • 45. 41 12. REFERENCES While making this project, we referred to several books, technical magazines, websites and visited some technical exhibitions. We have listed these references below: • Institute of Electrical and Electronics Engineers. • Sakthipriya, N.: An Effective Method for Crop Monitoring Using Wireless Sensor Network, Journal of Scientific Research. • Arduino liquid level indicator tutorial, https://goo.gl/fQMjDg. • Arduino official software downloads. • adafruit.io • lastminuteengineers.com • instructables.com
  • 46. 42 13. PICTURES RELATED TO THE PROJECT
  • 47. 43
  • 48. 44 (Left) Motor turns ON as water level is low in the tank. Water tank starts filling. (Below) A water in the tank reaches the upper threshold limit (when water is full in the tank) the motor automatically turns off.