Download as pdf or txt
Download as pdf or txt
You are on page 1of 33

Tank level

Indication
System
Vikas Complex Co-op Hsg Society

TANK LEVEL INDICATION SYSTEM


Vikas Complex, LBS Marg, Thane(W)-400601.
Report No:20023
Authors: Vignesh Ramakrishnan(73),Nirnay Wankhede(74),Satyam
Yadav(75),Tanmay Zope(76),Rahul Mhatre(78),Hajira Ishack(79)
Authorization: Management committee, Vikas Complex
Date: 20.09.2016
Approved by Secretary

ACKNOWLEDGEMENT
We would like to thank the managing committee of Vikas Complex for allowing
us to implement this project in their premises. We would also express
gratitude towards our professors who helped us and solved our doubts in this
project.
Last but not the least, we would like to thank the DIY research community and
open source movement for the unstinted support by developing the modules
used in this project

TABLE OF CONTENTS
ACKNOWLEDGEMENT

BUILDING SPECIFICATION

BLOCK DIAGRAM REPRESENTATION

ULTRASONIC TECHNOLOGY

MICROCONTROLLER:

10

Arduino

10

ESP8266

12

HC-SR04 ULTRASONIC SENSOR

14

WIRELESS ROUTER

16

LCD MODULE

18

PROJECT MODULARITY

19

CONCLUSION AND RECOMMENDATIONS

20

APPENDIX

21

CODE TO INTERFACE ARDUINO AND ESP8266

21

CODE TO UPDATE VALUES TO SERVER

23

CODE TO RETRIEVE DATA

25

CODE TO PROGRAM THE ULTRASONIC SENSOR

29

CODE TO PROGRAM LCD MODULE

30

BIBLIOGRAPHY

33

ABSTRACT
The main objectives satisfied by this project are:
To monitor and measure quantitatively the water content in overhead
tank placed on the terrace reducing wastage during periods of water
shortage as observed in recent years
To monitor the level of liquid, which is stored in a huge tank periodically,
and to indicate the empty level and overflow level with alarms
As the water might corrode electronic circuits, it is very difficult to
maintain the commonly used conduction/capacitance based systems,
which have direct contact with the liquid.
The main salient features of using ultrasonic sensor with wireless
transmission using wifi are:
Able to measure level without physical contact
No moving parts, so easy inspection and low maintenance cost.
Reliability of reading unaffected by changes in the composition or
density of water
Small and light, installation is easy
Precise to 1cm of water column

BUILDING SPECIFICATION

This is the specification of building.


Where the height of the building is 60m consisting of 12 floors.
The height of tank is 180 cm.
The tank is situated above the building.
But the data needs to be transferred to the security room which is located at
the ground floor of the building.
So the data is to be transferred from tank which is located far away from the
control room which is in the ground floor of the building.
For the transmission of the data one possible way is to transmit it through the
wires.
If we go for wired transmission for transmitting purpose then we require long
length wires.
We might require wires in large quantity.
The quality of the wires also matter a lot according to where the tanks are
located.
This increases the cost equally.
So wired transmission can be tedious and costly.
As the tank is located far away from the control room so long wires are
required for wiring, this is practically not possible. Also this is very expensive to
implement.
Also, the wires which are installed in the corrosive environment where actually
the tanks are located has a tendency to fail at connection point.

So we go for a wireless communication where wifi is used for application.


Wifi is very useful for this application as it can work under any weather
conditions.
This is one of the major advantage of wireless communication over wired
communication.
This application is perfect for both domestic and industrial applications.
The system is simple to install.
There is no requirement of a watchman to check the tank time to time.

BLOCK DIAGRAM REPRESENTATION

The tank of 180 cm height is placed above the 60 m building.


The tank is attached with the router which transmits wifi signal. After
transmitting the wifi the data is received in the display screen which is in the
terms of level of water indicated by the tank.

ULTRASONIC TECHNOLOGY
The human ear can hear sound frequency around 20HZ ~ 20KHZ, and ultrasonic
is the sound wave beyond the human ability of 20KHZ . Ultrasonic transmitter
emitted an ultrasonic wave in one direction, and started timing when it
launched. Ultrasonic spread in the air, and would return immediately when it
encountered obstacles on the way. At last, the ultrasonic receiver would stop
timing when it received the reflected wave. As Ultrasonic spread velocity is
340m / s in the air, based on the timer record t, we can calculate the distance
(s) between the obstacle and transmitter, namely: s = 340t / 2, which is socalled time difference distance measurement principle The principle of
ultrasonic distance measurement used the already-known air spreading
velocity, measuring the time from launch to reflection when it encountered
obstacle, and then calculate the distance between the transmitter and the
obstacle according to the time and the velocity. Thus, the principle of
ultrasonic distance measurement is the same with radar. Distance
Measurement formula is expressed as: L = C X T In the formula, L is the
measured distance, and C is the ultrasonic spreading velocity in air, also, T
represents time (T is half the time value from transmitting to receiving ).
Ultrasonic Application Technology is the thing which developed in recent
decades. With the ultrasonic advance, and the electronic technology
development, especially as high-power semiconductor device technology
matures, the application of ultrasonic has become increasingly widespread:
Ultrasonic measurement of distance, depth and thickness; Ultrasonic testing;
Ultrasound imaging; Ultrasonic machining, such as polishing, drilling;
Ultrasonic cleaning; Ultrasonic welding

Microcontroller:
Arduino
An Arduino board historically consists of an Atmel 8-, 16- or 32-bit
AVR microcontroller (although since 2015 other makers' microcontrollers have
been used) with complementary components that facilitate programming and
incorporation into other circuits. An important aspect of the Arduino is its
standard connectors, which let users connect the CPU board to a variety of
interchangeable add-on modules termed shields. Some shields communicate
with the Arduino board directly over various pins, but many shields are
individually addressable via an IC serial busso many shields can be stacked
and used in parallel. Before 2015, Official Arduinos had used the
Atmel megaAVR series of chips, specifically
the ATmega8, ATmega168, ATmega328, ATmega1280, and ATmega2560. In
2015, units by other producers were added. A handful of other processors
have also been used by Arduino compatible devices. Most boards include a 5
V linear regulator and a 16 MHz crystal oscillator (or ceramic resonator in some
variants), although some designs such as the LilyPad run at 8 MHz and
dispense with the onboard voltage regulator due to specific form-factor
restrictions. An Arduino's microcontroller is also pre-programmed with a boot
loader that simplifies uploading of programs to the on-chip flash memory,
compared with other devices that typically need an external programmer. This
makes using an Arduino more straightforward by allowing the use of an
ordinary computer as the programmer. Currently, optiboot bootloader is the
default bootloader installed on Arduino UNO.
At a conceptual level, when using the Arduino integrated development
environment, all boards are programmed over a serial connection. Its
implementation varies with the hardware version. Some serial Arduino boards
contain a level shifter circuit to convert between RS-232logic levels
and transistortransistor logic (TTL) level signals. Current Arduino boards are
programmed via Universal Serial Bus (USB), implemented using USB-to-serial
adapter chips such as the FTDI FT232. Some boards, such as later-model Uno
boards, substitute the FTDI chip with a separate AVR chip containing USB-to-

10

serial firmware, which is reprogrammable via its own ICSP header. Other
variants, such as the Arduino Mini and the unofficial Boarduino, use a
detachable USB-to-serial adapter board or cable,Bluetooth or other methods,
when used with traditional microcontroller tools instead of the Arduino IDE,
standard AVR in-system programming (ISP) programming is used. The Arduino
board exposes most of the microcontroller's I/O pins for use by other circuits.
The Diecimila, Duemilanove, and current Uno provide 14 digital I/O pins, six of
which can produce pulse-width modulated signals, and six analog inputs, which
can also be used as six digital I/O pins. These pins are on the top of the board,
via female 0.1-inch (2.54 mm) headers. Several plug-in application shields are
also commercially available. The Arduino Nano, and Arduino-compatible Bare
Bones Board and Boarduino boards may provide male header pins on the
underside of the board that can plug into solderless breadboards.
Many Arduino-compatible and Arduino-derived boards exist. Some are
functionally equivalent to an Arduino and can be used interchangeably. Many
enhance the basic Arduino by adding output drivers, often for use in schoollevel education, to simplify making buggies and small robots. Others are
electrically equivalent but change the form factor, sometimes retaining
compatibility with shields, sometimes not. Some variants use different
processors, of varying compatibility. Arduino Wifi Shields are costly. So we
interfaced arduino with ESP8266 wifi module.

11

ESP8266
ESP8266, in its default configuration, boots up into the serial modem mode. In
this mode you can communicate with it using a set of AT commands.
Features of ESP8266

802.11 b/g/n protocol

Wi-Fi 2.4 GHz, support WPA/WPA2

Super small module size (11.5mm x 11.5mm)

Integrated 10-bit ADC

Integrated TCP/IP protocol stack (ipv4 only at the moment)

Integrated TR switch, balun, LNA, power amplifier and matching network


Integrated PLL, regulators, and power management units

+20dBm output power in 802.11b mode

Supports antenna diversity

Deep sleep power <10uA, Power down leakage current < 5uA

Integrated low power 32-bit MCU

SDIO 2.0, SPI, UART, I2C

STBC, 1x1 MIMO, 2x1 MIMO

A-MPDU & A-MSDU aggregation & 0.4s guard interval

Wake up and transmit packets in < 2ms

Standby power consumption of < 1.0mW (DTIM3)

Operating temperature range -40C ~ 125C

It's a wireless SoC

It has GPIO, I2C, ADC, SPI, PWM and some more

12

It's running at 80MHz

64KBytes of instruction RAM

96KBytes of data RAM

64KBytes boot ROM

It has a Winbond W25Q40BVNIG SPI flash

It's a RISC architecture

The core is a 106micro Diamond Standard core (LX3) made


by Tensilica

The ESP8266 chip is made by Espressif

Modules bearing this chip are made by various manufacturers.


Connections are made as shown

13

HC-SR04 Ultrasonic Sensor


Ultrasonic ranging module HC - SR04 provides 2cm - 400cm non-contact
measurement function, the ranging accuracy can reach to 3mm. The modules
includes ultrasonic transmitters, receiver and control circuit. The basic
principle of work:
(1) Using IO trigger for at least 10us high level signal
(2) The Module automatically sends eight 40 kHz and detect whether there is
a pulse signal back.
(3) IF the signal back, through high level , time of high output IO duration is the
time from sending ultrasonic to returning. Test distance = (high level
time*velocity of sound (340M/S) / 2.
Set low the Trig and Echo port when the module initializes , firstly, transmit at
least 10us high level pulse to the Trig pin (module automatically sends eight
40K square wave), and then wait to capture the rising edge output by echo
port, at the same time, open the timer to start timing. Next, once again
capture the falling edge output by echo port, at the same time, read the time
of the counter, which is the ultrasonic running time in the air. According to the
formular: test distance = (high level time * ultrasonic spreading velocity in air) /
2, you can calculate the distance to the obstacle.

14

Connections are made as


shown.

15

Wireless Router
A wireless router is a device that performs the functions of a router and also
includes the functions of a wireless access point. It is used to provide access to
the Internet or a private computer network. It can function in a wired LAN
(local area network), in a wireless-only LAN (WLAN), or in a mixed
wired/wireless network, depending on the manufacturer and model.
Features[edit]
Most current wireless routers have the following characteristics:

One or multiple NICs supporting Fast Ethernet or Gigabit


Ethernet integrated into the main SoC

One or multiple WNICs supporting a part of the IEEE 802.11-standard


family also integrated into the main SoC or as separate chips on
the printed circuit board. It also can be a distinct card connected over
a MiniPCI or MiniPCIe interface.

So far the PHY-Chips for the WNICs are generally distinct chips on
the PCB. Dependent on the mode the WNIC supports, i.e. 1T1R,
2T2R or 3T3R, one WNIC have up to 3 PHY-Chips connected to it.
Each PHY-Chip is connected to a Hirose U.FL-connector on the
PCB. A so-called pigtail cable connects the Hirose U.FL either to
a RF connector, in which case the antenna can be changed or
directly to the antenna, in which case it is integrated into the
casing. Common are single-band (i.e. only for 2.4 GHz or only for
5 GHz) and dual-band (i.e. for 2.4 and 5 GHz) antennas.

Often an Ethernet switch supporting Gigabit Ethernet or Fast Ethernet,


with support for IEEE 802.1Q, integrated into the main SoC
(MediaTek SoCs) or as separate Chip on the PCB.

Some wireless routers come with


either xDSL modem, DOCSIS modem, LTE modem, or fiber optic modem
integrated.

16

IEEE 802.11n compliant or ready.

Some dual-band wireless routers operate the 2.4 GHz and 5 GHz bands
simultaneously.

Some high end dual-band wireless routers have data transfer rates of at
most 300 Mbit/s (For 2.4 GHz band) and 450 Mbit/s (For 5 GHz band).

The Wi-Fi clone button simplifies Wi-Fi configuration and builds a


seamless unified home network, enabling Super Range Extension, which
means it can automatically copy the SSID and Password of your router.

Some wireless routers have 1 or 2 USB port(s). For wireless routers


having 1 USB port, it is designated for either printer or desktop/mobile
external hard disk drive. For wireless routers having 2 USB ports, one is
designated for the printer and the other one is designated for either
desktop or mobile external hard disk drive.

Some wireless routers have a USB port specifically designed for


connecting mobile broadband modem, aside from connecting the
wireless router to an Ethernet with xDSL or cable modem. So, can be
inserted a mobile broadband USB adapter into the router to share the
mobile broadband Internet connection through the wireless network.

17

LCD Module
A liquid crystal display is a special thin flat panel that can let light go through
it, or can block the light. (Unlike an LED it does not produce its own light). The
panel is made up of several blocks, and each block can be in any shape. Each
block is filled with liquid crystals that can be made clear or solid, by changing
the electric current to that block. Liquid crystal displays are often
abbreviated LCDs.
Liquid crystal displays are often used in battery-powered devices, such as
digital watches, because they use very little electricity. They are also used for
flat screen TV's. Many LCDs work well by themselves when there is other light
around (like in a lit room, or outside in daylight). For smartphones, computer
monitor, TV's and some other purposes, a back-light is built into the product.

18

PROJECT MODULARITY
Sensor and Transmitter module: Signal is measured and transmitted
with the help of an ultrasonic sensor coupled with an Arduino
Microcontroller connected to ESP8266 wifi module.
Wireless Communication Module: Signal is wirelessly transmitted with
the help of Wifi router.
Receiver LCD Display Module: With the assistance of microcontroller,
the data is displayed on the LCD screen in terms of level of water in tank.

19

CONCLUSION AND RECOMMENDATIONS


This project can be easily extended to have a fully automated level
control system with use of control valves and pumps.
This is feasible if the customers extend a larger line of credit to the
developers
The compactness of each module can be improved by developing own
integrated chip for reduction in wiring.
Wifi connection can be made through internet for making the tank data
available online for all building residents or by using building wifi.
Overall this project is a good investment by a housing society to
safeguard its water during scarce supply.

20

APPENDIX
CODE TO INTERFACE ARDUINO AND ESP8266
1. #include <SoftwareSerial.h>
2.
3. SoftwareSerial esp8266(2,3); // make RX Arduino line is pin 2, make TX
Arduino line is pin 3.
4.

// This means that you need to connect the TX line from


the esp to the Arduino's pin 2

5.

// and the RX line from the esp to the Arduino's pin 3

6. void setup()
7. {
8. Serial.begin(9600);
9. esp8266.begin(9600); // your esp's baud rate might be different
10.}
11.
12.void loop()
13.{
14. if(esp8266.available()) // check if the esp is sending a message
15. {
16. while(esp8266.available())
17. {
18.

// The esp has data so display its output to the serial window

19.

char c = esp8266.read(); // read the next character.

21

20.

Serial.write(c);

21. }
22. }
23.
24.
25.
26. if(Serial.available())
27. {
28. // the following delay is required because otherwise the arduino will
read the first letter of the command but not the rest
29. // In other words without the delay if you use AT+RST, for example,
the Arduino will read the letter A send it, then read the rest and send it
30. // but we want to send everything at the same time.
31. delay(1000);
32.
33. String command="";
34.
35. while(Serial.available()) // read the command character by character
36. {
37.
38.

// read one character


command+=(char)Serial.read();

39. }
40. esp8266.println(command); // send the read character to the esp8266
41. }

22

42.}

CODE TO UPDATE VALUES TO SERVER


/*
To upload through terminal you can use: curl -F "image=@firmware.bin"
esp8266-webupdate.local/update
*/

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <ESP8266HTTPUpdateServer.h>

const char* host = "esp8266-webupdate";


const char* update_path = "/firmware";
const char* update_username = "admin";
const char* update_password = "admin";
const char* ssid = "........";
const char* password = "........";

ESP8266WebServer httpServer(80);
ESP8266HTTPUpdateServer httpUpdater;

void setup(void){

23

Serial.begin(115200);
Serial.println();
Serial.println("Booting Sketch...");
WiFi.mode(WIFI_AP_STA);
WiFi.begin(ssid, password);

while(WiFi.waitForConnectResult() != WL_CONNECTED){
WiFi.begin(ssid, password);
Serial.println("WiFi failed, retrying.");
}

MDNS.begin(host);

httpUpdater.setup(&httpServer, update_path, update_username,


update_password);
httpServer.begin();

MDNS.addService("http", "tcp", 80);


Serial.printf("HTTPUpdateServer ready! Open http://%s.local%s in your
browser and login with username '%s' and password '%s'\n", host,
update_path, update_username, update_password);
}

24

void loop(void){
httpServer.handleClient();
}

CODE TO RETRIEVE DATA


/*
* This sketch sends data via HTTP GET requests to data.sparkfun.com service.
*
* You need to get streamId and privateKey at data.sparkfun.com and paste
them
* below. Or just customize this script to talk to other HTTP servers.
*
*/

#include <ESP8266WiFi.h>

const char* ssid

= "your-ssid";

const char* password = "your-password";

const char* host = "server";


const char* streamId = "....................";
const char* privateKey = "....................";

void setup() {
Serial.begin(115200);

25

delay(10);

// We start by connecting to a WiFi network

Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {


delay(500);
Serial.print(".");
}

Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}

int value = 0;

26

void loop() {
delay(5000);
++value;

Serial.print("connecting to ");
Serial.println(host);

// Use WiFiClient class to create TCP connections


WiFiClient client;
const int httpPort = 80;
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
return;
}

// We now create a URI for the request


String url = "/input/";
url += streamId;
url += "?private_key=";
url += privateKey;
url += "&value=";
url += value;

27

Serial.print("Requesting URL: ");


Serial.println(url);

// This will send the request to the server


client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
unsigned long timeout = millis();
while (client.available() == 0) {
if (millis() - timeout > 5000) {
Serial.println(">>> Client Timeout !");
client.stop();
return;
}
}

// Read all the lines of the reply from server and print them to Serial
while(client.available()){
String line = client.readStringUntil('\r');
Serial.print(line);
}
Serial.println();

28

Serial.println("closing connection");}

CODE TO PROGRAM THE ULTRASONIC SENSOR


// defines pins numbers
const int trigPin = 9;
const int echoPin = 10;
// 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);
// 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

29

distance= duration*0.034/2;
// Prints the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.println(distance);}

CODE TO PROGRAM LCD MODULE


/*
LiquidCrystal Library - display() and noDisplay()

Demonstrates the use a 16x2 LCD display. The LiquidCrystal


library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface.

This sketch prints "Hello World!" to the LCD and uses the
display() and noDisplay() functions to turn on and off
the display.

The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2

30

* LCD R/W pin to ground


* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)

Library originally added 18 Apr 2008


by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe

This example code is in the public domain.

http://www.arduino.cc/en/Tutorial/LiquidCrystalDisplay

*/

// include the library code:


#include <LiquidCrystal.h>

31

// initialize the library with the numbers of the interface pins


LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
}

void loop() {
// Turn off the display:
lcd.noDisplay();
delay(500);
// Turn on the display:
lcd.display();
delay(500);
}

32

BIBLIOGRAPHY
ESP8266 Datasheet
www.arduino.cc
www.wikipedia.org
HC-SR04 Datasheet
LCD Module datasheet
www.esp8266-arduino.com
www.github.com
www.stackoverflow.com/electronics
www.instructables.com

33

You might also like