Вы находитесь на странице: 1из 69

WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

CHAPTER 1. INTRODUCTION

1.1 GENERAL
The main aim of the project is to design a system which will monitor and control
the water level in the dams and also intimates the concerned authority when the water
level exceeds the limit.

1.2 OBJECTIVE
The main objective of this project is to design an embedded based control
warning system limited condition by making use of sensor. This system use sensors to
detect the variation in the water level using logic controller. The controller uses the
embedded system to work as the computing platform.

1.3 EXISTING SYSTEM

Fig: 1.1 Existing System Block Diagram

The existing system uses manual operation to control and monitor the water level
Which is more manual and require more human involvement to monitor or to get the
exact location.

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 1|P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

1.4 DISADVANTAGES OF EXISTING SYSTEM


The system uses manual operation for monitoring and forwarding the
information. This proves to a disadvantage in existing system.

1.5 PROPOSED SYSTEM

Fig: 1.2 Proposed System Block Diagram


The proposed includes sensors information, level estimation. This research tries
to design a set of embedded intelligent level controlling system to promote the safety.
By using microcontroller to transform the signal from the sensors. The purpose of the
project is to monitor the water level in dams using sensors. This system also checks
continuously the water flow in dams and whenever water level exceeds the higher limit
sends SMS to the concerned person using GSM technology. The system also uses a
Ethernet / Wi-Fi so that the flood levels can be shared real time on the web.

1.6 ADVANTAGES OF PROPOSED SYSTEM


The proposed system comes with advantage of using sensor instead of manual
operations. The stability of this system improved a lot if we could use the sensors which
are with superior features of the performance. The major advantage of this design is Fast
Response, Highly Reliable and longtime stability. It has multiple transmitter and receiver
ports. In 2560 model there are more number of pins where compare to Arduino Uno.

CHAPTER 2. LITERATURE SURVEY

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 2|P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

2.1 GENERAL INTRODUCTION TO EMBEDDED SYSTEM


Embedded systems are designed to do some specific task rather than be a
general-purpose computer for multiple task. Some also have real time performance
constraints that must met, for reason such as safety and usability; others may have low
or no performance requirements, allowing the system hardware to be simplified to
reduce costs.
An embedded system is not always a separate block very often it is physically
built in to the device it is controlling. The software written for embedded systems is often
called firmware, and is stored in read only memory or flash convector chips rather than a
disk drive. It often runs with limited computer hardware resources: small or no keyboard,
screen and little memory.

To perform any application in the embedded system we require microprocessor


and microcontroller. In the microprocessor, an external memory is connected which
increases the size of the microprocessor and multiple operations are being performed by
the microprocessor but whereas in the microprocessor the memory is inbuilt and also, we
can use this controller only for the specific applications where the speed is increased so
most probably microcontrollers are used in the different applications in the embedded
systems rather than microprocessor.

Fig: 2.1 Layered Architecture of Embedded Systems.

2.2 MICROPROCESSOR

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 3|P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

Microprocessor is typically found in a desktop PC or laptop and contains a CPU


and an external memory interface plus various I/O buses to connect to the outside world
such as SPI, I2C, UART, USB, LCD and others. Microprocessors will also have an
external crystal to provide a clock. Most microprocessors have no read-only memory on
the chip; instead there is an external chip on the motherboard where the initial boot code
is located. On Intel-based PC's, this is called the Basic Input/output System (BIOS) and
also contains I/O routines in addition to the initial boot code. The boot code starts by
doing a Power-On Self-Test (POST) and then looks to see where to load the next stage
of the boot code from a hard drive, CD, a floppy disk. This second level boot then loads
the operating system.

Some microprocessors have a small amount of read-only memory that contains


the initial boot code. I refer to the boot code as read-only; actually, on some systems, it
can be updated. However, this is fairly risky; if something goes wrong the system may
no longer boot. Unlike microcontrollers, which execute their programs out of read-only
memory, after booting up microprocessors load their programs into external RAM and
execute it from there.

Fig: 2.2 Block Diagram of Microprocessor

2.3 MICROCONTROLLER

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 4|P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

A microcontroller on the other hand is a standalone single-chip IC that contains a


CPU, read-only memory to store the program, RAM to store variables used in the
execution of the program, and various I/O buses to connect to the outside world such as
SPI, I2C, UART and others. By itself, it cannot execute any programs without being
programmed via an external interface to a PC. A microcontroller is an integrated chip
that is often part of an embedded system.

It includes a CPU, RAM, ROM, I/O ports, and timers like a standard computer,
but because they are designed to execute only a single specific task to control a single
system, they are much smaller and simplified so that they can include all the functions
required on a single chip. Unlike a microprocessor, which is a general-purpose chip used
to create a multi-function computer or device and requires multiple chips to handle
various tasks, this device is meant to be more self-contained and independent, and
functions as a tiny, dedicated computer. A microcontroller may also need an external
crystal to provide a clock, however some have an internal clock. Some microcontrollers
have two sections of flash memory; one to hold initialization (boot) code, and another to
store the application. This makes it easier to update the application code in-place.

Fig: 2.3 Block Diagram of Microcontroller

2.4 ARDUINO

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 5|P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

Arduino is an open-source electronics platform based on easy-to-use hardware


and software. Arduino boards are able to read inputs - light on a sensor, a finger on a
button, or a Twitter message - and turn it into an output - activating a motor, turning on
an LED, publishing something online. You can tell your board what to do by sending a
set of instructions to the microcontroller on the board. To do so you use the Arduino
programming language (based on Wiring), and the Arduino Software (IDE), based on
Processing.

An Arduino is a PCB containing an Atmel AVR microcontroller and usually


providing a set of connectors in a standard pattern. The microcontroller is typically
preprogrammed with a "bootloader" program that allows a program (called a "sketch") to
be loaded into the microcontroller over a TTY serial connection (or virtual serial over
USB connection) from a PC.

Fig: 2.4 Block Diagram of Arduino Mega


An Arduino is such a board, and contains a microcontroller, typical an 8-bit AVR
such as the ATmega8, ATmega168, ATmega328, ATmega1280, and ATmega2560, plus
power supplies, crystal, and female headers to interface with various peripheral boards.

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 6|P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

These peripheral boards are called shields, and are designed to stack on top of each
other. Example shields are motor control boards, general I/O boards, relay boards,
Ethernet boards, and LCD's, typically with a touch-screen.

In addition to the hardware described above, Arduino also come with a cross-
platform Integrated Development Environment (IDE) written in Java. It was designed to
introduce programming to artists and other beginners, much as the BASIC language did
50 years ago. A program for Arduino is called a sketch.

Arduino programs are written in C or C++, however many of the details are
hidden from the user: only two functions (called by the system) need to be defined to
make a program that continually loops (which is typically for embedded programs) The
IDE comes with a software library called "Wiring" which can be used for common
input/output operations.

2.5 ADVANTAGES OF ARDUINO OVER MICROCONTROLLER

There are many Advantages of Using Arduino over simple microcontroller. Some of
them are as follows:

1. Ready to use: Its ready to use structure makes it really easy to use. You dont have
to take care of burner, fuse settings, Serial Monitor Softwares etc.
2. Effortless functions: There are many functions present in the software of Arduino
which makes coding so easy and fast that is not possible with simple microcontroller.
3. Large Community: Well it is obvious now that everyone is using Arduino
nowadays thats why you can get help anytime from anywhere whenever you will
have stuck somewhere.
4. Inexpensive: Arduino boards are relatively inexpensive compared to other
microcontroller platforms. The pre-assembled Arduino modules cost less than 300
rupees.

5. Cross-platform: The Arduino Software (IDE) runs on Windows, Macintosh OSX,


and Linux operating systems. Most microcontroller systems are limited to Windows.

CHAPTER 3. PROJECT DESCRIPTION

3.1 BLOCK DIAGRAM OF THE PROJECT

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 7|P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

Fig: 3.1 Block Diagram of the Project

3.2 OVERVIEW OF THE PROJECT

The Project Water Level Meter for Alerting Population about floods by using
Atmega 2560 is designed to alert the population about flood situation to avoid the loss
of human life. The three water level sensors which is generally immersed in reservoirs
(mostly in flood affected areas). These water level sensors are pressure based (WL400)
sensor which senses the increase in water level based on the increasing level of pressure
in water. The three sensors are indicated for three levels.

1. Level1: Water level is normal.


2. Level2: Water Level is continuously increasing.
3. Level 3: Flood Situation has occurred.

These three sensors continuously monitor the level of water and send the status of
the level of water to Arduino board which in turn sends this information to the
concerned authority through GSM (Global System for Mobile Communication) modem
via SMS and also to the webpage of officials who are monitoring the continuous
situation of reservoir via ethernet module. If the official gets the information of level1,
then the situation is under control. If the official gets the information of level2, then the
situation of flood is going to arise, as water level is continuously increasing, this makes
the officials to take action to vacant the flood prone areas. The third level 3, informs the

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 8|P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

official that flood has occurred. So, As the water level 2 is received, this helps to save
the human life, as it requires minimum 6 hours to fill the reservoir if continuously water
level is raising. This time is utilized to save the human life.

3.3 SCHEMATIC OF THE PROJECT

Fig: 3.3 Schematic of the Project

3.4 WORKING OF THE PROJECT


The complete hardware of the project entitled Water Level Meter for Alerting
Population about floods by using ATMEGA 2560 works on the +5V power supply
which is given to the Arduino board from power jack. When the Arduino mega boards
get on, the three Water Level Sensors WL400 are interfaced to the Arduino board

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 9|P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

through 3 analog pins (A0, A1 and A2) which senses the water level and sends the
analog output to the Atmega 2560 microcontroller inbuilt in Arduino Mega board. There
are inbuilt Analog to Digital converters on the board which converts the analog output of
sensors to digital input of microcontroller.
These sensors continuously send the status of water level to microcontroller. This
status of water level is displayed on 16X2 LCD (Liquid Crystal Display), as it is
interfaced with Arduino mega board parallelly (through its six PWM digital pins).
Whenever the 16X2 LCD chip enable is active Low and read signal is active high the
LCD reads the characters from microcontroller and display it on LCD. The same status
is received to the concerned authority through GSM modem which is interfaced through
one of the serial ports of Arduino board. The GSM modem gets active when it receives
respective AT commands from the Microcontroller when it senses the status of water
level in reservoir. Whenever the AT command is received by GSM modem, according to
the AT command it sends the respective status to concerned official via SMS. The Serial
port(RS232) cannot be directly interfaced with Atmega 2560 Microcontroller, as the
voltage levels of GSM (Global System for Mobile Communication) and Atmega 2560
Microcontroller are different, so as to make the GSM (Global System for Mobile
Communication) modem communicate with Microcontroller or vice versa, MAX232
voltage level converter is being interfaced between them.
And at the Same time ethernet Module (ENC28J60) is also interfaced with
microcontroller through Serial peripheral interface(SPI) pins (50,51 and 52) of Arduino
board. When the ethernet receives the information about sensors that is being displayed
on the webpage on Personal computer which is again interfaced through serial port and
MAX232 voltage converter. In brief, whenever water level change is sensed the
information is displayed on LCD through parallel port and the same information is
received by concerned official through GSM via SMS or through webpage via ethernet
communication protocol on Personal computer. This makes the concerned official to
take action to avoid loss of human life in flood prone areas within the time limit.
CHAPTER 4. HARDWARE DESCRIPTION

4.1 LIST OF HARDWARE USED


1. Arduino Mega Development board
2. Atmega2560 Microcontroller
3. Water level sensors WL400

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 10 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

4. (ENC28J60) Ethernet controller


5. Global System for Mobile Communication(GSM) Modem
6. 16X2 Liquid Crystal Display(LCD)
7. Power supply
8. Personal computer

4.2 ARDUINO MEGA


The Mega 2560 is a microcontroller board based on the ATmega2560. It has 54
digital input/output pins (of which 15 can be used as PWM outputs), 16 analog inputs, 4
UARTs (hardware serial ports), a 16 MHz crystal oscillator, a USB connection, a power
jack, an ICSP header, and a reset button. It contains everything needed to support the
microcontroller; simply connect it to a computer with a USB cable or power it with a
AC-to-DC adapter or battery to get started. The Mega 2560 board is compatible with
most shields designed for the Uno and the former boards Duemilanove or Diecimila.
The Mega 2560 is an update to the Arduino Mega, which it replaces.

Figure 4.2 Arduino Mega

Table 4.1 Specifications of Arduino Mega

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 11 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

Microcontroller ATmega 2560


Operating Voltage 5V
Input Voltage
7-12V
(recommended)
Input Voltage (limit) 6-20V
Digital I/O Pins 54 (of which 15 provide PWM output)
Analog Input Pins 16
DC Current per I/O Pin 20 mA
DC Current for 3.3V Pin 50 mA
256 KB of which 8 KB used by boot
Flash Memory
loader
SRAM 8 KB
EEPROM 4 KB
Clock Speed 16 MHz
LED_BUILTIN 13
Length 101.52 mm
Width 53.3 mm
Weight 37 g

Memory
The ATmega2560 has 256 KB of flash memory for storing code (of which 8 KB
is used for the boot loader), 8 KB of SRAM and 4 KB of EEPROM (which can be read
and written with the EEPROM library).

Communication
The Mega 2560 board has a number of facilities for communicating with a
computer, another board, or other microcontrollers. The ATmega2560 provides four
hardware UARTs for TTL (5V) serial communication. The Arduino Software (IDE)
includes a serial monitor which allows simple textual data to be sent to and from the
board. The RX and TX LEDs on the board will flash when data is being transmitted via
the ATmega8U2/ATmega16U2 chip and USB connection to the computer (but not for
serial communication on pins 0 and 1). A Software Serial library allows for serial
communication on any of the Mega 2560's digital pins. The Mega 2560 also supports

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 12 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

TWI and SPI communication. The Arduino Software (IDE) includes a Wire library to
simplify use of the TWI bus.

Physical Characteristics and Shield Compatibility

The maximum length and width of the Mega 2560 PCB are 4 and 2.1 inches
respectively, with the USB connector and power jack extending beyond the former
dimension. The Mega 2560 is designed to be compatible with most shields designed for
the Uno and the older Diecimila or Duemilanove Arduino boards. Digital pins 0 to 13
(and the adjacent AREF and GND pins), analog inputs 0 to 5, the power header, and
ICSP header are all in equivalent locations. Furthermore, the main UART (serial port) is
located on the same pins (0 and 1), as are external interrupts 0 and 1 (pins 2 and 3
respectively). SPI is available through the ICSP header on both the Mega 2560 and
Duemilanove / Diecimila boards.

Automatic (Software) Reset

Rather than requiring a physical press of the reset button before an upload, the
Mega 2560 is designed in a way that allows it to be reset by software running on a
connected computer. One of the hardware flow control lines (DTR) of the ATmega8U2
is connected to the reset line of the ATmega2560 via a 100 nano-farad capacitor. When
this line is asserted (taken low), the reset line drops long enough to reset the chip. The
Arduino Software (IDE) uses this capability to allow you to upload code by simply
pressing the upload button in the Arduino environment. This means that the boot loader
can have a shorter timeout, as the lowering of DTR can be well-coordinated with the
start of the upload.

When the Mega 2560 board is connected to either a computer running Mac OS X
or Linux, it resets each time a connection is made to it from software (via USB). For the
following half-second or so, the boot loader is running on the ATMega2560. While it is
programmed to ignore malformed data (i.e. anything besides an upload of new code), it
will intercept the first few bytes of data sent to the board after a connection is opened. If
a sketch running on the board receives one-time configuration or other data when it first
starts, make sure that the software with which it communicates waits a second after
opening the connection and before sending this data.

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 13 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

.
Figure 4.2 ARDUINO MEGA Pin Diagram

Input and Output mapping between Arduino pins and Atmega2560 ports
Each of the 54 digital pins on the Mega can be used as an input or output,
using pinMode(), digitalWrite(), and digitalRead(). functions. They operate at 5 volts.
Each pin can provide or receive 20 mA as recommended operating condition and has an
internal pull-up resistor (disconnected by default) of 20-50 k ohm. A maximum of 40mA

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 14 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

is the value that must not be exceeded to avoid permanent damage to the
microcontroller.

Table 4.2 Arduino Mega 2560 PIN mapping

Pin Number Pin Name Mapped Pin Name


1 PG5 ( OC0B ) Digital pin 4 (PWM)
2 PE0 ( RXD0/PCINT8 ) Digital pin 0 (RX0)
3 PE1 ( TXD0 ) Digital pin 1 (TX0)
4 PE2 ( XCK0/AIN0 )
5 PE3 ( OC3A/AIN1 ) Digital pin 5 (PWM)
6 PE4 ( OC3B/INT4 ) Digital pin 2 (PWM)
7 PE5 ( OC3C/INT5 ) Digital pin 3 (PWM)
8 PE6 ( T3/INT6 )
9 PE7 ( CLKO/ICP3/INT7 )
10 VCC VCC
11 GND GND
12 PH0 ( RXD2 ) Digital pin 17 (RX2)
13 PH1 ( TXD2 ) Digital pin 16 (TX2)
14 PH2 ( XCK2 )
15 PH3 ( OC4A ) Digital pin 6 (PWM)
16 PH4 ( OC4B ) Digital pin 7 (PWM)
17 PH5 ( OC4C ) Digital pin 8 (PWM)
18 PH6 ( OC2B ) Digital pin 9 (PWM)
19 PB0 ( SS/PCINT0 ) Digital pin 53 (SS)
20 PB1 ( SCK/PCINT1 ) Digital pin 52 (SCK)
21 PB2 ( MOSI/PCINT2 ) Digital pin 51 (MOSI)
22 PB3 ( MISO/PCINT3 ) Digital pin 50 (MISO)
23 PB4 ( OC2A/PCINT4 ) Digital pin 10 (PWM)
24 PB5 ( OC1A/PCINT5 ) Digital pin 11 (PWM)
25 PB6 ( OC1B/PCINT6 ) Digital pin 12 (PWM)
26 PB7 ( OC0A/OC1C/PCINT7 ) Digital pin 13 (PWM)
27 PH7 ( T4 )

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 15 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

28 PG3 ( TOSC2 )
29 PG4 ( TOSC1 )
30 RESET RESET
31 VCC VCC
32 GND GND
33 XTAL2 XTAL2
34 XTAL1 XTAL1
35 PL0 ( ICP4 ) Digital pin 49
36 PL1 ( ICP5 ) Digital pin 48
37 PL2 ( T5 ) Digital pin 47
38 PL3 ( OC5A ) Digital pin 46 (PWM)
39 PL4 ( OC5B ) Digital pin 45 (PWM)
40 PL5 ( OC5C ) Digital pin 44 (PWM)
41 PL6 Digital pin 43
42 PL7 Digital pin 42
43 PD0 ( SCL/INT0 ) Digital pin 21 (SCL)
44 PD1 ( SDA/INT1 ) Digital pin 20 (SDA)
45 PD2 ( RXDI/INT2 ) Digital pin 19 (RX1)
46 PD3 ( TXD1/INT3 ) Digital pin 18 (TX1)
47 PD4 ( ICP1 )
48 PD5 ( XCK1 )
49 PD6 ( T1 )
50 PD7 ( T0 ) Digital pin 38
51 PG0 ( WR ) Digital pin 41
52 PG1 ( RD ) Digital pin 40
53 PC0 ( A8 ) Digital pin 37
54 PC1 ( A9 ) Digital pin 36
55 PC2 ( A10 ) Digital pin 35
56 PC3 ( A11 ) Digital pin 34
57 PC4 ( A12 ) Digital pin 33
58 PC5 ( A13 ) Digital pin 32
59 PC6 ( A14 ) Digital pin 31

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 16 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

60 PC7 ( A15 ) Digital pin 30


61 VCC VCC
62 GND GND
63 PJ0 ( RXD3/PCINT9 ) Digital pin 15 (RX3)
64 PJ1 ( TXD3/PCINT10 ) Digital pin 14 (TX3)
65 PJ2 ( XCK3/PCINT11 )
66 PJ3 ( PCINT12 )
67 PJ4 ( PCINT13 )
68 PJ5 ( PCINT14 )
69 PJ6 ( PCINT 15 )
70 PG2 ( ALE ) Digital pin 39
71 PA7 ( AD7 ) Digital pin 29
72 PA6 ( AD6 ) Digital pin 28
73 PA5 ( AD5 ) Digital pin 27
74 PA4 ( AD4 ) Digital pin 26
75 PA3 ( AD3 ) Digital pin 25
76 PA2 ( AD2 ) Digital pin 24
77 PA1 ( AD1 ) Digital pin 23
78 PA0 ( AD0 ) Digital pin 22
79 PJ7
80 VCC VCC
81 GND GND
82 PK7 ( ADC15/PCINT23 ) Analog pin 15
83 PK6 ( ADC14/PCINT22 ) Analog pin 14
84 PK5 ( ADC13/PCINT21 ) Analog pin 13
85 PK4 ( ADC12/PCINT20 ) Analog pin 12
86 PK3 ( ADC11/PCINT19 ) Analog pin 11
87 PK2 ( ADC10/PCINT18 ) Analog pin 10
88 PK1 ( ADC9/PCINT17 ) Analog pin 9
89 PK0 ( ADC8/PCINT16 ) Analog pin 8
90 PF7 ( ADC7 ) Analog pin 7
91 PF6 ( ADC6 ) Analog pin 6

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 17 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

92 PF5 ( ADC5/TMS ) Analog pin 5


93 PF4 ( ADC4/TMK ) Analog pin 4
94 PF3 ( ADC3 ) Analog pin 3
95 PF2 ( ADC2 ) Analog pin 2
96 PF1 ( ADC1 ) Analog pin 1
97 PF0 ( ADC0 ) Analog pin 0
98 AREF Analog Reference
99 GND GND
100 AVCC VCC

The Arduino Mega2560 has a resettable poly fuse that protects your computers
USB ports from shorts and over current. Although most computers provide their own
internal protection, the fuse provides an extra layer of protection. If more than 500 mA is
applied to the USB port, the fuse will automatically break the connection until the short
or overload is removed. The Arduino Software (IDE) uses this capability to allow you to
upload code by simply pressing the upload button in the Arduino environment.

This setup has other implications. When the Mega 2560 board is connected to
either a computer running Mac OS X or Linux, it resets each time a connection is made
to it from software (via USB). For the following half-second or so, the boot loader is
running on the ATMega2560. While it is programmed to ignore malformed data (i.e.
anything besides an upload of new code), it will intercept the first few bytes of data sent
to the board after a connection is opened.

If a sketch running on the board receives one-time configuration or other data


when it first starts, make sure that the software with which it communicates waits a
second after opening the connection and before sending this data.

In addition, some pins have specialized functions:

1. Serial 0: (RX) and 1 (TX); Serial 1: 19 (RX) and 18 (TX); Serial 2: 17 (RX) and 16
(TX); Serial 3: 15 (RX) and 14 (TX). Used to receive (RX) and transmit (TX) TTL
serial data. Pins 0 and 1 are also connected to the corresponding pins of the
ATmega16U2 USB-to-TTL Serial chip.
2. External Interrupts: 2 (interrupt 0), 3 (interrupt 1), 18 (interrupt 5), 19 (interrupt
4), 20 (interrupt 3), and 21 (interrupt 2). These pins can be configured to trigger an
interrupt on a low level, a rising or falling edge, or a change in level. PWM: 2 to 13
and 44 to 46. Provide 8-bit PWM output with the analogWrite() function.

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 18 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

3. SPI: 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS). These pins support SPI


communication using the SPI library.
4. LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH
value, the LED is on, when the pin is LOW, it's off.
5. TWI: 20 (SDA) and 21 (SCL). Support TWI communication using the Wire library.
The Mega 2560 has 16 analog inputs, each of which provide 10 bits of resolution.
6. AREF: Reference voltage for the analog inputs.
7. Reset: Bring this line LOW to reset the microcontroller. Typically used to add a reset
button to shields which block the one on the board.

4.3 ATMEGA 2560 MICROCONTROLLER


The Atmega 2560 is a low-power CMOS 8-bit microcontroller based on the AVR
enhanced RISC architecture. By executing powerful instructions in a single clock
cycle, theAtmega2560achieves throughputs approaching 1 MIPS per MHz allowing
the system designer to optimize power consumption versus processing speed.

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 19 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

Figure 4.3 ATMEGA 2560 Pin Diagram


The Atmega 2560 provides the following features: 64K/128K/256K bytes of In-
System Programmable Flash with Read-While-Write capabilities, 4Kbytes
EEPROM, 8Kbytes SRAM, 54/86 general purpose I/O lines, 32 general purpose
working registers, Real Time Counter (RTC), six flexible Timer/Counters with
compare modes and PWM, four USARTs, a byte oriented 2-wire Serial Interface, a
16-channel, 10-bit ADC with optional differential input stage with programmable
gain, programmable Watchdog Timer with Internal Oscillator ,an SPI serial port,

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 20 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

IEEE std. 1149.1 compliant JTAG test interface, also used for accessing the On-chip
Debug system and programming and six software selectable power saving modes.
AVR is a family of microcontrollers developed by Atmel beginning in 1996.
These are modified Harvard architecture 8-bit RISC single-chip microcontrollers.
AVR was one of the first microcontroller families to use on-chip flash memory for
program storage, as opposed to one-time programmable ROM, EPROM, or
EEPROM used by other microcontrollers at the time. AVR microcontrollers find
many applications as embedded systems; they are also used in the Arduino line of
open source board designs.

The On-chip ISP Flash allows the program memory to be reprogrammed in-
system through an SPI serial interface, by a conventional non-volatile memory
programmer, or by an On-chip Boot program running on the AVR core. The boot
program can us easy interface to download the application program in the application
Flash memory.

The Idle mode stops the CPU while allowing the SRAM, Timer/Counters, SPI
port, and interrupt system to continue functioning. The Power-down mode saves the
register contents but freezes the Oscillator, disabling all other chip functions until the
next interrupter Hardware Reset. In Power-save mode, the asynchronous timer
continues to run, allowing the user to maintain a timer base while the rest of the
device is sleeping.
In Standby mode, the Crystal/Resonator Oscillator is running while the rest of the
device is sleeping. This allows very fast start-up combined with low power
consumption. In Extended Standby mode, both the main Oscillator and the
Asynchronous Timer continue to run. Atmel offers the Q Touch library for
embedding capacitive touch buttons, sliders and wheels functionality into AVR
microcontrollers.

Table 4.3: ATMEGA 2560 Pin and port Description

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 21 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

The device is manufactured using the Atmel high-density nonvolatile memory


technology. Software in the Boot Flash section will continue to run while the
Application Flash section is updated, providing true Read-While-Write operation. By
combining an 8-bit RISC CPU with In-System Self-Programmable Flash on a
monolithic chip, the Atmel ATmega 2560is a powerful microcontroller that provides
a highly flexible and cost effective solution to many embedded control applications.
The Atmega 2560 AVR is supported with a full suite of program and system
development.
The On-chip ISP Flash allows the program memory to be reprogrammed in-
system through an SPI serial interface, by a conventional non-volatile memory
programmer, or by an On-chip Boot program running on the AVR core. The boot
program can us easy interface to download the application program in the application
Flash memory

4.4 WL400 WATER LEVEL SENSOR

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 22 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

Figure 4.4 WL400 water level sensor

Submersible Pressure Transducer for Level and Pressure

Global Water's WL400 Water Level Sensor submersible pressure transducer


consists of a solid-state pressure sensor encapsulated in a submersible stainless steel
13/16 diameter housing. The water level gauge uses a marine grade cable to connect the
water pressure sensor to the monitoring device. Each of Global Water's pressure
transducers has a two-wire 4-20 mA high level output, five full scales ranges, and is
fully temperature and barometric pressure compensated.

Low Level Range

The water depth indicator is available in a 0-3' full scale range which is ideal for
measuring shallow flows or small water level changes. The 0-3' range is great for
measuring flows in sewers, storm drains, weirs, flumes, lakes, tanks or any water body
that is less than 3' deep. The 0-3' water monitoring sensor accurately measures small
changes in water, even when the water's depth is only a few inches deep. Other metal
foil type sensors typically have serious problems at low level ranges because of
crinkling, stretching and drifting.

Protective Cap
The water sensor also utilizes a stainless steel micro-screen cap to protect the
sensing element. This protective cap has hundreds of openings, making fouling the
sensor with silt, mud or sludge virtually impossible.

Encapsulated Pressure Sensor

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 23 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

Global Water's Water Level Sensors are fully encapsulated with marine-grade
epoxy. The submersible pressure transducer's electronics are encased in marine grade
epoxy so that moisture can never leak in or work its way down the vent tube to cause
drift or level sensor failure (as is the case with other pressure sensors). The vent tube is
sealed directly to the sensing element, and any moisture that may enter the vent tube
only comes in contact with a silicon sensing device, not the electronics.

Output Signals

The WL400 water pressure sensors have a two-wire 4-20 mA output signal that
is linear with water depth. 10 to 36 VDC is required to operate the depth level sensor, so
the WL400 submersible pressure transducer can be operated from 12 or 24 VDC
systems. The 4-20 mA signal can run up to 3,000' from the sensor to the logging device.
Common twisted pair or electrical extension cord wire may be spliced to the vented
cable once the cable is out of the water. The 4-20 mA signal may be converted to 0.5 to
2.5 VDC by dropping the current signal across a 125-ohm resistor.

Features of WL400
1. High accuracy and reliability.
2. Completely submersible sensor and cable.
3. Compact, rugged design for easy installation.
4. Minimal maintenance and care.
5. Sensor compatible with most monitoring equipment
6. 4-20mA output
7. Vented cable for automatic barometric compensation
8. Multiple ranges available from 3 to 250 Wet-wet sensor eliminates vent tube
concerns Dynamic temperature compensation system Not affected by foam, wind
or rain
9. Monitors levels in groundwater wells, rivers, streams, tanks, lift stations and
open channels
Interfacing of Arduino with WL400

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 24 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

Figure 4.5 Interfacing Arduino with WL400

4.5 ETHERNET (ENC28J60)

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 25 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

The ENC28J60 is a stand-alone Ethernet controller with an industry standard


Serial Peripheral Interface (SPI). It is designed to serve as an Ethernet network
interface for any controller equipped with SPI. The ENC28J60 meets all of the IEEE
802.3 specifications. It incorporates a number of packet filtering schemes to limit
incoming packets. It also provides an internal DMA module for fast data throughput and
hardware assisted IP checksum calculations.
Communication with the host controller is implemented via two interrupt pins
and the SPI, with data rates of up to10 Mb/s. Two dedicated pins are used for LED link
and network activity indication. With the ENC28J60, two pulse transformers and a few
passive components are all that is required to connect a microcontroller to a 10 Mbps
Ethernet network.

Fig:4.6 Pin diagram of Ethernet

Ethernet Controller Features


1. IEEE 802.3 compatible Ethernet controller
2. Integrated MAC and 10BASE-T PHY

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 26 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

3. Receiver and collision squelch circuit


4. Supports one 10BASE-T port with automatic polarity detection and correction
5. Supports Full and Half-Duplex modes
6. Programmable automatic retransmit on collision
7. Programmable padding and CRC generation
8. Programmable automatic rejection of erroneous packets
9. SPI Interface with speeds up to 10 Mb/s
The ENC28J60 consists of seven major functional blocks:

1. An SPI interface that serves as a communication channel between the host


controller and the ENC28J60.
2. Control Registers which are used to control and monitor the ENC28J60.
3. A dual port RAM buffer for received and transmitted data packets.
4. An arbiter to control the access to the RAM buffer when requests are made from
DMA, transmit and receive blocks.
5. The bus interface that interprets data and commands received via the SPI
interface.
6. The MAC (Medium Access Control) module that implements IEEE 802.3
compliant MAC logic.
7. The PHY (Physical Layer) module that encodes and decodes the analog data that
is present on the twisted pair interface.
8. The device also contains other support blocks, such as the oscillator, on-chip
voltage regulator, level translators to provide 5V tolerant I/Os and system control
logic

Medium Access Controller (MAC) Features

1. Supports Uni cast, Multicast and Broadcast packets


2. Programmable receive packet filtering and wake-up host on logical AND or OR
of the following:
- Uni cast destination address
- Multicast address
- Broadcast address
- Magic Packet
- Group destination addresses as defined by 64-bit hash table
- Programmable pattern matching of up to 64 bytes at user-defined offset
3. Loopback mode

Ethernet Buffer
The Ethernet buffer contains transmit and receive memory used by the Ethernet
controller. The entire buffer is 8 Kbytes, divided into separate receive and transmit
buffer spaces. The sizes and locations of transmit and receive memory are fully

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 27 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

programmable by the host controller using the SPI interface. The relationship of the
buffer spaces is

Receive Buffer
The receive buffer constitutes a circular FIFO buffer managed by hardware. The
register pairs ERXSTH: ERXSTL and ERXNDH: ERXNDL serve as pointers to define
the buffers size and location within the memory. The byte pointed to by ERXST and
the byte pointed to by ERXND are both included in the FIFO buffer.
As bytes of data are received from the Ethernet interface, they are written into
the receive buffer sequentially. However, after the memory pointed to by ERXND is
written to, the hardware will automatically write the next byte of received data to the
memory pointed to by ERXST. As a result, the receive hardware will never write outside
the boundaries of the FIFO.
The host controller may program the ERXST and ERXND pointers when the
receive logic is not enabled. The pointers must not be modified while the receive logic is
enabled (ECON1.RXEN is set). If desired, the pointers may span the 1FFFh to 0000h
memory boundary; the hardware will still operate as a FIFO. The ERXWRPTH:
ERXWRPTL registers define a location within the FIFO where the hardware will write
bytes that it receives.
The pointer is read-only and is automatically updated by the hardware whenever
a new packet is successfully received. The pointer is useful for determining how much
free space is available within the FIFO. The ERXRDPT registers define a location
within the FIFO where the receive hardware is forbidden to write to. In normal
operation, the receive hardware will write data up to, but not including, the memory
pointed to by ERXRDPT
4.6 GLOBAL SYSTEM FOR MOBILE COMMUNICATION

Global system for mobile communication (GSM) is a globally accepted standard for
digital cellular communication. GSM is the name of a standardization group established
in 1982 to create a common European mobile telephone standard that would formulate
specifications for a pan-European mobile cellular radio system operating at 900 MHz.

The GSM network


GSM provides recommendations, not requirements. The GSM specifications define
the functions and interface requirements in detail but do not address the hardware. The

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 28 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

reason for this is to limit the designers as little as possible but still to make it possible for
the operators to buy equipment from different suppliers. The GSM network is divided
into three major systems: the switching system (SS), the base station system (BSS), and
the operation and support system (OSS).

Figure 4.7: GSM Network

GSM Network Elements

1. The Switching System: The switching system (SS) is responsible for


performing call processing and subscriber-related functions. The switching
system includes the following functional units.
2. Home location register (HLR): The HLR is a database used for storage and
management of subscriptions. The HLR is considered the most important
database, as it stores permanent data about subscribers, including a subscriber's
service profile, location information, and activity status. When an individual

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 29 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

buys a subscription from one of the PCS operators, he or she is registered in the
HLR of that operator.
3. Mobile services switching center (MSC): The MSC performs the telephony
switching functions of the system. It controls calls to and from other telephone
and data systems. It also performs such functions as toll ticketing, network
interfacing, common channel signaling, and others.
4. Visitor location register (VLR): The VLR is a database that contains temporary
information about subscribers that is needed by the MSC in order to service
visiting subscribers. The VLR is always integrated with the MSC. When a
mobile station roams into a new MSC area, the VLR connected to that MSC will
request data about the mobile station from the HLR. Later, if the mobile station
makes a call, the VLR will have the information needed for call setup without
having to interrogate the HLR each time.
5. Authentication center (AUC): A unit called the AUC provides authentication
and encryption parameters that verify the user's identity and ensure the
confidentiality of each call. The AUC protects network operators from different
types of fraud found in today's cellular world.
6. Equipment identity register (EIR): The EIR is a database that contains
information about the identity of mobile equipment that prevents calls from
stolen, unauthorized, or defective mobile stations. The AUC and EIR are
implemented as stand-alone nodes or as a combined AUC/EIR node.
7. The Base Station System (BSS): All radio-related functions are performed in
the BSS, which consists of base station controllers (BSCs) and the base
transceiver stations (BTSs). BSC: The BSC provides all the control functions
and physical links between the MSC and BTS. It is a high-capacity switch that
provides functions such as handover, cell configuration data, and control of radio
frequency (RF) power levels in base transceiver stations. A number of BSCs are
served by an MSC. BTS: The BTS handles the radio interface to the mobile
station. The BTS is the radio equipment (transceivers and antennas) needed to
service each cell in the network. A group of BTSs are controlled by a BSC.
8. The Operation and Support System: The operations and maintenance center
(OMC) is connected to all equipment in the switching system and to the BSC.
The implementation of OMC is called the operation and support system (OSS).
The OSS is the functional entity from which the network operator monitors and
controls the system. The purpose of OSS is to offer the customer cost-effective
support for centralized, regional, and local operational and maintenance activities

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 30 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

that are required for a GSM network. An important function of OSS is to provide
a network overview and support the maintenance activities of different operation
and maintenance organizations.

GSM Modem
A GSM modem is a wireless modem that works with a GSM wireless network. A
wireless modem behaves like a dial-up modem. The main difference between them is
that a dial-up modem sends and receives data through a fixed telephone line while a
wireless modem sends and receives data through radio waves.

Figure 4.8 GSM modem

A GSM modem can be an external device or a PC Card / PCMCIA Card.


Typically, an external GSM modem is connected to a computer through a serial cable or
a USB cable. A GSM modem in the form of a PC Card / PCMCIA Card is designed for
use with a laptop computer. It should be inserted into one of the PC Card / PCMCIA
Card slots of a laptop computer. Like a GSM mobile phone, a GSM modem requires a
SIM card from a wireless carrier in order to operate.

AT Commands

The working of GSM modem is based on commands, the commands always start with
AT (which means Attention) and finish with a <CR> character. For example, the dialing
command is ATD<number>; ATD3314629080; here the dialing command ends with

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 31 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

semicolon. The AT commands are given to the GSM modem with the help of PC or
controller. computers use AT commands to control modems.
Both GSM modems and dial-up modems support a common set of standard AT
commands. You can use a GSM modem just like a dial-up modem. In addition to the
standard AT commands, GSM modems support an extended set of AT commands. These
extended AT commands are defined in the GSM standards. With the extended AT
commands, you can do things like:

1. Reading, writing and deleting SMS messages.

2. Sending SMS messages.

3. Monitoring the signal strength.

4. Monitoring the charging status and charge level of the battery.

5. Reading, writing and searching phone book entries.

The number of SMS messages that can be processed by a GSM modem per minute is
very low , only about six to ten SMS messages per minute.

The specifications and characteristics for GSM

1. Frequency band: The frequency range specified for GSM is 1,850 to 1,990 MHz
(mobile station to base station).
2. Duplex distance: The duplex distance is 80 MHz. Duplex distance is the distance
between the uplink and downlink frequencies. A channel has two frequencies, 80
MHz apart.

3. Channel separation: The separation between adjacent carrier frequencies. In GSM,


this is 200 kHz.

4. Modulation: Modulation is the process of sending a signal by changing the


characteristics of a carrier frequency. This is done in GSM via Gaussian minimum
shift keying (GMSK).

5. Transmission rate: GSM is a digital system with an over-the-air bit rate of 270
kbps.

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 32 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

6. Access method: GSM utilizes the time division multiple access (TDMA) concept.
TDMA is a technique in which several different calls may share the same carrier.
Each call is assigned a particular time slot.

7. Speech coder: GSM uses linear predictive coding (LPC). The purpose of LPC is to
reduce the bit rate. The LPC provides parameters for a filter that mimics the vocal
tract. The signal passes through this filter, leaving behind a residual signal. Speech is
encoded at 13 kbps.

GSM Subscriber Services

There are two basic types of services offered through GSM: telephony (also
referred to as teleservices) and data. Telephony services are mainly voice services that
provide subscribers with the complete capability to communicate with other subscribers.

1. short message services: A convenient facility of the GSM network is the short message
service. A message consisting of a maximum of 160 alphanumeric characters can be
sent to or from a mobile station. This service can be viewed as an advanced form of
alphanumeric paging with a number of advantages. If the subscriber's mobile unit is
powered off or has left the coverage area, the message is stored and offered back to the
subscriber when the mobile is powered on or has reentered the coverage area of the
network. This function ensures that the message will be received.
2. voice mail: This service is actually an answering machine within the network, which is
controlled by the subscriber. Calls can be forwarded to the subscriber's voice-mail box
and the subscriber checks for messages via a personal security code.
3. fax mail: With this service, the subscriber can receive fax messages at any fax machine.
The messages are stored in a service center from which they can be retrieved by the
subscriber via a personal security code to the desired fax number.

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 33 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

Figure 4.9: Interfacing GSM Modem with Arduino

The GSM modem is serially interfaced with the controller with the help of MAX
232. Here max 232 acts as driver which converts TTL levels to the RS 232 levels. For
serial interface GSM modem requires the signal based on RS 232 levels. The T1_OUT
and R1_IN pin of MAX 232 is connected to the TX and RX pin of GSM modem
4.7 LIQUID CRYSTAL DISPLAY (LCD)

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 34 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

LCD (Liquid Crystal Display) screen is an electronic display module and find a
wide range of applications. A 16x2 LCD display is very basic module and is very
commonly used in various devices and circuits. The most commonly used Character
based LCDs are based on Hitachi's HD44780 controller or other which are compatible
with HD44580.

These modules are preferred over seven segments and other multi segment
LEDs. The reasons being: LCDs are economical; easily programmable; have no
limitation of displaying special & even custom characters (unlike in seven segments),
animations and so on.

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. This LCD has two
registers, namely, Command and Data. The command register stores the command
instructions given to the LCD.

A command is an instruction given to LCD to do a predefined task like


initializing it, clearing its screen, setting the cursor position, controlling display etc. The
data register stores the data to be displayed on the LCD. The data is the ASCII value of
the character to be displayed on the LCD.

Figure 4.10: 16x2 LCD

Pin Description

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 35 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

Most LCDs with 1 controller has 14 Pins and LCDs with 2 controllers has 16
Pins (two pins are extra in both for back-light LED connections). Pin description is
shown in the table below.

Table 4.7: Pin Configuration table for a 16X2 LCD character display

Pin Number Symbol Function

1 Vss Ground Terminal

2 Vcc Positive Supply

3 Vdd
Contrast adjustment

4 RS Register Select; 0Instruction Register, 1Data Register

5 R/W Read/write Signal; 1Read, 0 Write

6 E Enable; Falling edge

7 DB0

8 DB1

9 DB2

10 DB3 Bi-directional data bus, data transfer is performed once, thru


DB0 to DB7, in the case of interface data length is 8-bits; and
11 DB4 twice, through DB4 to DB7 in the case of interface data
length is 4-bits. Upper four bits first then lower four bits.
12 DB5

13 DB6

14 DB7

15 LED-(K)
Back light LED cathode terminal

16 LED+(A)
Back Light LED anode terminal

Data/Signals/Execution of LCD

LCD accepts two types of signals, one is data, and another is control. These
signals are recognized by the LCD module from status of the RS pin. Now data can be

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 36 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

read also from the LCD display, by pulling the R/W pin high. As soon as the E pin is
pulsed, LCD display reads data at the falling edge of the pulse and executes it, same for
the case of transmission.
LCD display takes a time of 39-43S to place a character or execute a
command. Except for clearing display and to seek cursor to home position it takes
1.53ms to 1.64ms. Any attempt to send any data before this interval may lead to failure
to read data or execution of the current data in some devices. Some devices compensate
the speed by storing the incoming data to some temporary registers.

Instruction Register (IR) and Data Register (DR)


There are two 8-bit registers in HD44780 controller Instruction and Data register.
Instruction register corresponds to the register where you send commands to LCD e.g
LCD shift command, LCD clear, LCD address etc. and Data register is used for storing
data which is to be displayed on LCD. when send the enable signal of the LCD is
asserted, the data on the pins is latched in to the data register and data is then moved
automatically to the DDRAM and hence is displayed on the LCD.

Commands and Instruction set


Only the instruction register (IR) and the data register (DR) of the LCD can be
controlled by the MCU. Before starting the internal operation of the LCD, control
information is temporarily stored into these registers to allow interfacing with various
MCUs, which operate at different speeds, or various peripheral control devices. The
internal operation of the LCD is determined by signals sent from the MCU. These
signals, which include register selection signal (RS), read/write signal (R/W), and the
data bus (DB0 to DB7), make up the LCD instructions (Table 3). There are four
categories of instructions that:

1. Designate LCD functions, such as display format, data length, etc.

2. Set internal RAM addresses

3. Perform data transfer with internal RAM

4. Perform miscellaneous functions

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 37 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

A command is an instruction given to LCD to do a predefined task like


initializing it, clearing its screen, setting the cursor position, controlling display etc. The
data register stores the data to be displayed on the LCD. The data is the ASCII value of
the character to be displayed on the LCD.

Table 4.8: Frequently used commands and instructions for LCD

No. Instruction Hex Decimal


1 Function Set: 8-bit, 1 Line, 5x7 Dots 0x30 48
2 Function Set: 8-bit, 2 Line, 5x7 Dots 0x38 56
3 Function Set: 4-bit, 1 Line, 5x7 Dots 0x20 32
4 Function Set: 4-bit, 2 Line, 5x7 Dots 0x28 40
5 Entry Mode 0x06 6
Display off Cursor off
6 (clearing display without clearing DDRAM 0x08 8
content)
7 Display on Cursor on 0x0E 14
8 Display on Cursor off 0x0C 12
9 Display on Cursor blinking 0x0F 15
10 Shift entire display left 0x18 24
12 Shift entire display right 0x1C 30
13 Move cursor left by one character 0x10 16
14 Move cursor right by one character 0x14 20
15 Clear Display (also clear DDRAM content) 0x01 1
Set DDRAM address or coursor position on
16 0x80+add* +add*
display
Set CGRAM address or set pointer to
17 0x40+add** 64+add**
CGRAM location

Table 4.9: List of commands and instructions for LCD

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 38 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

Liquid crystal displays interfacing with Arduino

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 39 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

Fig: 4.11: LCD Interfacing with Arduino

4.8 POWER SUPPLY

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 40 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

The power supply section is the section which provide +5V for the components
to work. IC LM7805 is used for providing a constant power of +5V.The ac voltage,
typically 220V, is connected to a transformer, which steps down that ac voltage down to
the level of the desired dc output. A diode rectifier then provides a full-wave rectified
voltage that is initially filtered by a simple capacitor filter to produce a dc voltage. This
resulting dc voltage usually has some ripple or ac voltage variation.
A regulator circuit removes the ripples and also retains the same dc value even if
the input dc voltage varies, or the load connected to the output dc voltage changes. This
voltage regulation is usually obtained using one of the popular voltage regulator IC
units.

Fig 4.12: Block Diagram of Power Supply

Transformer
Transformers convert AC electricity from one voltage to another with little loss
of power. Transformers work only with AC and this is one of the reasons why mains
electricity is AC. Step-up transformers increase voltage, step-down transformers reduce
voltage. Most power supplies use a step-down transformer to reduce the dangerously
high mains voltage (230V in India) to a safer low voltage. The input coil is called the
primary and the output coil is called the secondary.
There is no electrical connection between the two coils; instead they are linked
by an alternating magnetic field created in the soft-iron core of the transformer.
Transformers waste very little power so the power out is (almost) equal to the power in.
Note that as voltage is stepped down current is stepped up. The transformer will step
down the power supply voltage (0-230V) to (0- 6V) level. Then the secondary of the
potential transformer will be connected to the bridge rectifier, which is constructed with
the help of PN junction diodes. The advantages of using bridge rectifier are it will give
peak voltage output as DC.

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 41 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

Rectifier
There are several ways of connecting diodes to make a rectifier to convert AC to
DC. The bridge rectifier is the most important and it produces full-wave varying DC. A
full-wave rectifier can also be made from just two diodes if a center-tap transformer is
used, but this method is rarely used now that diodes are cheaper. A single diode can be
used as a rectifier but it only uses the positive (+) parts of the AC wave to produce half-
wave varying DC

Bridge Rectifier

When four diodes are connected as shown in figure, the circuit is called as bridge
rectifier. The input to the circuit is applied to the diagonally opposite corners of the
network, and the output is taken from the remaining two corners. Let us assume that the
transformer is working properly and there is a positive potential, at point A and a
negative potential at point B. the positive potential at point A will forward bias D3 and
reverse bias D4.

Fig 4.13: Bridge Rectifier


The negative potential at point B will forward bias D1 and reverse D2. At this
time D3 and D1 are forward biased and will allow current flow to pass through them; D4
and D2 are reverse biased and will block current flow. One advantage of a bridge
rectifier over a conventional full-wave rectifier is that with a given transformer the
bridge rectifier produces a voltage output that is nearly twice that of the conventional
full-wave circuit.
The main advantage of this bridge circuit is that it does not require a special
center tapped transformer, thereby reducing its size and cost. The single secondary

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 42 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

winding is connected to one side of the diode bridge network and the load to the other
side as shown below. The result is still a pulsating direct current but with double the
frequency.

Fig 4.14: Output Waveform Of DC

Smoothing

Smoothing is performed by a large value electrolytic capacitor connected across


the DC supply to act as a reservoir, supplying current to the output when the varying DC
voltage from the rectifier is falling. The capacitor charges quickly near the peak of the
varying DC, and then discharges as it supplies current to the output.

Voltage Regulators

Voltage regulators comprise a class of widely used ICs. Regulator IC units


contain the circuitry for reference source, comparator amplifier, control device, and
overload protection all in a single IC. IC units provide regulation of either a fixed
positive voltage, a fixed negative voltage, or an adjustably set voltage. The regulators
can be selected for operation with load currents from hundreds of milli amperes to tens
of amperes, corresponding to power ratings from milli watts to tens of watts.

A fixed three-terminal voltage regulator has an unregulated dc input voltage, Vi,


applied to one input terminal, a regulated dc output voltage, Vo, from a second terminal,
with the third terminal connected to ground. The series 78 regulators provide fixed
positive regulated voltages from 5 to 24 volts. Similarly, the series 79 regulators provide
fixed negative regulated voltages from 5 to 24 volts.
Voltage regulator ICs are available with fixed (typically 5, 12 and 15V) or
variable output voltages. They are also rated by the maximum current they can pass.

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 43 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

Negative voltage regulators are available, mainly for use in dual supplies. Most
regulators include some automatic protection from excessive current ('overload
protection') and overheating ('thermal protection'). Many of the fixed voltage regulator
ICs has 3 leads and look like power transistors, such as the 7805 +5V 1Amp regulator.
They include a hole for attaching a heat sink if necessary.

Fig 4.15: Regulator

Fig 4.16: Circuit Diagram of Power Supply

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 44 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

Powering an Arduino

There are 3 ways to power an Arduino; through USB, the barrel jack, or directly
into the VIN pin. Each option has pros and cons and the method used depends on the
project the Arduino is a part of.

1. USB

Fig 4.17: USB port of Arduino Board

Powering an Arduino from a USB is the way used by most people. When an
Arduino is connected to a computer to load code, it also provides power for testing.
If a project involves interaction with the USB port, in order to send or receive serial
data for example, the USB is an easy, no hassle method. However, if a project is
mobile or not in close proximity to a computer, a different power option will need to
be considered.

2. Barrel Jack

The Arduino Uno, Mega and Ethernet (as well as the many of the older boards)
have a standard 2.1mm center positive barrel jack connector. This jack has a diode to
protect the Arduino from reversed polarity. This allows the Arduino to be easily
connected to an AC-to-DC adapter or a battery pack. The recommended input voltage
for this jack is 7 to 12 volts. Stationary projects that will be near a wall outlet can be
powered with a 9v or 12v wall wart power supply rated at either 1amp or 500ma.For a
mobile project, batteries can also be plugged into the barrel jack. The most basic option

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 45 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

is to create a 9v battery adapter.. To power a project with standard 1.5 volt alkaline AA
and AAA batteries requires at least a 6x battery holder.

Fig 4.18: Barrel Jack of Arduino Board

If using rechargeable batteries remember that they provide different voltages,


NiMH for example is only 1.2 volts. If the power supplied to the Arduino drops below
7v the output of the 5v pin may not be a full 5 volts and the board may become unstable.

3.VINPin
The VIN pin on Arduino boards can be used to tap into the power source plugged into
the barrel jack. Some shields will use this as their power source. The VIN pin is after the
polarity protection diode so keep in mind that the output will be about .6 to .7 volts less
than the input voltage

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 46 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

Fig 4.19: Power pins of Arduino Board

This pin can also be used as an input for power. The only difference between the barrel
jack and the VIN pin is that the VIN pin is after the polarity protection diode. This
means 2 things: first if the power is connected with polarity reversed it will destroy the
Arduino and second the power used by the Arduino will be slightly less, leading to
longer life if powered from a battery. Once again the type of project and components
will determine if this is the best route.

4.9 PERSONAL COMPUTER


A personal computer (PC) is a small, relatively inexpensive computer designed
for an individual user. In price, personal computers range anywhere from a few hundred
dollars to thousands of dollars. All are based on the microprocessor technology that
enables manufacturers to put an entire CPU on one chip. Here Personal computer is
interfaced with GSM and Arduino through Serial port.

Personal computer is required to check the water level status continuously on webpage
developed for continuous monitoring of flood situation.

Personal Computer Interfacing with Arduino

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 47 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

Fig 4.20: Interfacing Personal Computer Arduino Board

MAX 232

The MAX232 is a dual driver/receiver that includes a capacitive


voltage generator to supply RS 232 voltage levels from a single 5v
supply. Each receiver converts RS-232 to 5v TTL/CMOS levels. Each
driver converts TLL/CMOS input levels into EIA-232 levels. The P3_0
(RX) and P3_1 (TX) pin of controller is connected to the max 232 driver
and the TX and RX pin of max 232 is connected to the GSM modem or
PC.

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 48 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

Fig 4.21: MAX 232

In this circuit the microcontroller transmitter pin is connected in the


MAX232 T2IN pin which converts input 5v TTL/CMOS level to RS232
level. Then T2OUT pin is connected to reviver pin of 9 pin D type serial
connector which is directly connected to PC.

In PC the transmitting data is given to R2IN of MAX232 through


transmitting pin of 9 pin D type connector which converts the RS232
level to 5v TTL/CMOS level. The R2OUT pin is connected to receiver pin
of the microcontroller. Likewise the data is transmitted and received
between the microcontroller and PC or other device vice versa.

RS232

An RS-232 serial port was once a standard feature of a personal computer, used for
connections to modems, printers, mice, data storage, uninterruptible power supplies, and
other peripheral devices. However, RS-232 is hampered by low transmission speed,
large voltage swing, and large standard connectors. In modern personal
computers, USB has displaced RS-232 from most of its peripheral interface roles. Many
computers do not come equipped with RS-232 ports and must use either an external

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 49 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

USB-to-RS-232 converter or an internal expansion card with one or more serial ports to
connect to RS-232 peripherals

Independent channels are established for two-way (full-duplex) communications.


The RS232 signals are represented by voltage levels with respect to a system common
(power / logic ground). The "idle" state (MARK) has the signal level negative with
respect to common, and the "active" state (SPACE) has the signal level positive with
respect to common. RS232 has numerous handshaking lines (primarily used with
modems), and also specifies a communications protocol.

Fig 4.22:RS232 Communication

The standard defines how computers (it calls them Data Terminal Equipment or
DTEs) connect to modems (it calls them Data Communication Equipment or DCEs).
The standard says that computers should be fitted with a 25 way plug whilst modems
should have a 25 way D socket. The interconnecting lead between a computer and a
modem should be simply pin1-pin1, pin2-pin2, etc. The main signals and their direction
of flow are described below. It is important to note that a signal which is an output from
a computer is an input to a modem and vice versa.

This means that you can never tell from the signal name alone whether it is an
input or an output from a particular piece of equipment. Also, instead of being a DCE
device, a data acquisition device might be configured as DTE. In this case you need an
adaptor or the RS232 cable wired differently to normal. When the PC is connected to a
DTE instrument - called a null modem arrangement - some of the cable wires must cross
over. The RS-232 interface presupposes a common ground between the DTE and DCE.

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 50 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

This is a reasonable assumption when a short cable connects the DTE to the DCE, but
with longer lines and connections between devices that may be on different electrical
busses with different grounds, this may not be true.RS232 data is bi-polar.... +3 TO +12
volts indicates an "ON or 0-state (SPACE) condition" while A -3 to -12 volts indicates
an "OFF" 1-state (MARK) condition.... Modern computer equipment ignores the
negative level and accepts a zero voltage level as the "OFF" state. In fact, the "ON" state
may be achieved with lesser positive potential.

Fig 4.23:RS232

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 51 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

Figure 4.24 Interfacing RS232 and Max 232

Table 4.9 Voltage Levels of RS232 and MAX232

RS232 line type and logic level RS232 voltage TTL voltage to/from MAX232

Data transmission (Rx/Tx) logic 0 +3 V to +15 V 0V

Data transmission (Rx/Tx) logic 1 -3 V to -15 V 5V

Control signals (RTS/CTS/DTR/DSR) logic 0 -3 V to -15 V 5V

Control signals kjnic 1 +3 V to +15 V 0V

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 52 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

CHAPTER 5. SOFTWARE DESCRIPTION

5.1 ARDUINO IDE


Youll need to download the Arduino Software package for your operating system.
When youve downloaded and opened the application you should see something like
this:

Screenshot 1: Editor Page


This is where you type the code you want to compile and send to the Arduino board.

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 53 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

5.2 THE INITIAL SETUP


We need to setup the environment to Tools menu and select Board.

Screenshot 2: Selection of Board

Then select the type of Arduino you want to program, in our case its the Arduino
Mega.

Screenshot 3: Selection of Arduino Mega Board

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 54 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

5.3 CODING
The code you write for your Arduino are known as sketches. They
are written in C++. Every sketch needs two void type functions, setup() and
loop(). A void type function doesnt return any value. The setup() method is
ran once at the just after the Arduino is powered up and the loop() method is
ran continuously afterwards.
The setup() is where you want to do any initialisation steps, and in
loop() you want to run the code you want to run over and over again.

So, your basic sketch or program should look like this:

void setup()
{

void loop()
{

}
Now we have the basic skeleton in place we can now do the Hello, World
program of microcontrollers, a blinking an LED.

Headers and Pins


If you notice on the top edge of the board theres two black
rectangles with several squares in. These are called headers. Headers make
it easy to connect components to the the Arduino. Where they connect to the
board is called pins. Knowing what pin something is connected to is
essential for programming an Arduino.

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 55 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

The pin numbers are listed next to the headers on the board in white.
The onboard LED we want to control is on pin 13.

In our code above the setup() method lets create a variable called
ledPin. In C++ we need to state why type our variable is before hand, in this
case its an integer, so its of type int.

int ledPin = 13;


void setup()
{

void loop()
{

}
Each line is ended with a semicolon (;).

In the setup() method we want to set the ledPin to the output mode.
We do this by calling a special function called pinMode() which takes two
variables, the first the pin number, and second, whether its an input or
output pin. Since were dealing with an output we need to set it to a
constant called OUTPUT. If you were working with a sensor or input it
would be INPUT.

int ledPin = 13;

void setup()

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 56 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

{
pinMode(ledPin, OUTPUT);
}

void loop()
{

}
In our loop we are going to first switch off the LED to make sure our
program is being transferred to the chip and overriding the default.
We do this by calling another special method called digitalWrite(). This also
takes two values, the pin number and the level, HIGH or the on state or
LOW the off state.

int ledPin = 13;

void setup()
{
pinMode(ledPin, OUTPUT);
}

void loop()
{
digitalWrite(ledPin, LOW);
}

Next we want to compile to machine code and deploy or upload it to the


Arduino.

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 57 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

5.4 COMPILING THE CODE


If this is your first time youve ever compiled code to your Arduino
before plugging it in to the computer go to the Tools menu, then Serial
Port and take note of what appears there.
Heres what mine looks like before plugging in the Arduino Mega:

Plug your Arduino Mega board in to the USB cable and into your
computer. Now go back to the Tools > Serial Port menu and you should
see at least 1 new option. On my Mac 2 new serial ports appear.

They tty and cu are two ways that computers can talk over a serial
port. Both seem to work with the Arduino software so I selected the tty.*
one. On Windows you should see COM followed by a number. Select the
new one that appears.
Once you have selected your serial or COM port you can then press the
button with the arrow pointing to the right.

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 58 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

Screen Shot 3 : Compiling the code

Once that happens you should see the TX and RX LEDs below the L LED flash.
This is the communication going on between the computer and the Arduino. The L may
flicker too. Once this dance is complete your program should be running. And your LED
should be off.

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 59 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

CHAPTER 6. CODING

6.1 CODING OF MAIN MODULE

// include the library code:


#include <LiquidCrystal.h>
//initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 13, 8, 9, 10, 11);
const int analogInPin0 = A0; // Analog input pin that the potentiometer is

attached to
const int analogInPin1 = A1; // Analog input pin that the potentiometer is

attached to
const int analogInPin2 = A2; // Analog input pin that the potentiometer is

attached to
int sensorValue0 = 0; // value read from the pot
int sensorValue1 = 0; // value read from the pot
int sensorValue2 = 0; // value read from the pot
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// initialize serial communications at 9600 bps:
Serial.begin(9600);
//lcd inital mesg
lcd.print("DAM WATER LEVEL ");
//3sec delay
delay(3000);

//sms inital
Serial.print("AT\r"); //Sets the GSM Module in Text Mode
delay(2000);
Serial.print("AT+CMGF=1\r"); //sms select
delay(2000);
Serial.print("AT+CMGS=\"9642699925\"\r");//mobile number
delay(2000);
Serial.print("DAM WATER LEVEL");//mesg
Serial.print((char)26);// ASCII code of CTRL+Z
delay(2000);
//clear lcd

//sms inital
Serial.print("AT\r"); //Sets the GSM Module in Text Mode
delay(2000);
Serial.print("AT+CMGF=1\r"); //sms select
delay(2000);
Serial.print("AT+CMGS=\"8790509218\"\r");//mobile number

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 60 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

delay(2000);
Serial.print("DAM WATER LEVEL");//
Serial.print((char)26);// ASCII code of CTRL+Z
delay(2000);
//clear lcd
lcd.clear();
}

void loop() {
// read the analog in value:
sensorValue0 = analogRead(analogInPin0);
//print sensor value
Serial.print("sensor0 = " ); //mesg on serial
Serial.print(sensorValue0); // print value
Serial.print("\n" ); //new line
lcd.setCursor(0, 0); // top left
lcd.print("L1:");
lcd.print(sensorValue0);
delay(1000);

// read the analog in value:


sensorValue1 = analogRead(analogInPin1);
Serial.print("sensor1 = " );
Serial.print(sensorValue1);
Serial.print("\n" );
lcd.setCursor(7, 0); // bottom left
lcd.print(" L2:");
lcd.print(sensorValue1);
lcd.print(" ");
delay(1000);

// read the analog in value:


sensorValue2 = analogRead(analogInPin2);
Serial.print("sensor2 = " );
Serial.print(sensorValue2);
Serial.print("\n" );
lcd.setCursor(0, 1); // bottom left
lcd.print("L3:");
lcd.print(sensorValue2);
delay(1000);

if(sensorValue0==0)
{
lcd.clear();
Serial.print("LEVEL1\n" );
lcd.setCursor(0, 0); // bottom left
lcd.print("LEVEL 1!!!!!!!!!");
delay(2000);
lcd.setCursor(0, 0); // bottom left
lcd.print("SENDING SMS!!! ");

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 61 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

delay(2000);

Serial.print("AT\r"); //Sets the GSM Module in Text Mode


delay(2000);
Serial.print("AT+CMGF=1\r");
delay(2000);
Serial.print("AT+CMGS=\"9642699925\"\r");
delay(2000);
Serial.print("Water at level 1");
Serial.print((char)26);// ASCII code of CTRL+Z
delay(2000);
}
if(sensorValue1==0)
{
lcd.clear();
Serial.print("LEVEL2\n" );
lcd.setCursor(0, 0); // bottom left
lcd.print("LEVEL 2!!!!!!!!!");
delay(2000);
lcd.setCursor(0, 0); // bottom left
lcd.print("SENDING SMS!!! ");
delay(1000);
Serial.print("AT\r"); //Sets the GSM Module in Text Mode
delay(2000);
Serial.print("AT+CMGF=1\r");
delay(2000);
Serial.print("AT+CMGS=\"9642699925\"\r");
delay(2000);
Serial.print("Water at level 2");
Serial.print((char)26);// ASCII code of CTRL+Z
delay(2000);
}

if(sensorValue2==0)
{
lcd.clear();
Serial.print("LEVEL3\n" );
lcd.setCursor(0, 0); // bottom left
lcd.print("LEVEL 3!!!!!!!!!");
delay(2000);
lcd.setCursor(0, 0); // bottom left
lcd.print("SENDING SMS!!! ");
delay(2000);
Serial.print("AT\r"); //Sets the GSM Module in Text Mode
delay(2000);
Serial.print("AT+CMGF=1\r");
delay(2000);
Serial.print("AT+CMGS=\"9642699925\"\r");
delay(2000);
Serial.print("Water at level 3\n");

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 62 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

Serial.print("DANGER!!!!!!!!!!!!!");
Serial.print((char)26);// ASCII code of CTRL+Z
delay(2000);
}
delay(1000);
}
6.2 SOFTWARE CODE OF LCD

// include the library code:

#include <LiquidCrystal.h>

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

LiquidCrystal lcd(12, 13, 8, 9, 10, 11);

int analogPin0 = A0;

int analogPin1 = A1;

int analogPin2 = A2;

int val0 = 0;

int val1 = 0;

int val2 = 0;

void setup() {

// set up the LCD's number of columns and rows:

lcd.begin(16, 2);

Serial.begin(9600);

// Print a message to the LCD.

lcd.print(" DAM WATER LEVEL ");

delay(3000);

lcd.clear();

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 63 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

void loop() {

val0 = analogRead(analogPin0); // read the input pin

// Serial.println("VIB:");

// Serial.println(val0); // debug value

lcd.setCursor(0, 0); // bottom left

lcd.print("L1:");

lcd.print(val0);

delay(500);

val1 = analogRead(analogPin1); // read the input pin

// Serial.println("VIB:");

// Serial.println(val1); // debug value

lcd.setCursor(7, 0); // bottom left

lcd.print(" L2:");

lcd.print(val1);

delay(500);

val2 = analogRead(analogPin2); // read the input pin

// Serial.println("VIB:");

// Serial.println(val1); // debug value

lcd.setCursor(0, 1); // bottom left

lcd.print("L3:");

lcd.print(val2);

delay(500);

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 64 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

CHAPTER 7. FLOWCHART

7.1 FLOWCHART

Fig 7.1 Flowchart of the Project

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 65 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

7.2 ADVANTAGES
1. Cost effective: Arduino boards are relatively inexpensive compared to other
microcontroller platforms. The pre-assembled Arduino modules cost less than
300 rupees.
2. Ready to use: Its ready to use structure makes it really easy to use. You dont
have to take care of burner, fuse settings, Serial Monitor Softwares etc.
3. Effortless functions: There are many functions present in the software of
Arduino which makes coding so easy and fast that is not possible with simple
microcontroller.
4. Large Community: Well it is obvious now that everyone is using Arduino
nowadays thats why you can get help anytime from anywhere whenever you
will have stuck somewhere.

5. Cross-platform: The Arduino Software (IDE) runs on Windows, Macintosh


OSX, and Linux operating systems. Most microcontroller systems are limited to
Windows.

6. Can save lives by alerting people on time about flood.

7.3 APPLICATIONS
1. Reservoirs for water level detection: In reservoirs, it is applicable where
continuous water level monitoring can be done.
2. Any low-lying flood prone areas: It can be used in any low- lying areas where
the danger of flood is always detected. This project helps to save human life in
any flood prone areas and also rural areas.

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 66 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

CHAPTER:8 COMPLETED PCB

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 67 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

CONCLUSION

The implementation of the project entitled Water level Meter for alerting
population about floods using Atmega 2560 is successfully done. This project helps to
save many lives by alerting the people on time to vacate the flood prone areas. In detail
the description of hardware used in the project entitled Detecting and alerting the
people about flood situation is given here. This project helps to save many lives by
alerting the people on time to vacate the flood prone areas.

The Project Water Level Meter for Alerting Population about floods by using
Atmega 2560 is designed to alert the population about flood situation to avoid the loss
of human life. The three water level sensors which is generally immersed in reservoirs
(mostly in flood affected areas). These water level sensors are pressure based (WL400)
sensor which senses the increase in water level based on the increasing level of pressure
in water. The three sensors are indicated for three levels. In implementing this project we
have learnt about GSM modem, LCD interfacing and the issues related to interfacing the
devices.

While designing this project we have learnt about Arduino IDE, Sketches, types
of Arduino boards and the procedure of implementing the code on Arduino board. These
helped us in the successful implementation of the project entitled Water level Meter for
alerting population about floods using Atmega 2560 .

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 68 | P a g e


WATER LEVEL METER FOR ALERTING POPULATION ABOUT FLOODS BY USING AT MEGA 2560

BIBLIOGRAPHY
REFERENCES
[1] A. Shalom Hakkert, Victoria Gitelman, Eliah Ben-Shabat, Anevaluation of
crosswalk warning systems: effects on pedestrian andvehicle behavior, Transportation
Research Institute, TechnionIsrael Institute of Technology, Technion City, Haifa
32000, Israel,Transportation Research Part F 5 (2002) 275292
[2] Hitoshi Miyata, Makoto Ohki, Yasuyuki Yokouchi, Masaaki Ohkita ,Control of the
autonomous mobile robotDREAM-1 for a parallelparking, Department of Electrical
and Electronic Engineering,Faculty of Engineering, Tottori University, 4-101, Koyama-
Minami,Tottori 680, Japan, Mathematics and Computers in Simulation 41(1996) 129-
138
[3] Nikolaj Zimic, Miha Mraz, Decomposition of a complex fuzzycontroller for the
truck-and-trailer reverse parking problem,University of Ljubljana, Faculty of Computer
and Information Science,Trzaska cesta 25, SI-1000 Ljubljana, Slovenia, Mathematical
andComputer Modelling 43 (2006) 632645
[4] Massaki Wada, Student Member, Development of Advanced ParkingAssistance
System, IEEE, Kang Sup Yoon, Member, IEEE, andHideki Hashimoto, Member, IEEE,
IEEE Transactions on IndustrialElectronics, VOL. 50, NO. 1, Feb 2003
[5] Tsung-hua Hsu, Jing-Fu Liu, Pen-Ning Yu, Wang-Shuan Lee and Jia-Sing Hsu,
Development of an Automatic Parking System forVehicle, Automotive Research and
Testing Center, Changhua County,Taiwan, R.O.C., IEEE Vehicle Power and Propulsion
Conference(VPPC), September 3-5, 2008, Harbin, China.

WEBSITES
1. www.arduino.cc
2. www.engineeringsgarage.com
3. www.ieeeprojects.com
4. www.arduinoprojects.com
5. www.wikipedia.org.

DEPTOF ECE, LORDS INSTITUTE OF ENGINEERING AND TECHNOLOGY 69 | P a g e

Вам также может понравиться