Real Time Water Quality Monitoring Through Iot

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 71

REAL TIME WATER QUALITY MONITORING THROUGH IOT

REAL TIME WATER QUALITY MONITORING

THROUGH IOT

A project Report

Submitted in Fulfilment of the Award of the Degree of Bachelor of technology in

ELECTRONICS AND COMMUNICATION ENGINEERING

SUBMITTED BY

Y.LASYA (12951A0417)

D.DEEKSHA (12951A0407)

B.SRIKANTH (12951A0451)

K.MANOJ (12951A0420)

Under the guidance of

S LAKSHMANACHARI

ASSISTANT PROFESSOR

Department of Electronics and Communication Engineering

INSTITUTE OF AERONAUTICAL ENGINEERING

DUNDIGAL500-043, HYDERABAD, TELANGANA STATE

1|Page
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

APRIL-2016

INSTITUTE OF AERONAUTICAL ENGINEERING


Dundigal,Qutubullapur (Mandal), Hyderabad. Pin- 500043 Telangana, India
Ph: 08418-257181/182 Fax: 08418-257202 Email:info@iare.ac.in

CERTIFICATE
This is to certify that the project work entitled “SMART CARD BASED PETRO CARD
MANAGING SYSTEM ”submitted as partial fulfilment for the award of Bachelor of
Technology degree in Electronic And Communication Engineering from Institute Of
Aeronautical Engineering, affiliated with Jawaharlal Nehru Technological University,
Hyderabad, is a record of bonafide work done during the academic year 2015 by

Y.LASYA (12951A0417)

D.DEEKSHA (12951A0407)

B.SRIKANTH (12951A0451)

K.MANOJ (12951A0420)

MR.S.LAKSHMANACHARI PROF.V.R.SESHAGIRI RAASSISTANT


PROFESSOR HEAD OF DEPARTMENT ECE

2|Page
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

ACKNOWLEDGEMENT

This project brings with a sense of satisfaction, but it is never complete without
thanking those people who made it possible and whose constant support has crowned my
efforts with success.

We would also like to thank my guide, S.LAKSHMANACHARI, Assistant


Professor of Electronics and communication engineering, for his expert guidance,
encouragement and valuable suggestions at every step. Without his incredible support and
steady involvement the project would not have been fruitful.

We are thankful to the principal of college Prof. A.BARAI, head of the department
(ECE) V.R.SESHAGIRI RAO at INSTITUTE OF AERONAUTICAL ENGINEERING
College for supporting us.

We are also thankful to all the Lecturers and staff members of Electronics and
Communication Engineering Department for providing me with required facilities and
support towards the completion of the project.

We are extremely happy to acknowledge and express my sincere gratitude to my


parents for their constant support and encouragement and last but not the least, friends and
well-wishers for their help for cooperation and solutions to problems during the completion
of project.

3|Page
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

DECLARATION

We hereby declare that this submission is own work and that, to the best of my knowledge
and belief, it contains no material previously published or written by another person nor
material which to a substantial extend has been accepted for the award of the award of any
other degree or diploma of the university or other institute of the higher leaning except where
due acknowledgement has been made in the text.

Y.LASYA (12951A0417)

D.DEEKSHA (12951A0407)

B.SRIKANTH (12951A0451)

K.MANOJ (12951A0420)

4|Page
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

ABSTRACT
Nowadays drinking water is the most precious and valuable for all the human beings,
drinking water utilities faces new challenges in real-time operation. This challenge occurred
because of limited water resources growing population, ageing infrastructure etc. Hence
therefore there is a need of better methodologies for monitoring the water quality.
Traditional methods of water quality involve the manual collection of water sample at
different locations, followed by laboratory analytical techniques in order the character the
water quality. Such approaches take longer time and no longer to be considered efficient .
Although the current methodologies analysis the physical, chemical and biological agents, it
has several drawbacks: a) poor spatiotemporal coverage b) it is labor intensive and high
cost(labor, operation; and equipment) c)the lack of real time water quality information to
enable critical decisions for public health protection. Therefore, there is a need for continuous
online water quality monitoring.
The online water monitoring technologies have made a significant progress for source
water surveillance and water plant operation. The use of their technologies having high cost
associated with installation and calibration of a large distributed array of monitoring sensors.
The algorithm proposed on the new technology must be suitable for particular area and for
large system is not suitable.
By focusing on the above issues our paper design and develop a low cost system for
real time monitoring of the water quality in IOT environment. In our design ARM-7 is used
as a core controller. The design system applies a specialized IOT module for accessing sensor
data from core controller to the mobile. The sensor data can be viewed on the mobile using a
special IP address. Additionally the IOT module also provides a Wi-Fi for viewing the data
on mobile.

5|Page
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

CONTENTS PAGE NO

1. Introduction 10
1.1Embedded system 10
1.2 Microcontroller versus Microprocessor 11
1.3 Microprocessor 12
1.3.1 Features 13
2. Function description 14
2.1 LPC2148 Microcontroller 14
2.1.1 Features 14
2.1.2 Pin Configuration 16
2.1.3 Pin description 16
3. Circuit description 24
3.1 Block diagram 24
3.2 Circuit diagram 26
3.3 Components description 27
3.3.1 LPC2148 Microcontroller 27
3.3.2 Power supply circuit 24
3.3.3 Regulated power supply 27
3.3.4 Temperature sensor 32
3.3.5 pH sensor 33
3.3.6 Level sensor 34
3.3.7 MAX232 35
3.3.8 ESP8266 Wi-Fi module 36
3.3.9 LCD 38
3.3.10 Buzzer 41
4. Implementation 43
4.1 Introduction 43
4.2 Working 43
5. Software designing
5.1 Software tools required 45
5.2 Flow chart 43

6|Page
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

6. Results analysis conclusion and future scope 44


6.1Simulation result 44
6.2 Applications 44
6.3 Conclusion 45
6.4 Future scope 45
REFERENCES 46

APPENDICES 47
Source code

7|Page
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

LIST OF FIGURES

FIGURE.NO FIGURE NAME PAGE.NO


1.1 Block diagram of 13
Microprocessor
2.1 LPC2148 IC 14
2.2 Architecture of ARM-7 16
2.3 Pin Configuration 17
3.1 Block diagram 25
3.2 Circuit Diagram 27
3.3 Power Supply Circuit 28
3.4 Mutual Induction Of Transformer 29
3.5 Step Down Transformer 29
3.6 Bridge Rectifier Circuit 30
3.7 Filter Circuit 30
3.8 7805 Voltage Regulator 31
3.9 LM317 IC 32
3.10 Temperature Sensor 34
3.11 pH Sensor 35

3.12 Level Sensor 36

3.13 IC MAX 232 37


3.14 Wi-Fi Module 38
3.15 LCD Display 40

3.16 Buzzer 42
4.1 Output of Water Quality Parameters 45
5.1 ARM device Programmer 49
5.2 Proload Programmer Device 50
6.1 Output using Keil-microvision3 51

CHAPTER-1

INTRODUCTION
1.1 EMBEDDED SYSTEMS:

8|Page
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

An embedded system is a special-purpose computer system designed to perform one


or a few dedicated functions, sometimes with real-time computing constraints. It is usually
embedded as part of a complete device including hardware and mechanical parts. In contrast,
a general-purpose computer, such as a personal computer, can do many different tasks
depending on programming. Embedded systems have become very important today as they
control many of the common devices we use.

Since the embedded system is dedicated to specific tasks, design engineers can
optimize it, reducing the size and cost of the product, or increasing the reliability and
performance. Some embedded systems are mass-produced, benefiting from economies of
scale.

Physically, embedded systems range from portable devices such as digital watches
and MP3 players, to large stationary installations like traffic lights, factory controllers, or the
systems controlling nuclear power plants. Complexity varies from low, with a single
microcontroller chip, to very high with multiple units, peripherals and networks mounted
inside a large chassis or enclosure.

In general, "embedded system" is not an exactly defined term, as many systems have
some element of programmability. For example, Handheld computers share some elements
with embedded systems — such as the operating systems and microprocessors which power
them — but are not truly embedded systems, because they allow different applications to be
loaded and peripherals to be connected.

A Digital computer built on a single IC is called single chip microcomputer. Such


Computers are used in instrumentation automatic industrial control, process control, and
home and consumer applications. As it is used for control applications it is called micro
controller or embedded microcontroller. It is very small and compact. It contains CPU,
ROM, RAM and I/O lines.

1.2 MICROPROCESSOR Vs MICROCONTROLLER:

The past three decades have seen the introduction of a technology that has radically
changed the way in which we analyses the control the world around us. Born of parallel
developments in computer architecture and integrated circuit fabrication, the microprocessor

9|Page
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

or computer on a chip first became a commercial reality in 1971 with introduction of 4-bit
4004 by Intel corp.

A by-product of microprocessor development was the microcontroller. The same


fabrication techniques and programming concept that make possible the general-purpose
microprocessor also yielded the microcontroller are not as well as known to the general
Public or to many in the technical community, as are the most glamorous – microprocessor.
The public is however very aware that “something” is responsible for all of the smart VCRs,
clock radios, washers, dryers, videogames, telephones, microwaves, TVs, automobiles, toys,
vending machines, copiers, elevators and irons are programmable and intelligent Companies
are also ware that being competitive in this age of microchip requires their products, or the
machinery they use to make those products, to have some smart.

The block diagram of a microcontroller is shown, which is a true computer on chip.


The design incorporates all of the features found in the microprocessor. It also has added the
other features needed to make complete computer like ROM, RAM, parallel I/O, serial I/O,
counters and a clock circuit

Like the microprocessor, a microcontroller is a general purpose device, but one that is
meant to read data, perform limited calculation on that data and its environment based on
those calculations. The prime use of a microcontroller is to control the operation of a
machine using a fixed program that is stored in ROM & that does not change over the
lifetime of the system.

The design approach of the microcontroller mirrors that of the microprocessor make a
single design that can be used in as many applications as possible in order to sell, hopefully
as many as possible. The microprocessor accomplishes the goal by having a very flexible
and extensive repertoire of multi-byte instructions. These instructions work in Hardware
configurations that enable large amounts of memory and I/O to be connected to address and
data bus pins on the Integrated Circuit Package. Much of the activity in the Microprocessor
has to do with moving the code and data to and from external memory to the CPU. The
architecture features working registers that can be programmed to take Party in the memory
access process, and instruction set is aimed at expediting this activity in order to improve
throughput. The pins connected to the microprocessor to the external memory are unique, is
having a single function. Data is handled in byte or large sizes.

10 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

The microcontroller design uses a much more limited set of single and double byte
instructions that are used to move the code and data from internal memory to ALU Many
instructions are coupled with pins on integrated circuit package, the pins are “Programmable”
– that is capable of having several different functions depending on the wishes of the
programmer. The micro controller is concerned with getting data from and to its own pins.
The architecture and instructions are optimized to handle data in bit and byte size.

1.3 MICROPROCESSOR:

A microprocessor as a term has come to be known is a general-purpose digital


computer central processing unit. Although popularly known as a computer on a chip. The
microprocessor contains arithmetic and logic units, program counter, Stack pointer, some
working registers, and clock timing circuit and interrupts circuits.

To make a complete computer one must add memory usually RAM & ROM, memory
decoders, an oscillator and number of I/O devices such as parallel and serial data ports in
addition special purpose devices such as interrupt handlers and counters

The key term in describing the design of the microprocessor is “general purpose”. The
hardware design of a microprocessor CPU is arranged so that a small or very large system
can be configured around the CPU as the application demands.

Prime use of microprocessor is to read data, perform extensive calculation on that data
and store those calculations in a mass storage device. The programs used by the
microprocessor are stored in the mass storage device and loaded in the RAM as the user
directs. A few microprocessor programs are stored in the ROM. The ROM based programs
are primarily are small fixed programs that operate on peripherals and other fixed device that
are connected to the system.

BLOCK DIAGRAM OF MICROPROCESSOR:

11 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

Figure 1.1: Block diagram of microprocessor

1.3.1 Features:
1. 8086 is a 40 pin IC
2. It is a 16-bit processor
3. Its operating voltage is 5 volts
4. Its operating frequency is 5 MHz
5. Total memory addressing capacity is 1MB (external).
6. It has 16-bit data bus and 20-bit address bus.
7. It has fourteen 16-bit registers.
8. Higher throughput (speed).
9. 8086 has 256 vectored interrupts.
10. 8086 uses two stage of pipelining. First is Fetch Stage and the second is Execute
Stage.

12 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

CHAPTER-2
FUNCTIONAL DESCRIPTION

2.1 LPC2148 MICROCONTROLLER

The LPC2148 microcontroller is based on a 32-bit ARM7TDMI-S CPU with real-


time emulation and embedded trace support, that combine microcontrollers with embedded
high-speed flash memory ranging from 32 kB to 512 kB. A 128-bit wide memory interface
and unique accelerator architecture enable 32-bit code execution at the maximum clock rate.
For critical code size applications, the alternative 16-bit Thumb mode reduces code by more
than 30 % with minimal performance penalty.

Due to their tiny size and low power consumption, LPC2141/42/44/46/48 are ideal for
applications where miniaturization is a key requirement, such as access control and point-of-
sale. Serial communications interfaces ranging from a USB 2.0 Full-speed device, multiple
UARTs, SPI, SSP to I2C-bus and on-chip SRAM of 8 kB up to 40 kB, make these devices
very well suited for communication gateways and protocol converters, soft modems, voice
recognition and low end imaging, providing both large buffer size and high processing
power. Various 32-bit timers, single or dual 10-bit ADCs, 10-bit DAC, PWM channels and
45 fast GPIO lines with up to nine edge or level sensitive external interrupt pins make these
microcontrollers suitable for industrial control and medical systems.

Figure 2.1: LPC2148 IC

Features of LPC2148:
 16-bit/32-bit ARM7TDMI-S microcontroller in a tiny LQFP64 package.
 8 kB to 40 kB of on-chip static RAM and 32 kB to 512 kB of on-chip flash memory;
128-bit wide interface/accelerator enables high-speed 60 MHz operation.

13 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

 In-System Programming/In-Application Programming (ISP/IAP) via on-chip boot


loader software, single flash sector or full chip erase in 400 ms and programming of 256
B in 1 ms.
 Embedded ICE RT and Embedded Trace interfaces offer real-time debugging with the
on-chip Real Monitor software and high-speed tracing of instruction execution.
 USB 2.0 Full-speed compliant device controller with 2 kB of endpoint RAM.
 In addition, the LPC2146/48 provides 8 kB of on-chip RAM accessible to USB by
DMA.
 One or two (LPC2141/42 vs, LPC2144/46/48) 10-bit ADCs provide a total of 6/14
analog inputs, with conversion times as low as 2.44 ms per channel Single 10-bit DAC
provides variable analog output (LPC2142/44/46/48 only).
 Two 32-bit timers/external event counters (with four capture and four
comparechannels each), PWM unit (six outputs) and watchdog.
 Low power Real-Time Clock (RTC) with independent power and 32 kHz clock input.
 Multiple serial interfaces including two UARTs (16C550), two Fast I2C-bus (400
kbit/s), SPI and SSP with buffering and variable data length capabilities.
 Vectored Interrupt Controller (VIC) with configurable priorities and vector addresses.
 Up to 45 of 5 V tolerant fast general purpose I/O pins in a tiny LQFP64 package.
 Up to 21 external interrupt pins available.
 60 MHz maximum CPU clock available from programmable on-chip PLL with
settling time of 100 ms.
 On-chip integrated oscillator operates with an external crystal from 1 MHz to 25
MHz.
 Power saving modes include Idle and Power-down.
 Individual enable/disable of peripheral functions as well as peripheral clock scaling
for additional power optimization.
 Processor wake-up from Power-down mode via external interrupt.
 Single power supply chip with POR and BOD circuits:
CPU operating voltage range of 3.0 V to 3.6 V (3.3 V ± 10 %) with 5 V tolerant I/O pads.

14 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

Architecture of ARM7-LPC2148 Microcontroller:

15 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

16 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

Figure 2.2: Architecture of ARM7-LPC2148

ARM Architecture:

17 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

RISC:
RISC, or Reduced Instruction Set Computer. is a type of microprocessor architecture that
utilizes a small, highly-optimized set of instructions, rather than a more specialized set of
instructions often found in other types of architectures.

History:
The first RISC projects came from IBM, Stanford, and UC-Berkeley in the late 70s and early
80s. The IBM 801, Stanford MIPS, and Berkeley RISC 1 and 2 were all designed with a
similar philosophy which has become known as RISC. Certain design features have been
characteristic of most RISC processors:
 One cycle execution time :RISC processors have a CPI (clock per instruction) of one
cycle. This is due to the optimization of each instruction on the CPU and a technique
called pipelining : a technique that allows for simultaneous execution of parts, or
stages, of instructions to more efficiently process instructions;

 large number of registers : the RISC design philosophy generally incorporates a larger
number of registers to prevent in large amounts of interactions with memory.

Based upon RISC Architecture with enhancements to meet requirements of embedded


applications ARM is having
1. A large uniform register file

2. Load-store architecture ,where data processing operations operate on register


contents only

3. Uniform and fixed length instructions

4. 32 -bit processor

5. Instructions are 32-bit long

6. Good Speed/Power Consumption Ratio

7. High Code Density

CISC RISC

18 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

Price/Performance Strategies

Price: move complexity from software to hardware. Price: move complexity from hardware to software.
Performance: make tradeoffs in favour of decreased code Performance: make tradeoffs in favor of a lower CPI,
size, at the expense of a higher CPI. at the expense of increased code size.

Design Decisions

 Execution of instructions takes many cycles  Simple, single-cycle instructions that perform
only basic functions.  Assembler instructions
 Design rules are simple thus core operates at
correspond to microcode instructions on a
higher clock frequencies
CISC machine.
 Memory-to-memory addressing modes.
 Design rules are more complex and operates
 A microcode control unit. at lower clock frequencies

 Spend fewer transistors on registers.  Simple addressing modes that allow only
LOAD and STORE to access memory.  All
operations are register-to-register.

 direct execution control unit.

 spend more transistors on multiple banks of


registers.

 use pipelined execution to lower CPI.

Pin Configuration:

19 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

Figure 2.3: Pin configuration


Pin Description:

P0.0 to P0.31 I/O Port 0:


Port 0 is a 32-bit I/O port with individual direction controls for each bit. Total of 31
pins of the Port 0 can be used as a general purpose bidirectional digital I/Os while P0.31 is
output only pin. The operation of port 0 pins depends upon the pin function selected via the
pin connect block.
P0.0/TXD0/PWM1:
P0.0 - General purpose input/output digital pin (GPIO).
TXD0 - Transmitter output for UART0.
PWM1 - Pulse Width Modulator output 1.
P0.1/RXD0/PWM3/EINT0:
P0.1 -General purpose input/output digital pin (GPIO).

20 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

RXD0 -Receiver input for UART0.


PWM3 - Pulse Width Modulator output 3.
EINT0 -External interrupt 0 input.
P0.2/SCL0/ CAP0.0:
P0.2 - General purpose input/output digital pin (GPIO).
SCL0 -I2C0 clock input/output, open-drain output (for I2C-bus compliance).
CAP0.0 -Capture input for Timer 0, channel 0.
P0.3/SDA0/ MAT0.0/EINT1:
P0.3 -General purpose input/output digital pin (GPIO).
SDA0 -I2C0 data input/output, open-drain output (for I2C-bus compliance).
MAT0.0 -Match output for Timer 0, channel 0.
EINT1 -External interrupt 1 input.
P0.4/SCK0/ CAP0.1/AD0.6:
P0.4 -General purpose input/output digital pin (GPIO).
SCK0 -Serial clock for SPI0, SPI clock output from master or input to slave.
CAP0.1 -Capture input for Timer 0, channel 0.
AD0.6 -ADC 0, input 6.
P0.5/MISO0/ MAT0.1/AD0.7:
P0.5 -General purpose input/output digital pin (GPIO).
MISO0 –Master In Slave OUT for SPI0, data input to SPI master or data output from
SPI.
MAT0.1 -Match output for Timer 0, channel 1.
AD0.7 -ADC 0, input 7.
P0.6/MOSI0/ CAP0.2/AD1.0:
P0.6 -General purpose input/output digital pin (GPIO).
MOSI0 -Master Out Slave In for SPI0, data output from SPI master or data input to
SPI.
CAP0.2 -Capture input for Timer 0, channel 2.
AD1.0 -ADC 1, input 0, available in LPC2144/46/48 only.
P0.7/SSEL0/PWM2/EINT2:
P0.7 -General purpose input/output digital pin (GPIO).
SSEL0 -Slave Select for SPI0, selects the SPI interface as a slave.
PWM2 — Pulse Width Modulator output 2.
EINT2 — External interrupt 2 input.

21 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

P0.8/TXD1/PWM4/AD1.1:
P0.8 — General purpose input/output digital pin (GPIO).
TXD1 — Transmitter output for UART1.
PWM4 — Pulse Width Modulator output 4.
AD1.1 — ADC 1, input 1, available in LPC2144/46/48 only.
P0.9/RXD1/ PWM6/EINT3:
P0.9 -General purpose input/output digital pin (GPIO).
RXD1 -Receiver input for UART1.
PWM6 -Pulse Width Modulator output 6.
EINT3 -External interrupt 3 input.
P0.10/RTS1/ CAP1.0/AD1.2:
P0.10 -General purpose input/output digital pin (GPIO).
RTS1 -Request to send output for UART1, LPC2144/46/48 only.
CAP1.0 -Capture input for Timer 1, channel 0.
AD1.2 -ADC 1, input 2, available in LPC2144/46/48 only.
P0.11/CTS1/ CAP1.1/SCL1:
P0.11 -General purpose input/output digital pin (GPIO).
CTS1 -Clear to send input for UART1, available in LPC2144/46/48 only.
CAP1.1 -Capture input for Timer 1, channel 1.
SCL1 -I2C1 clock input/output, open-drain output (for I2C-bus compliance).
P0.12/DSR1/MAT1.0/AD1.3:
P0.12 -General purpose input/output digital pin (GPIO).
DSR1 -Data Set Ready input for UART1, available in LPC2144/46/48 only.
MAT1.0 -Match output for Timer 1, channel 0.
AD1.3 -ADC input 3, available in LPC2144/46/48 only.
P0.13/DTR1/ MAT1.1/AD1.4:
P0.13 -General purpose input/output digital pin (GPIO).
DTR1 -Data Terminal Ready output for UART1, LPC2144/46/48 only.
MAT1.1 -Match output for Timer 1, channel 1.
AD1.4 -ADC input 4, available in LPC2144/46/48 only.
P0.14/DCD1/EINT1/SDA1:
P0.14 — General purpose input/output digital pin (GPIO)
DCD1 — Data Carrier Detect input for UART1, LPC2144/46/48 only
EINT1 — External interrupt 1 input

22 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

SDA1 — I2C1 data input/output, open-drain output.


P0.15/RI1/ EINT2/AD1.5:
P0.15 - General purpose input/output digital pin (GPIO).
RI1 -Ring Indicator input for UART1, available in LPC2144/46/48 only.
EINT2 -External interrupt 2 input.
AD1.5 -ADC 1, input 5, available in LPC2144/46/48 only.
P0.16/EINT0/MAT0.2/CAP0.2:
P0.16 -General purpose input/output digital pin (GPIO).
EINT0 -External interrupt 0 input.
MAT0.2 -Match output for Timer 0, channel 2.
CAP0.2 - Capture input for Timer 0, channel 2.
P0.17/CAP1.2/ SCK1/MAT1.2:
P0.17 -General purpose input/output digital pin (GPIO).
CAP1.2 -Capture input for Timer 1, channel 2.
SCK1 -Serial Clock for SSP, clock output from master or input to slave.
MAT1.2 -Match output for Timer 1, channel 2.
P0.18/CAP1.3/MISO1/MAT1.3:
P0.18 -General purpose input/output digital pin (GPIO).
CAP1.3 - Capture input for Timer 1, channel 3.
MISO1 -Master In Slave Out for SSP, data input to SPI master or data output from
SSP.
MAT1.3 -Match output for Timer 1, channel 3.
P0.19/MAT1.2/MOSI1/CAP1.2:
P0.19 -General purpose input/output digital pin (GPIO).
MAT1.2 -Match output for Timer 1, channel 2.
MOSI1 -Master Out Slave In for SSP, data output from SSP master or data Input to
SSP.
CAP1.2 -Capture input for Timer 1, channel 2.
P0.20/MAT1.3/SSEL1/EINT3:
P0.20 -General purpose input/output digital pin (GPIO).
MAT1.3 -Match output for Timer 1, channel 3.
SSEL1 -Slave Select for SSP, selects the SSP interface as a slave.
EINT3 -External interrupt 3 input.
P0.21/PWM5/AD1.6/CAP1.3:

23 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

P0.21 -General purpose input/output digital pin (GPIO).


PWM5 -Pulse Width Modulator output 5.
AD1.6 -ADC 1, input 6, available in LPC2144/46/48 only.
CAP1.3 -Capture input for Timer 1, channel 3.
P0.22/AD1.7/CAP0.0/MAT0.0:
P0.22 -General purpose input/output digital pin (GPIO).
AD1.7 -ADC 1, input 7, available in LPC2144/46/48 only.
CAP0.0 -Capture input for Timer 0, channel 0.
MAT0.0 -Match output for Timer 0, channel 0.
P0.23/VBUS:
P0.23 -General purpose input/output digital pin (GPIO).
VBUS -Indicates the presence of USB bus power.
P0.25/AD0.4/AOUT:
P0.25 -General purpose input/output digital pin (GPIO).
AD0.4 -ADC 0, input 4.
AOUT -DAC output, available in LPC2142/44/46/48 only.
P0.28/AD0.1/CAP0.2/MAT0.2:
P0.28 -General purpose input/output digital pin (GPIO).
AD0.1 -ADC 0, input 1.
CAP0.2 -Capture input for Timer 0, channel 2.
MAT0.2 -Match output for Timer 0, channel 2.
P0.29/AD0.2/CAP0.3/MAT0.3:
P0.29 -General purpose input/output digital pin (GPIO).
AD0.2 -ADC 0, input 2.
CAP0.3 -Capture input for Timer 0, Channel 3.
MAT0.3 -Match output for Timer 0, channel 3.
P0.30/AD0.3/EINT3/CAP0.0:
P0.30 - General purpose input/output digital pin (GPIO).
AD0.3 -ADC 0, input 3.
EINT3 - External interrupt 3 input.
CAP0.0 -Capture input for Timer 0, channel 0.
P0.31/UP_LED/CONNECT:
P0.31 - General purpose output only digital pin (GPO).
UP_LED -USB Good Link LED indicator, LOW when configured otherwise HIGH.

24 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

CONNECT -Signal used to switch an external 1.5 k ohms resistor under the Software
control, used with the Soft Connect USB feature.
P1.0 to P1.31 I/O Port 1:
Port 1 is a 32-bit bidirectional I/O port with individual direction controls for each bit,
the operation of port 1 pins depends upon the pin function selected via the pin connect block,
pins 0 through 15 of port 1 are not Available.
P1.16/TRACEPKT0:
P1.16 -General purpose input/output digital pin (GPIO).
TRACEPKT0 -Trace Packet, bit 0, standard I/O port with internal pull-up.
P1.17/TRACEPKT1:
P1.17 -General purpose input/output digital pin (GPIO).
TRACEPKT1 -Trace Packet, bit 1, standard I/O port with internal pull-up.
P1.18/TRACEPKT2:
P1.18 — General purpose input/output digital pin (GPIO).
TRACEPKT2 — Trace Packet, bit 2, standard I/O port with internal pull-up.
P1.19/TRACEPKT3:
P1.19 — General purpose input/output digital pin (GPIO).
TRACEPKT3 — Trace Packet, bit 3, standard I/O port with internal pull-up.
P1.20/TRACESYNC:
P1.20 -General purpose input/output digital pin (GPIO).
TRACESYNC -Trace Synchronization, standard I/O port with internal pull-up.
P1.21/PIPESTAT0:
P1.21 -General purpose input/output digital pin (GPIO).
PIPESTAT0 -Pipeline Status, bit 0, standard I/O port with internal pull-up.
P1.22/PIPESTAT1:
P1.22 -General purpose input/output digital pin (GPIO).
PIPESTAT1 -Pipeline Status, bit 1, standard I/O port with internal pull-up.
P1.23/PIPESTAT2:
P1.23 -General purpose input/output digital pin (GPIO).
PIPESTAT2 -Pipeline Status, bit 2, standard I/O port with internal pull-up.
P1.24/TRACECLK:
P1.24 -General purpose input/output digital pin (GPIO).
TRACECLK — Trace Clock, standard I/O port with internal pull-up.
P1.25/EXTIN0:

25 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

P1.25 -General purpose input/output digital pin (GPIO).


EXTIN0 -External Trigger Input, standard I/O with internal pull-up.
P1.26/RTCK:
P1.26 -General purpose input/output digital pin (GPIO).
RTCK -Returned Test Clock output, extra signal added to the JTAG port, assists
debugger synchronization when processor frequency varies, bidirectional pin with
internal pull-up.
P1.27/TDO:
P1.27 -General purpose input/output digital pin (GPIO).
TDO -Test Data out for JTAG interface.
P1.28/TDI:
P1.28 -General purpose input/output digital pin (GPIO).
TDI -Test Data in for JTAG interface.
P1.29/TCK:
P1.29 -General purpose input/output digital pin (GPIO).
TCK -Test Clock for JTAG interface.
P1.30/TMS:
P1.30 -General purpose input/output digital pin (GPIO).
TMS -Test Mode Select for JTAG interface.
P1.31/TRST:
P1.31 -General purpose input/output digital pin (GPIO).
TRST -Test Reset for JTAG interface.
D+: USB bidirectional D+ line.
D-: USB bidirectional D- line.
RESET External input:
A LOW on this pin resets the device, causing I/O ports and peripherals to take on
their default states, and processor execution to begin at address 0, TTL with hysteretic, 5 V
tolerant.
XTAL1: Input to the oscillator circuit and internal clock generator circuits.
XTAL2: Output from the oscillator amplifier.
RTCX1: Input to the RTC oscillator circuit.
RTCX2: Output from the RTC oscillator circuit.
VSS: 6, 18, 25, 42, 50 pins are for supply voltage.
Ground:0 V reference.

26 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

VSSA Analog ground:


0 V reference, this should nominally be the same voltage as VSS, but should be
isolated to minimize noise and error.
VDD 23, 43, 51 I 3.3 V power supply: Power supply voltage for the core and I/O ports.
VDDA 7 I Analog 3.3 V power supply:
This should be nominally the same voltage as VDD but should be isolated to
minimize noise and error, this voltage is only used to power the on-chip ADC(s) and DAC.
VREF ADC reference voltage:
This should be nominally less than or equal to the VDD voltage but should be isolated
to minimize noise and error, level on this Pin is used as a reference for ADC(s) and DAC.
VBAT RTC power supply voltage: 3.3 V on this pin supplies the power to the RTC.

ARM Register file & modes of operation:


Registers : General Purpose registers hold either data or address they are identified with
the letter r prefixed to the register number. All registers are of 32 bits.
ARM has 37 registers in total, all of which are 32-bits long.
1 dedicated program counter
1 dedicated current program status register
5 dedicated saved program status registers
30 general purpose registers
However these are arranged into several banks, with the accessible bank being governed by
the processor mode. Each mode can access a particular set of r0-r12 registers, a particular r13
(the stack pointer) and r14 (link register), r15 (the program counter), cpsr (the current
program status register) and privileged modes can also access a particular spsr (saved
program status register).
In user mode 16 data registers and 2 status registers are visible. Depending upon context,
register r13 and r14 can also be used as General Purpose Registers. In ARM state the
registers r0 to r13 are Orthogonal that means - any instruction which use r0 can as well be
used with any other General Purpose Register (r1-r13).
The ARM processor has three registers assigned to a particular task or special function:
r13,r14 and r15. They are frequently given different labels to differentiate them from the
other registers.
 Register r13 is traditionally used as the stack pointer (sp) and stores the head of the
stack in the current processor mode

27 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

 Register r14 is called the link register ( lr ) and is where the core puts the return
address whenever it calls a subroutine.

 Register r15 is the program counter ( pc ) and contains the address of the next
instruction to be fetched by the processor

The register file contains all the registers available to a programmer. Which registers are
visible to the programmer depend upon the current mode of the processor.
Current program status register :
The ARM core uses the cpsr to monitor and control internal operations. The
cpsr is a dedicated 32-bit register and resides in the register file. The following figure shows
the generic program status register.

Fig: Program Status Register

The control bit field contains the processor mode, state , and interrupt mask bits (I,F).
Reserved bits are allocated for the future versions purpose.
 The N, Z, C and V are condition code flags will be changed as a result of arithmetic and
logical operations in the processor

N : Negative. Z : Zero. C : Carry. V : Overflow

 The I and F bits are the interrupt disable bits

 The M0, M1, M2, M3 and M4 bits are the mode bits

Processor Modes: Processor modes determine which register are active, and access rights to
CPSR register itself.

CHAPTER 3

28 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

CIRCUIT DESCRIPTION

3.1 BLOCK DIAGRAM

POWER
SUPPLY

M
I
C
R
TEMPERA O U MAX WIFI
TURE C A
MOBILE
SENSOR O R 232 MODULE
N T
T
A
R
PH O
D
SENSOR L
L
C
E
LCD R
LEVEL
SENSOR
ARM7

LPC2148 BUZZER

Figure 3.1: Block Diagram

29 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

LCD DISPLAY:

 LCD (Liquid Crystal Display) is an electronic display module. A 16x2 LCD display is a
very basic module and commonly used in various devices and circuits. These modules
are preferred over seven segments and other multi segment LEDs.
 A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In
this LCD each character is displayed in 5x7 pixel matrix. LCD has two registers,
namely, Command and Data registers. The command register stores the command
instructions given to the LCD.

BUZZER:
 A buzzer or beeper is a signalling device, usually electronic, typically used in
automobiles, household appliances such as a microwave oven, or game shows.
 It most commonly consists of a number of switches connected to a control unit that
determines if and which button was pushed or a preset time has lapsed, and usually
illuminates a light on the appropriate button or control panel, and sounds a warning in
the form of a continuous or intermittent buzzing or beeping sound.

POWER SUPPLY:

 The circuit basically consists of a step down transformer, a bridge rectifier, a low-pass
filter, and a regulator. It is centre tapped to have both -ve and +ve half cycle of AC
waveform to contribute to direct current and transforming energy using mutual
induction.TTL logic circuitry cannot work on voltage of 230v ac .So, we are stepping
down it to 9v.
 A bridge rectifier is an arrangement of four or more diodes in a bridge circuit
configuration which provides the same output polarity for either input polarity.
 It is used for converting an alternating current (AC) input into a direct current (DC)
output.
 A low pass filter in the circuit is to filter out any unwanted high frequency noise from
nearby equipment. The cut-off frequency of the filter was chosen as 2Hz. The
frequency and phase responses of the amplifier together with the filter. The output
time response of the amplifier and filter circuit which consists of pulses.

30 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

 7805 is a voltage regulator integrated circuit. It is a member of 78xx series of fixed


linear voltage regulator ICs. The voltage regulator IC maintains the output voltage at a
constant value. The xx in 78xx indicates the fixed output voltage it is designed to
provide. 7805 provides +5V regulated power supply. 

3.2 CIRCUIT DIAGRAM:

TEMPERATURE

SENSOR ARM 7

MICRO

CONTROLLER
LEVEL WIFI Mobile

SENSOR MODULE

pH
SENSOR

ASM/C

PROGRAM

Figure 3.2 : Circuit diagram

3.3 COMPONENT DESCRIPTION:


31 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

3.3.1 LPC2148 MICRO CONTROLLER:

The LPC2148 microcontroller is based on a 32-bit ARM7TDMI-S CPU with


real-time emulation and embedded trace support, that combine microcontrollers with
embedded high-speed flash memory ranging from 32 kB to 512 kB.

A 128-bit wide memory interface and unique accelerator architecture enable 32-bit
code execution at the maximum clock rate. For critical code size applications, the alternative
16-bit Thumb mode reduces code by more than 30 % with minimal performance penalty.

3.3.2 POWER SUPPLY CIRCUIT:

Figure 3.3: Power supply circuit

STEP DOWN TRANSFORMER:

 It is a Centre tapped transformer giving 9-0-9v dc at the output of 1A current. It is


centre tapped to have both -ve and +ve half cycle of AC waveform to contribute to
direct current and transforming energy using mutual induction.TTL logic circuitry
cannot work on voltage of 230v ac .so, we are stepping down it to 9v.

32 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

Figure 3.4: Mutual Induction of transformer

Figure 3.5: Step down transformer

BRIDGE RECTIFER:

 Converting both polarities of input ac voltage to one of the constant polarity at its
output dc current. Yields a higher mean output voltage .Our circuitry can only work
on dc voltage. The negative peak inverse voltage is less compared to full wave
rectifier and is cost efficient.

33 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

Figure 3.6: Bridge rectifier circuit

FILTER CIRCUIT:

 Low pass filter is a filter that passes with a frequency lower than a certain cut-off
frequency and attenuates signals with frequency higher than the cut-off frequency.

 The amount of attenuation for each frequency depends on the filter design the
frequency at which the transition occurs is called the “cut-off frequency”.

Figure 3.7: Filter circuit

VOLTAGE REGULATOR:

 It has 5V Regulated output voltage. Input voltage range is 5V-18V. The voltage source
in circuit may have fluctuation and would not give fixed output voltage. It has three
pins Pin1-input, Pin2-ground, Pin3-output.Heat sink is used for dissipating heat into
surrounding air to protect device from damage. LM indicates as linear monolithic,78
indicates positive voltage and 05 indicates 5v.

34 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

Figure 3.8: 7805Voltage regulator

3.3.3 REGULATED POWER SUPPLY


A variable regulated power supply, also called a variable bench power supply, is one where
you can continuously adjust the output voltage to your requirements. Varying the output of
the power supply is the recommended way to test a project after having double checked parts
placement against circuit drawings and the parts placement guide.

This type of regulation is ideal for having a simple variable bench power supply. Actually
this is quite important because one of the first projects a hobbyist should undertake is the
construction of a variable regulated power supply. While a dedicated supply is quite handy
,it's much handier to have a variable supply on hand, especially for testing.

Mainly the ARM controller needs 3.3 volt power supply. To use these parts we need to build
a regulated 3.3 volt source. Usually you start with an unregulated power To make a 3.3 volt
power supply, we use a LM317 voltage regulator IC (Integrated Circuit). The IC is shown
below.

CIRCUIT FEATURES

Vout range 1.25V - 37V

Vin - Vout difference 3V - 40V

Operation ambient temperature 0 - 125°C

Output Imax <1.5A

35 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

Minimum Load Currentmax 10mA

A current-limiting circuit constructed with LM317

Figure 3.9: LM317 IC

Part pin out of LM317 showing its constant voltage reference

LM317 is the standard part number for an integrated three-terminal adjustable linear voltage
regulator. LM317 is a positive voltage regulator supporting input voltage of 3V to 40V and
output voltage between 1.25V and 37V. A typical current rating is 1.5A although several
lower and higher current models are available. Variable output voltage is achieved by using a
potentiometer or a variable voltage from another source to apply a control voltage to the
control terminal. LM317 also has a built-in current limiter to prevent the output current from
exceeding the rated current, and LM317 will automatically reduce its output current if an
overheat condition occurs under load. LM317 is manufactured by many companies, including
National Semiconductor, Fairchild Semiconductor, and STMicroelectronics.

Although LM317 is an adjustable regulator, it is sometimes preferred for high-precision fixed


voltage applications instead of the similar LM78xx devices because the LM317 is designed
with superior output tolerances. For a fixed voltage application, the control pin will typically
be biased with a fixed resistor network, a Zener diode network, or a fixed control voltage
from another source. Manufacturer datasheets provide standard configurations for achieving
various design applications, including the use of a pass transistor to achieve regulated output
currents in excess of what the LM317 alone can provide.

LM317 is available in a wide range of package forms for different applications including heat
sink mounting and surface-mount applications. Common form factors for high-current
applications include TO-220 and TO-3. LM317 is capable of dissipating a large amount of
heat at medium to high current loads and the use of a heat sink is recommended to maximize
the lifespan and power-handling capability.

36 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

LM337 is the negative voltage complement to LM317 and the specifications and function are
essentially identical, except that the regulator must receive a control voltage and act on an
input voltage that are below the ground reference point instead of above it.

3.4 TEMPERATURE SENSOR (LM35):


Precision Centigrade Temperature Sensor

In this project, in order to monitor the temperature continuously and compare this with the set
temperature preprogrammed in the microcontroller, initially this temperature value has to be
read and fed to the microcontroller. This temperature value has to be sensed. Thus a sensor
has to be used and the sensor used in this project is LM35. It converts temperature value into
electrical signals.
LM35 series sensors are precision integrated-circuit temperature sensors whose output
voltage is linearly proportional to the Celsius temperature. The LM35 requires no external
calibration since it is internally calibrated. . The LM35 does not require any external
calibration or trimming to provide typical accuracies of ±1⁄4°C at room temperature and
±3⁄4°C over a full −55 to +150°C temperature range.
The LM35’s low output impedance, linear output, and precise inherent calibration make
interfacing to readout or control circuitry especially easy. It can be used with single power
supplies, or with plus and minus supplies. As it draws only 60 μA from its supply, it has very
low self-heating, less than 0.1°C in still air.
Features
1. Calibrated directly in ° Celsius (Centigrade)
2. Linear + 10.0 mV/°C scale factor
3. 0.5°C accuracy guaranteed (at +25°C)
4. Rated for full −55° to +150°C range
5. Suitable for remote applications
6. Low cost due to wafer-level trimming
7. Operates from 4 to 30 volts
8. Less than 60 μA current drain
9. Low self-heating, 0.08°C in still air

37 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

Figure 3.10 : Temperature Sensor

The characteristic of this LM35 sensor is:


For each degree of centigrade temperature it outputs 10milli volts.

ROLE OF LM35:
In this project, the temperature is to be monitored continuously and if the temperature
exceeds the set value preprogrammed in the microcontroller, a buzzer indication is provided
in the circuit to alert the people in the industry to stop the process immediately. Thus the
temperature sensor LM35 has to read the temperature continuously and the microcontroller
has to compare this temperature value with the set temperature preprogrammed in it. When
this temperature exceeds the set value, the microcontroller sends an indication to the buzzer
which gives a loud noise.

3.5 pH SENSOR:

The pH sensor components are usually combined into one device called a combination pH
electrode. The measuring electrode is usually glass and quite fragile. Recent
developments have replaced the glass with more durable solid-state sensors. The
preamplifier is a signal-conditioning device. It takes the high-impedance pH electrode
signal and changes it into allow impedance signal which the analiser or transmitter can
accept. The preamplifier also
strengthens and stabilizes the signal, making it less susceptible to electrical noise.

The sensor's electrical signal is then displayed. This is commonly done in a 120/240 V ac-
powered analiser or in a 24 V dc loop-powered transmitter.

Additionally, the analiser or transmitter has a man machine interface for calibrating the
sensor and configuring outputs and alarms, if pH control is being done.

38 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

Keep in mind, application requirements should be carefully considered when choosing a


pH electrode. Accurate pH measurement and the resulting precise control that it can allow,
can go a long way toward process optimization and result in increased product and result in
increased product quality and consistency. Accurate, stable pH measurement also controls
and often lowers chemical usage, minimising system maintenance and expense.

Figure 3.11: pH Sensor

3.7 LEVEL SENSOR:

Level sensors detect the level of liquids and other fluids and fluidized solids, including
slurries, granular materials, and powders that exhibit an upper free surface. The substance to
be measured can be inside a container or can be in its natural form (e.g., a river or a lake).
The level measurement can be either continuous or point values. Continuous level sensors
measure level within a specified range and determine the exact amount of substance in a
certain place, while point-level sensors only indicate whether the substance is above or below
the sensing point. Generally the latter detect levels that are excessively high or low.

There are many physical and application variables that affect the selection of the optimal
level monitoring method for industrial and commercial processes. The selection criteria
include the physical: phase (liquid, solid or slurry), temperature, pressure or vacuum,
chemistry, dielectric constant of medium, density (specific gravity) of medium, agitation
(action), acoustical or electrical noise, vibration, mechanical shock, tank or bin size and
shape. Also important are the application constraints: price, accuracy, appearance, response
rate, ease of calibration or programming, physical size and mounting of the instrument,
monitoring or control of continuous or discrete (point) levels. In short, level sensors are one
of the very important sensors and play very important role in variety of consumer/ industrial
applications. As with other type of sensors, level sensors are available or can be designed
using variety of sensing principles. Selection of an appropriate type of sensor suiting to the
application requirement is very important.

39 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

Figure 3.12: Level Sensor

3.8 MAX232:

 The MAX232 is an IC, first created in 1987 by Maxim Integrated Products, that


converts signals from an RS-232 serial port to signals suitable for use
in TTL compatible digital logic circuits. The MAX232 is a dual driver/receiver and
typically converts the RX, TX, CTS and RTS signals.
 The drivers provide RS-232 voltage level outputs (approx. ± 7.5 V) from a single
+ 5 V supply via on-chip charge pumps and external capacitors. This makes it
useful for implementing RS-232 in devices that otherwise do not need any voltages
outside the 0 V to + 5 V range, as power supply design does not need to be made
more complicated just for driving the RS-232 in this case.

40 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

Figure 3.13 : IC MAX232

3.9 ESP8266 Wi-Fi Module

The ESP8266 Wi-Fi Module is a self contained SOC with integrated TCP/IP protocol
stack that can give any microcontroller access to your Wi-Fi network. The ESP8266 is
capable of either hosting an application or offloading all Wi-Fi networking functions from
another application processor. Each ESP8266 module comes pre-programmed with an AT
command set firmware, meaning, you can simply hook this up to your Arduino device and
get about as much Wi-Fi-ability as a Wi-Fi Shield offers (and that’s just out of the box)! The
ESP8266 module is an extremely cost effective board with a huge, and ever growing,
community.

This module has a powerful enough on-board processing and storage capability that
allows it to be integrated with the sensors and other application specific devices through its
GPIOs with minimal development up-front and minimal loading during runtime. Its high
degree of on-chip integration allows for minimal external circuitry, including the front-end
module, is designed to occupy minimal PCB area. The ESP8266 supports APSD for VoIP
applications and Bluetooth co-existence interfaces, it contains a self-calibrated RF allowing it
to work under all operating conditions, and requires no external RF parts.

41 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

There is an almost limitless fountain of information available for the ESP8266, all of which
has been provided by amazing community support. In the Documents section below you will
find many resources to aid you in using the ESP8266, even instructions on how to
transforming this module into an IOT (Internet of Things) solution. The ESP8266 Module is
not capable of 5-3V logic shifting and will require an external Logic Level Converter. Please
do not power it directly from your 5V dev board. This new version of the ESP8266 Wi-Fi
Module has increased the flash disk size from 512k to 1MB.

Features:

 802.11 b/g/n
 Wi-Fi Direct (P2P), soft-AP
 Integrated TCP/IP protocol stack
 Integrated TR switch, balun, LNA, power amplifier and matching network
 Integrated PLLs, regulators, DCXO and power management units
 +19.5dBm output power in 802.11b mode
 Power down leakage current of <10uA
 1MB Flash Memory
 Integrated low power 32-bit CPU could be used as application processor
 SDIO 1.1 / 2.0, SPI, UART
 STBC, 1×1 MIMO, 2×1 MIMO
 A-MPDU & A-MSDU aggregation & 0.4ms guard interval
 Wake up and transmit packets in < 2ms
 Standby power consumption of < 1.0mW (DTIM3)

Figure 3.14: Wi-Fi Module

42 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

3.10 LCD (Liquid Crystal Display)

A liquid crystal display (LCD) is a thin, flat display device made up of any number of
colour or monochrome pixels arrayed in front of a light source or reflector. Each pixel
consists of a column of liquid crystal molecules suspended between two transparent
electrodes, and two polarizing filters, the axes of polarity of which are perpendicular to each
other. Without the liquid crystals between them, light passing through one would be blocked
by the other. The liquid crystal twists the polarization of light entering one filter to allow it to
pass through the other.
A program must interact with the outside world using input and output devices that
communicate directly with a human being. One of the most common devices attached to a
controller is an LCD display. Some of the most common LCDs connected to the controllers
are 16X1, 16x2 and 20x2 displays. This means 16 characters per line by 1 line 16 characters
per line by 2 lines and 20 characters per line by 2 lines, respectively.
Many microcontroller devices use 'smart LCD' displays to output visual information.
LCD displays designed around LCD NT-C1611 module, are inexpensive, easy to use, and it
is even possible to produce a readout using the 5X7 dots plus cursor of the display. They
have a standard ASCII set of characters and mathematical symbols. For an 8-bit data bus, the
display requires a +5V supply plus 10 I/O lines (RS RW D7 D6 D5 D4 D3 D2 D1 D0). For
a 4-bit data bus it only requires the supply lines plus 6 extra lines (RS RW D7 D6 D5 D4).
When the LCD display is not enabled, data lines are tri state and they do not interfere with
the operation of the microcontroller.

Features:
(1) Interface with either 4-bit or 8-bit microprocessor.
(2) Display data RAM
(3) 80x8 bits (80 characters).
(4) Character generator ROM
(5) 160 different 5x7 dot-matrix character patterns.
(6) Character generator RAM
(7) 8 different user programmed 5x7 dot-matrix patterns.
(8) Display data RAM and character generator RAM may be accessed by the microprocessor.

43 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

(9) Clear Display, Cursor Home, Display ON/OFF, Cursor ON/OFF, Blink Character, Cursor
Shift, Display Shift.
(10) Built-in reset circuit is triggered at power ON and Built-in oscillator.

Data can be placed at any location on the LCD. For 16×1 LCD, the address locations are:

Electrical Block Diagram:

Pin Description:

Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has 16 Pins (two
pins are extra in both for back-light LED connections).

44 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

Figure 3.15:LCD Display

VCC, VSS, and VEE:


While Vcc and Vss  provide +5V and ground, respectively, Vee is used for
controlling LCD contrast.

RS – register select:
There are two very important registers inside the LCD. The RS pin is used for their
selection as follows. If RS = 0, the instruction command code register is selected, allowing
the user to send a command such as clear display, cursor at home, etc. If RS = 1 the data
register is selected, allowing the user to send data to be displayed on the LCD.

R/W – read/write:
R/W input allows the user to write information to the LCD or read information
from it. R/W = 1 when reading; R/W =0 when writing.

E – Enable:
The enable pin is used by the LCD to latch information presented to its data pins.
When data is supplied to data pins, a high to low pulse must be applied to this pin in order for
the LCD to latch in the data present at the data pins. This pulse must be a minimum of 450 ns
wide.
D0 – D7:

45 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

The 8bit data pins, D0 – D7, are used to send information to the LCD or read the contents of
the LCD’s internal registers. To display letters and numbers, we send ASCII codes for the
letters A – Z, a – z, and numbers 0 – 9 to these pins while making RS = 1.There are also
instructions command codes that can be sent to the LCD to clear the display or force the
cursor to the home position or blink the cursor. Table below lists the instruction command
codes.

3.11 BUZZER:

A buzzer or beeper is a signaling device, usually electronic, typically used in automobiles,


household appliances such as a microwave oven, or game shows.

Digital systems and microcontroller pins lack sufficient current to drive the
circuits like relays, buzzer circuits etc. While these circuits require around 10milli amps to be
operated, the microcontroller’s pin can provide a maximum of 1-2milli amps current. For this
reason, a driver such as a power transistor is placed in between the microcontroller and the
buzzer circuit.

Figure 3.16: Buzzer

46 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

Vcc

CONTROLLER BUZZER

PIN

GROUND

The operation of this circuit is as follows:


The input to the base of the transistor is applied from the microcontroller port pin P1.0. The
transistor will be switched on when the base to emitter voltage is greater than 0.7V (cut-in
voltage). Thus when the voltage applied to the pin P1.0 is high i.e., P1.0=1 (>0.7V), the
transistor will be switched on and thus the buzzer will be ON.
When the voltage at the pin P1.0 is low i.e., P1.0=0 (<0.7V) the transistor will be in off state
and the buzzer will be OFF. Thus the transistor acts like a current driver to operate the buzzer
accordingly.

47 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

CHAPTER- 4
IMPLEMENTATION

4.1. INTRODUCTION:
Nowadays drinking water is the most precious and valuable for all the human beings,
drinking water utilities faces new challenges in real-time operation. This challenge occurred
because of limited water resources growing population, ageing infrastructure etc. Hence
therefore there is a need of better methodologies for monitoring the water quality.
Traditional methods of water quality involve the manual collection of water sample at
different locations, followed by laboratory analytical techniques in order the character the
water quality. Such approaches take longer time and no longer to be considered efficient .
Although the current methodologies analysis the physical, chemical and biological agents, it
has several drawbacks: a) poor spatiotemporal coverage b) it is labor intensive and high
cost(labor, operation; and equipment) c)the lack of real time water quality information to
enable critical decisions for public health protection. Therefore, there is a need for continuous
online water quality monitoring.
The online water monitoring technologies have made a significant progress for source
water surveillance and water plant operation. The use of their technologies having high cost
associated with installation and calibration of a large distributed array of monitoring sensors.
The algorithm proposed on the new technology must be suitable for particular area and for
large system is not suitable.
By focusing on the above issues our paper design and develop a low cost system for
real time monitoring of the water quality in IOT environment. In our design ARM-7 is used
as a core controller. The design system applies a specialized IOT module for accessing sensor
data from core controller to the mobile. The sensor data can be viewed on the mobile using a
special IP address. Additionally the IOT module also provides a Wi-Fi for viewing the data
on mobile.

48 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

4.2 WORKING:
In this project, we are using three sensors namely temperature sensor, level sensor and
pH sensor which are used to collect the information from the required water. These sensors
are connected to the LCP2148 ARM-7 32bit microcontroller . The data which is collected in
ARM-7 , is sent to the receiver and through UART The MAX232 is an IC, that converts
signals from an RS-232 serial port to signals suitable for use in TTL compatible digital logic
circuits. The MAX232 is a dual driver/receiver and typically converts the RX, TX, CTS and
RTS signals, as it plays a role for transmitting data from controller to the Wi-Fi module. The
output is viewed on LCD or Mobile phone through the Telnet software , through which
information about water parameters is displayed.

Figure 4.1: Output of Water quality parameters

49 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

CHAPTER-5
SOFTWARE DESIGNING

5.1 SOFTWARE TOOLS REQUIRED:

KEIL is a cross compiler. So first we have to understand the concept of compilers and
cross compilers. After then we shall learn how to work with keil.

CONCEPT OF COMPILER:

 Compilers are programs used to convert a High Level Language to object code. Desktop
compilers produce an output object code for the underlying microprocessor, but not for
other microprocessors. I.E the programs written in one of the HLL like ‘C’ will compile
the code to run on the system for a particular processor like x86 (underlying
microprocessor in the computer). For example compilers for Dos platform is different
from the Compilers for Unix platform So if one wants to define a compiler then compiler
is a program that translates source code into object code.

 CONCEPT OF CROSS COMPILER:

 A cross compiler is similar to the compilers but we write a program for the target
processor on the host processors. It means being in one environment you are writing a
code for another environment is called cross development. And the compiler used for
cross development is called cross compiler. So, the definition of cross compiler is a
compiler that runs on one computer but produces object code for a different type of
computer.

 Cross compilers are used to generate software that can run on computers with a new
architecture or on special-purpose devices that cannot host their own compilers. Cross
compilers are very popular for embedded development, where the target probably couldn't
run a compiler. Typically an embedded platform has restricted RAM, no hard disk, and
limited I/O capability. Code can be edited and compiled on a fast host machine (such as a
PC or Unix workstation) and the resulting executable code can then be downloaded to the

50 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

target to be tested. Cross compilers are beneficial whenever the host machine has more
resources (memory, disk, I/O etc) than the target.

Keil C Compiler is one such compiler that supports a huge number of host and target
combinations. It supports as a target to 8 bit microcontrollers like Atmel and Motorola etc.

WHY DO WE NEED CROSS COMPILER?

There are several advantages of using cross compiler. Some of them are described as
follows

• By using this compilers not only can development of complex embedded systems be
completed in a fraction of the time, but reliability is improved, and maintenance is easy.

• Knowledge of the processor instruction set is not required.

• A rudimentary knowledge of the ARM memory architecture is desirable but not necessary.

• Register allocation and addressing mode details are managed by the compiler.

• The ability to combine variable selection with specific operations improves program
readability.

• Keywords and operational functions that more nearly resemble the human thought process
can be used.

• Program development and debugging times are dramatically reduced when compared to
assembly language programming.

• The library files that are supplied provide many standard routines (such as formatted output,
data conversions, and floating-point arithmetic) that may be incorporated into your
application.

• Existing routine can be reused in new programs by utilizing the modular programming
techniques available with C.

• The C language is very portable and very popular. C compilers are available for almost all
target systems. Existing software investments can be quickly and easily converted from or

51 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

adapted to other processors or environments. Now after going through the concept of


compiler and cross compilers lets we start with Keil C cross compiler.

Keil C CROSS COMPILER: Keil is a German based Software development company. It


provides several development tools like

• IDE (Integrated Development environment).

• Project Manager.

• Simulator.

• Debugger.

• C Cross Compiler, Cross Assembler, Locator/Linker.

Keil Software provides you with software development tools for the ARM family of
microcontrollers. With these tools, you can generate embedded applications for the multitude
of ARM derivatives. Keil provides following tools for ARM development .

 ARM Optimizing C Cross Compiler,

 ARM Macro Assembler,

 ARM-7 Utilities (linker, object file converter, library manager),

 Source-Level Debugger/Simulator,

 µVision for Windows Integrated Development Environment.

 The keil ARM tool kit includes three main tools, assembler, compiler and linker. An
assembler is used to assemble your ARM assembly program. A compiler is used to
compile your C source code into an object file.

ARM project development cycle: -

These are the steps to develop ARM project using keil

1. Create source files in C or assembly.

52 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

2. Compile or assemble source files.

3. Correct errors in source files.

4. Link object files from compiler and assembler.

5. Test linked application.

PROLOAD:
 Proload is software which accepts only hex files. Once the machine code is
converted into hex code, that hex code has to be dumped into the microcontroller
and this is done by the Proload. Proload is a programmer which itself contains a
microcontroller in it other than the one which is to be programmed.
 This microcontroller has a program in it written in such a way that it accepts the
hex file from the Keil compiler and dumps this hex file into the microcontroller
which is to be programmed.
 As the Proload programmer kit requires power supply to be operated, this power
supply is given from the power supply circuit designed above. It should be noted
that this programmer kit contains a power supply section in the board itself but in
order to switch on that power supply, a source is required. Thus this is
accomplished from the power supply board with an output of 12volts.

Figure 5.1: ARM DEVICE PROGRAMMER

FEATURES:
 Auto Identify connected hardware and devices.
 Error checking and verification in-built.

53 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

 Lock of programs in chip supported to prevent program copying.


 Auto Erase before writing and Auto Verify after writing.
 Informative status bar and access to latest programmed file .
 Simple and Easy to use.

54 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

DESCRIPTION:

 It is simple to use and low cost, yet powerful flash microcontroller programmer for
the ARM series. It will Program, Read and Verify Code Data, Write Lock Bits, Erase
and Blank Check. All fuse and lock bits are programmable.
 This programmer has intelligent onboard firmware and connects to the serial port. It
can be used with any type of computer and requires no special hardware. All that is
needed is a serial communication ports which all computers have.
 All devices have signature bytes that the programmer reads to automatically identify
the chip. No need to select the devic0e. type, just plug it in and go! All devices also
have a number of lock bits to provide various levels of software and programming
protection. These lock bits are fully programmable using this programmer. Lock bits
are useful to protect the program to be read back from microcontroller only allowing
erase to reprogram the microcontroller. The programmer connects to a host computer
using a standard RS232 serial port. All the programming 'intelligence' is built into
the programmer so you do not need any special hardware to run it. Programmer
comes with window based software for easy programming of the devices.

Figure 5.2: Proload programmer device

55 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

CHAPTER-6
RESULT ANALYSIS CONCLUSION AND FUTURE SCOPE

6.1 SIMULATION RESULT:

Figure 6.1 Output using Keil-microvision3

6.2 APPLICATIONS:

56 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

6.3 CONCULSION:

6.4 FUTURE SCOPES:

REFERENCES

 www.national.com

 www.nxp.com

 www.8052.com

 www.microsoftsearch.com

 www.geocities.com

 www.keil.com

57 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

APPENDICES

#include <lpc214x.h> //21007BB4B15F 18008D991A16


#include <stdio.h>
#include <string.h> //192.168.4.1-telnet port-23
#include "lcd.h"
#include "serial.h"
//#include "gsm.h"
#include "gpio.h"
#define ON '1'//0x31
#define OFF '0' //0x30
#define lvl1 P0_3
#define lvl2 P0_4
#define buzzer P0_5
unsigned int memsx=0,memsy=0;
unsigned int temp=0;
unsigned char gchr='x',gchr1='x';
void serial0_RxISR(void) __irq;
unsigned long int as1()
{
AD0CR&=0XFFFFFF00;
AD0CR|=0X01000002;
delay(500);
while(!(AD0DR1&0X80000000));
return ((AD0DR1 >> 6) & 0x03FF);
}
unsigned long int as2()
{
AD0CR&=0XFFFFFF00;
AD0CR|=0X01000004;
//delay(500);
while(!(AD0DR2&0X80000000));
return((AD0DR2 >> 6) & 0x03FF);

58 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

}
unsigned long int as3()
{
AD0CR&=0XFFFFFF00;
AD0CR|=0X01000008;
//delay(500);
while(!(AD0DR3&0X80000000));
return((AD0DR3 >> 6) & 0x03FF);
}

void pin()
{
PINSEL0=0X00050005;//SELECTING PIN OPERATION
PINSEL1=0X15000000;
PINSEL2=0X00000000;
IODIR0=0xffffffff;
//IODIR0=0X00000000|sensor1|sensor2;// as output and 2 pins as input
IODIR0 &= ~(lvl1|lvl2);
IODIR1=0XFFFFFFFF;//PORT1 AS OUTPUT
IOCLR1=0XFFFFFFFF;
AD0CR=0X00210600;// ADC CONTROL REGISTER
//IOPIN0|=0X0000001C;
//IOSET0=sensor1|sensor2;
}
/*char inp0(char _bit)
{
unsigned long c;
c = 1<<_bit; // Calculate digit to configuration for input port
IODIR0 &= ~c; // Set input port from parameter _bit
return((IOPIN0 & c)>>_bit); // Read and return data bit
}*/

int inp0(int pinNumber)


{

59 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

// Read the current state of all pins in GPIO block 0


int pinBlockState = IOPIN0;

// Read the value of 'pinNumber'


int pinState = (pinBlockState & (/*1 <<*/ pinNumber)) ? 1 : 0;

// Return the value of pinState


return pinState;
}
void InitSerial0Int(unsigned isrPtr)
{
U0IER = 0x01;
VICVectCntl0 = 0x00000026; //select a priority slot for a given interrupt
VICVectAddr0 = (unsigned long)isrPtr; //pass the address of the IRQ into the VIC
slot
VICIntEnable |= 0x00000040; //enable interrupt2
}

unsigned char count=0,gps_location[26];


void gps()
{
while(receive_1()!='C');
for(count=0;count<14;count++)
{
receive_1();
}
for(count=0;count<24;count++)
{
gps_location[count]=receive_1();
}
}

60 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

void lcdbasic()
{
clcd(1);
stringlcd(0x80,"T:");//0x82,3,4
stringlcd(0x86,"L:"); //0x88,9,a
stringlcd(0xc0,"H:");//0xc2,3,4
}
void okc()
{
unsigned char rr;
do{
rr = receive_0();
}while(rr != 'K');
}
void wifiinit()
{
stringlcd(0x80,"IOT Initilizing");
string_0("AT\r\n"); delay(1500);
//okc();
string_0("ATE0\r\n");
okc();
string_0("AT+CWMODE=3\r\n");
delay(1500);
// string_0("AT+CWSAP=\"org_6547\",\"connectnow\",5,0\r\n");
delay(1500);
string_0("AT+CIPMUX=1\r\n");
delay(1500);
string_0("AT+CIPSERVER=1,23\r\n");
delay(1500);
stringlcd(0x80,"WAITING FOR CONNCT");

}
void sendwifi(unsigned char *chr,unsigned int length)
{

61 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

unsigned char temp[20];


string_0("AT+CIPSEND=0,");
sprintf(temp,"%u",length);
string_0(temp);
string_0("\r\n");
while(receive_0()!='>');
delay(100);
string_0(chr);
}

void send wifitemp()


{
string_0("AT+CIPSEND=0,9\r\n");
//sprintf(temp,"%u",length);
//string_0("4");
// conv_serial_1(temp);
//string_0("\r\n");
while(receive_0()!='>');
delay(100);
// string_1(chr);
string_0("Temp:");
conv_serial_0(temp);
// string_0("\r\n");
}

unsigned char mob1[11];//="9030059841\0";


unsigned char mob2[12];
unsigned int card=0,set1=0,set2=0,set3=0,hb=0,cnt=0,ht=0,loop=0;
unsignedchar
rfid_t[15],rfid_0[13]="140071C70FAD\0",rfid_1[13]="140071DCA61F\0",rfid_2[13]="8400
81160E1D\0",rfid_3[13]="FE006E2F5BE4\0";
unsigned char msg1[10],msg2[10];

62 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

void main() //gsm modem is connected to serial0 and system is connected to


serial1
{
unsigned char rec='X',rec1='x',p;
unsigned long int countv=0,cnt=0,hc=0,ht=0;
unsigned int tempv=0,phv=0;

for(p=0;p<14;p++){rfid_t[p]=0;}
pin();

IOCLR0=buzzer;
ser_init_0(0x61,0x00);
ser_init_1(0x61,0x00); //serial initilization
initlcd(); //Energy Efficient Ethernet for Real-Time Industrial Networks
stringlcd(0x80,"IOT BASED WATER QUALITY");
delay(1000); //gprs();
clcd(1);
wifiinit();
while(receive_0()!='L');
delay(400);
stringlcd(0x80,"CONNECTED");
delay(2500);
clcd(1);
stringlcd(0x80,"T:");//0x83,4,5
stringlcd(0x88,"L:");//0xc3,4,5
stringlcd(0xc0,"PH:");
// InitSerial0Int((unsigned int)serial0_RxISR);

while(1)
{
tempv = as1();
tempv = (tempv/3);
clcd(0x82);conv(tempv);delay(500);
string_0("AT+CIPSEND=0,9\r\n"); delay(900);

63 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

string_0("Temp:");conv_serial_0(tempv);
delay(800);
if(tempv > 40)
{
IOSET0=buzzer;
}
if(tempv < 40)
{
IOCLR0=buzzer;
}
phv = as2();
//phv = (phv/3);
clcd(0xC4);conv(phv);
delay(500);
if(phv > 0 && phv < 200)
{
stringlcd(0xc4,"000 ");
string_0("AT+CIPSEND=0,8\r\n"); delay(900);
string_0("Ph-000\r\n");//6
delay(800);
}

if(phv == 0)// && phv < 20)


{
stringlcd(0xc4,"000 ");
string_0("AT+CIPSEND=0,8\r\n"); delay(900);
string_0("Ph-000\r\n");//6
delay(800);
}
/*
if(phv > 40 && phv < 130)
{
stringlcd(0xc4,"0.7 ");
string_0("AT+CIPSEND=0,8\r\n"); delay(900);

64 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

string_0("Ph-0.7\r\n");//6
delay(800);
}

if(phv > 130 && phv < 160)


{
stringlcd(0xc4,"0.72");
string_0("AT+CIPSEND=0,9\r\n"); delay(900);
string_0("Ph-0.72\r\n");//6
delay(800);
}

if(phv > 160 && phv < 170)


{
stringlcd(0xc4,"0.75");
string_0("AT+CIPSEND=0,9\r\n"); delay(900);
string_0("Ph-0.75\r\n");//6
delay(800);
} */
/*
if(phv > 176 && phv < 200)
{
stringlcd(0xc4,"0.77");
string_0("AT+CIPSEND=0,9\r\n"); delay(900);
string_0("Ph-0.77\r\n");//6
delay(800);
} */

if(phv > 200 && phv < 210)


{
stringlcd(0xc4,"0.79");
string_0("AT+CIPSEND=0,9\r\n"); delay(900);
string_0("Ph-0.79\r\n");//6
delay(800);

65 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

if(phv > 210 && phv < 230)


{
stringlcd(0xc4,"0.80");
string_0("AT+CIPSEND=0,9\r\n"); delay(900);
string_0("Ph-0.80\r\n");//6
delay(800);
}
if(phv > 230 && phv < 250)
{
stringlcd(0xc4,"0.82");
string_0("AT+CIPSEND=0,9\r\n"); delay(900);
string_0("Ph-0.82\r\n");//6
delay(800);
}

if(phv > 250)// && phv < 250)


{
stringlcd(0xc4,"0.84");
string_0("AT+CIPSEND=0,9\r\n"); delay(900);
string_0("Ph-0.84\r\n");//6
delay(800);
}
if(inp0(lvl1) == 0 && inp0(lvl2) == 0)
{
string lcd(0x8A,"Empty");
string_0("AT+CIPSEND=0,13\r\n"); delay(900);
string_0("LEVEL-EMPTY\r\n");//6
delay(800);

IOSET0=buzzer;
}
if(inp0(lvl1) == 0 && inp0(lvl2) == 1)

66 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

{
stringlcd(0x8A,"Lvl-1");
IOCLR0=buzzer;
string_0("AT+CIPSEND=0,9\r\n"); delay(900);
string_0("LEVEL-1\r\n");//6
delay(800);
}

if(inp0(lvl1) == 1 && inp0(lvl2) == 1)


{
string lcd(0x8A,"Full ");
IOCLR0=buzzer;
string_0("AT+CIPSEND=0,12\r\n"); delay(900);
string_0("LEVEL-FULL\r\n");//6
delay(800);
}
/*
string_0("AT+CIPSEND=0,10\r\n"); delay(900);
string_0("Count:");//6
conv_serial_0(count); //4
*/

delay(500);
}//end of whil1e
}
void serial0_RxISR(void) __irq
{
unsigned char ch,cht1;

cht1 = receive_0();
if(cht1 == '+'){

for(ch=0;ch<8;ch++){receive_0();}

67 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

gchr = receive_0(); }

/* for(ch=0;ch<12;ch++){rfid_t[ch]=receive_0();}
IOCLR0=relay;
if(strcmp(rfid_t,rfid_0)==0){card = 1;set3=1;}
if(strcmp(rfid_t,rfid_1)==0){card = 2;set3=1;}
if(strcmp(rfid_t,rfid_2)==0){card = 3;set3=1;}*/

VICVectAddr = 0x00000000; //Dummy write to signal end of interrupt


}

68 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

69 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

70 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING
REAL TIME WATER QUALITY MONITORING THROUGH IOT

71 | P a g e
INSTITUTE OF AERONAUTICAL ENGINEERING

You might also like