GR 5 Edited
GR 5 Edited
                               CERTIFICATE
                             To whom it may concern
    This is to certify that the project work entitled Ultrasonic Sensor based Water Level
    Monitoring and Control using IoT is the bonafide work carried out by Sahil Tiwari
    (16902821010), Binay Kumar (16902821025), Ravi Bhushan (16902821048), Sandeepan
    Roy (16902821020) the students of B.Tech in the Department of Electrical & Electronics
    Engineering, Academy of Technology (AOT) affiliated to Maulana Abul Kalam Azad University of
    Technology (MAKAUT), WestBengal, India, during the academic year 2024- 25, in partial fulfillment
    of the requirements for the degree of Bachelor of Technology in Electrical & Electronics Engineering
    and that this project has not submitted previously for the award of any other degree, diploma and
    fellowship.
Countersigned by
It is our great fortune that we have got opportunity to carry out this project work
under the supervision of Mr. Suman Kumar Das in the Department of Electrical
& Electronics Engineering, Academy Of Technology (AOT), G.T. Road,
Adistaptagram, Hooghly -712121, affiliated to Maulana Abul Kalam Azad
University of Technology (MAKAUT), West Bengal, India. We express our
sincere thanks and deepest sense of gratitude to our guide for his constant support,
unparalleled guidance and limitless encouragement.
We would also like to convey our gratitude to all the faculty members and staffs of
the Department of Electrical & Electronics Engineering, AOT for their whole
hearted cooperation to make this work turn into reality.
We are very thankful to our Department and to the authority of AOT for providing
all kinds of infrastructural facility towards the research work.
Respected Sir,
In accordance with the requirements of the degree of Bachelor of Technology in the Department
of Electrical & Electronics Engineering, Academy of Technology, We present the following
thesis entitled “ Ultrasonic Sensor based Water Level Monitoring and Control using IoT ”.
This work was performed under the valuable guidance of Mr. Suman Kumar Das, Assistant
Professor in the Dept. of Electrical & Electronics Engineering.
We declare that the thesis submitted is our own, expected as acknowledge in the test and
reference and has not been previously submitted for a degree in any other Institution.
Yours Sincerely,
List of tables ii
Abstract 1
Chapter 1 (Introduction)
1.1 Introduction 3
Chapter 3 (Theory)
5.1 Introduction 36
6.1 Conclusion 42
     6.2   Results                                          42
     6.3   Future works                                     42
Chapter 6 (Reference)               44
Appendix C (Datasheets)             57
List of Figures
Sl. No.                     Figure numbers                        Page No.
   1      Ultrasonic Working Principle                                4
   2      Ultrasonic Module Timing Diagram                            4
   3      NODE MCU Development board                                 19
   4      NODE MCU with inbuilt Wi-Fi module                         19
   5      NODE MCU pin configuration                                 20
   6      Snapshot of the installation process of NODE MCU           21
   7      Driver Installation for NODE MCU                           21
   8      Arduino IDE preferences                                    22
   9      Arduino IDE board manager installation                     22
  10      ESP 8266 board installation in Arduino                     23
  11      Node MCU interfacing with Arduino                          23
  12      Ultrasonic Working Principle                               24
  13      Ultrasonic Module timing diagram                           25
  14      Interfacing HC SR 04 with Node MCU                         26
  15      Account creation and generation of unique ID in Blynk      26
  16      Working process of the water level control device          27
  17      Connection diagram of project                              27
  18      Blynk app user interface                                   28
  19      Main Controller with relay & OLED display module           30
  20      UNL2003A interfacing with µC                               32
  21      interface HC SR 04 with Node MCU                           33
  22      128X64 I2C based OLED module                               34
  23      Interfacing OLED with Node MCU                             34
  24      Flow chart of the Program                                  36
  25      Blynk working Principle                                    38
  26      Main Controller Board                                      39
  27      The whole prototype                                        40
  28      The Blynk app user Interface                               40
  29      Transformer less SMPS 5volt power supply                   47
  30      ULN2003A internal block diagram                            48
  31      Resistor                                                   48
  32      Colour Code for resistance                                 49
  33      6 volt Cube Relay                                          50
  34      128X64 OLED Module                                         51
  35      Node MCU Module                                            51
  36      Pizeo Buzzer                                               52
  37      Blank Glass Epoxy PCB Board                                52
                                     i
                 List of Tables
                           ii
ABBREVIATIONS AND ACRONYMS
   IOT–Internet of Things
   FCC - Federal Communications Commission
   HVAC–Heating Ventilation and AirConditioning
   IC - Integrated Circuit
   PCB – Printed Circuit Board
   µC – Micro Controller
   BJT - Bi-polar Junction Transistor
   SPDT - Single Pole Double Throw
   NO - Normally Open
   NC - Normally Closed
   COM – Common
   LCD – Liquid Crystal Display
   LED - Light Emitting Diode
   POT – Potentiometer
   AT – Attention Command
   SMPS – Switch Mode Power Supply
   RF– Radio Frequency
   ISM – Industrial, scientific and medical
   USB – Universal serial bus
   SPI – Serial Peripheral Interface
   I2C – Inter-Integrated Circuit
   GPIO – General Purpose Input Output
   API–ApplicationProgram Interface
                     iii
                      ABSTRACT
Wireless Water Level Monitoring & Control Using Ultrasonic sensor &
NODE MCU is an amazing and very useful project. The objective of this
project is to notify the user the amount of water that is present in the
overhead water tank. This project is further enhanced to control the
water level in the tank by turning the water pump ON, when the water
level is LOW, and turning the pump OFF when the water level is HIGH.
Thus, the MODE MCU water level indicator& control helps in
preventing wastage of water in overhead tank. This project wirelessly
send the data to the user mobile using Blynk IoT app.It is easy to install,
cost effective and it can work from anywhere in the world.
                                 1
CHAPTER 1
 (Introduction)
       2
1.1    INTRODUCTION
        The process requirement in many industries, farms, hostels, hotels etc includes an overhead
tank for water, which is usually fed through an electric pump that is switched off when the tank is
filled up, and on when it becomes empty. As such, the most common way of knowing when the
tank is filled is by observing when it overflows the brim. Depending on the type of liquid being
handled, the overfilling of such a tank could lead to heavy material losses. These losses can be
prevented if the tank is regulated automatically by incorporating a feed-back control mechanism,
which would be capable of tripping the pump on or off as required. Although pumps equipped with
variable speed motors could be more efficient than on/off mechanisms, the former are expensive to
procure and maintain, especially for small and medium enterprises. Furthermore, commercially
available water level sensors are expensive being imported into the country and as such cannot be
deployed in every household. Control systems are classified as open loop or closed loop. In open
loop systems a command is given to a system and it is assumed the system performs properly. A
closed loop system, on the other hand, compares the result or output of the system to a desired
output and takes appropriate corrective actions. Closed loop systems therefore, generally exhibit
more accurate performance butcost more and tend to be more unstable. Here the sensor used is
Ultrasonic sensor, it’s a non contact based distance sensor. Due to the not contact properties of the
sensor it can be used for any type of liquid in the tank. The level of the tank is monitor continuously
and sends to the user mobile through internet. The pump can be controlled anywhere using the
internet.
        Node MCU is an open source IoT platform. The user has a clear idea about the water level
in the overhead tank every time in the mobile using the internet. Also the user can control (ON/OFF
control only) the water pump through the mobile using IoT. When water goes below a certain level
the pump will automatically switched ON and gives an indication to the user mobile and after a
certain level the pump will switched OFF automatically. In this way this system ensures continuity
of water throughout the day and it also saves the spillage of water.
The ultrasonic sensor works on the principle of SONAR and RADAR system which is used to
determine the distance to an object.
An ultrasonic sensor generates the high-frequency sound (ultrasound) waves. When this ultrasound
hits the object, it reflects as echo which is sensed by the receiver as shown in below figure 1.
By measuring the time required for the echo to reach to the receiver, we can calculate the distance.
This is the basic working principle of Ultrasonic module to measure distance.
                                               3
                           Figure 1: Ultrasonic Working Principle
                                               4
1.4     Distance Calculation using HC SR 04
We know that,
                                    Distance = Speed x Time
Total distance is divided by 2 because signal travels from HC-SR04 to object and returns to the
module HC-SR-04.
1. Power Saver
Living in an age where we need to be more conscious of the energy that we use, a water level
controller is ideal at saving power. Normally, regulating water levels can consume electricity and
wastewater. However, with automatic controllers, the electricity usage is limited as well as less
water needed to regulate supply.
2. Money Saver
A water level controller helps save money by limiting the waste of water and electricity. These
devices accurately regulate how much energy is used to protect against any unnecessary
water/electricity usage. Over time, the money saved is quite substantial.
3. Automatic
Another notable advantage with these devices is that they regulate on their own. Eliminating
manual operations with a timer switch, the frustrations of manual monitoring water tanks are
minimized. Water levels are maintained at the appropriate levels thanks to the automatic operations
of these devices.
4. Water Maximization
On average, water pumps are used more during midday. A water level controller can maximize the
water usage provided during midday while automatically lessening the water usage at night. This
results in an appropriate level of water at all times being maintained, while providing you with the
maximum use of your water at the appropriate times.
                                              5
5. Reliable Electronic Design
Addressing the durability problems found in earlier designs, the solid-state electronics in the newer
models help to eliminate them. Not only do they help to eliminate the durability issues, but they
also create considerable savings of the life span of the unit with an advanced modular design. In
order to minimize problem areas of these designs, the only moving parts are the relays. These relays
are easily replaced and tested by any skilled operator or electrician while being an inexpensive part.
•     Easy installation
•     Minimal maintenance
•     Sends an alert to let you know water is too high or too low
•     Low & High alarms
•     Compact design
•     Automatically adjusts water levels
•     Save money by using less electricity and water
•     Can help avoid seepage of roofs and walls due to tanks overflowing
•     Automatic operation saves you manual labor time
•     Consumes a small amount little energy, perfect for on-going operations
•     Indicates water levels in any type of storage tank or body of liquid
•     A water alarm is loud so you can easily hear it
      .
The thesis is organised into five chapters including the chapter of introduction. Each chapter
is different from the other and is described along with the necessary theory required to
comprehend it.
Chapter2 deals with the literature reviews. From this chapter we can see before our project
who else works on this topic and how our project is different and advance from those projects.
Chapter 3 deals with the theory required to do the project. The basic of operation of HC SR
04 ultrasonic distance sensor and how to interface with node mcu microcontroller are
described there.
Chapter 4 deals with the hardware modelling of the projects. The main features, photographs,
step by step operation of the prototype, component listing and the hardware interfacing of the
required components are described here.
Chapter 5 describes the operation of the prototype circuit. A flow chart is presented on the
actions which describes the principle of operation of the prototype. HC SR 04 senses the water
level and sends it to the user mobile using wifi.
                                                7
Chapter 6 concludes the work performed so far. The possible limitations in proceeding
research towards this work are discussed. The future work that can be done in improving the
current scenario is mentioned. The future potential along the lines of this work is also
discussed.
Appendix A, B & C Hardware description, software coding and datasheets are listed here.
                                              8
CHAPTER 2
(Literature Review)
         9
[1]
This paper illustrates a solution of water scarcity faced by many societies and world in 21st century.
The proposed paper focused on IOT based monitoring system, implementation, management of
water distribution in large areas. The monitoring system was implemented by Ultrasonic sensors
and Node MCU. This is non-contact water level management. By the system, water is transferred to
several tanks from the ground water or dam, there water is pumped to tanks by motors. Each pump
connected to each tank by solenoid valves, used to control the water flow to each tanks. The
solenoid valves get turned on by USB6009 (DAQ Assist) with LABVIEW. The main function of
DAQ is sending digital pulses to get valves ON. Ultrasonic sensors that measures the distance of
water level in the tank & the data is displayed in the IoT devices. The received date is sent to
google cloud platform. We can also retrieve the data from the webpage that will display in LAB
VIEW front panel. Network of sensors has been used to buffer efficient water circulations. The
included NI-DAQmx driver and configuration utility simplify configuration and measurement.
[2]
S. V. Manikanthan and T. Padmapriya “Recent Trends In M2m Communications In 4g
Networks And Evolution Towards 5g”, International Journal of Pure and Applied
Mathematics, ISSN NO: 1314-3395, Vol115, Issue -8, Sep 2017.
                                              10
[3]
Neena Mani, Sudeesh T.P, Vinu Joseph, Titto V.D, Shamnas P.S, “Design and
Implementation of a Automated Water Level Indicator”, International Journal of Advanced
Research in Electrical, Electronics and Instrumentation Engineering 2014 Vol 3 Issue 2,
February 2014.
Water level indicator is widely used in many industries and houses .In this paper a programmed
microcontroller is the basic component for the water level indicator. ATmega 32A microcontroller
is helps to indicate the level of water or any other conducting liquid.. With the help of an lcd display
we can see all the level of the water contained in a tank or in any other vessels. A liquid level sensor
(transistor circuit) detects the present level of the liquid in the tank in terms of the voltage across
transistor and feeds it to the microcontroller and the microcontroller generates a corresponding
output text which in then displayed in the LCD. If the water level is full, then the circuits beeps
through the buzzer notifying that the water level is full. The circuit is divided into two parts. First
one is the microcontroller section which is kept on the breadboard and second is the transmitter
section and its base is kept inside the water tank. The collector terminals of each of these transistors
are connected to a +5 volt level. The emitter terminals are connected to input pins of PORT A of the
microcontroller. The microcontroller continuously monitors the state of each of these input pins. If
the first pin, which is the one corresponding to the quarter level of the tank is high then LCD
displays “quarter”. If both the first and second pins are high, then LCD displays “half full”.
Similarly if the first three pins are high then we infer from the LCD that the water level is three
quarters of the tank. Likewise a high on all four pins displays the message “full”. Once the water
tank is full, the buzzer produces a short audible sound warning the user to switch off the motor.
[4]
Jadhav, G. J, “Design and Implementation of Advanced ARM Based Surveillance System
using Wireless Communication, International Journal of Advance Research in Computer
Science and Management Studies” Vol 2, 2014.
This proposed paper is focused on the notion of water level monitoring and management within the
context of electrical conductivity of the water. More specifically, It illustrates investigation of the
microcontroller based water level sensing and controlling in a wired and wireless environment.
Water Level management approach would help in reducing the home power consumption and as
well as water overflow.it can indicate the amount of water in the tank that can support Global Water
types including cellular dataloggers, satellite data transmission systems for remote water monitoring
system. At the first stage of design a water level sensor is been made for sensing water level
accurately. Microcontroller is used to control the overall system automatically that reduces the
design and control complexity. Microcontroller takes input from the sensor unit which senses the
water level through inverter. After processing input variables, resultant output decides the water
pump’s action (on/off) with respect to current water status of the tank. The main intension of this
research work was to establish a flexible, economical and easy configurable system which can solve
our water losing problem. We have been used a low cost PIC 16F84A microcontroller in this
system which is the key point to reduce.
                                               11
[5]
Priya B. Patel, Viraj M. Choksi, Swapna Jadhav, M.B. Potdar, “Smart Motion Detection
System using Raspberry Pi”, International Journal of Applied Information Systems (IJAIS),
Vol10 – No.5, February 2016.
The paper illustrates to make a smart surveillance system which can be monitored by owner
remotely. As it is connected with the system with IOT, system will send the notifications when an
intrusion is detected inside the room. It is required to develop and implement affordable low cost
web-camera based surveillance system for remote security monitoring. Authorized user can access
to their monitoring system remotely via internet with the use a mobile phone and monitor the
situation on application. This project describes the use of low-cost single – board computer
Raspberry Pi with wireless internet. This work is focused on developing a surveillance system that
detects stranger and to response speedily by capturing and relaying images to admin office based
wireless module and thus activate the alert system both at intruder location and office admin.
Surveillance System consists of mainly two parts: A. Hard-wired surveillance systems: These
systems use wires to connect the cameras, motion detectors, power supply and LAN cable with the
pi., Remote Access Systems. 2. USB Camera, Raspberry Pi, Android device, PIR sensor whose
sensitivity range up to 20 feet (6 meters) 110 degrees * 60 degrees. Softwares like Python, NOOBS,
PUTTY, RASPBIAN OS are to be used. Therefore this kind of real time Surveillance system has
great prospect of in building a secured digital world.
[6]
S. M. Khaled Reza, Shah Ahsanuzzaman Md. Tariq, “Microcontroller Based Automated
Water Level Sensing and Controlling: Design and Implementation Issue”, Proceedings of the
World Congress on Engineering and Computer Science 2010 Vol I WCECS 2010, October 20-
22, 2010, San Francisco, USA.
This paper introduces the notion of water level monitoring and management within the context of
electrical conductivity of the water. More specifically, It investigate the microcontroller based water
level sensing and controlling in a wired and wireless environment. From the users perspective, it is
required to reuse such valuable resource in a mobile application. Finally, It proposes a web and
cellular based monitoring service protocol would determine and senses water level globally. To
implement the system we should use some necessary parts such as PIC 16F84A microcontroller,
Crystal Oscillator, 2 capacitor having capacitance 22 pF and 27 pF, inverter, LED, water tank,
water level sensor, water pump, transistor, inductor and some capacitor should be implemented.
When the water is decreasing from the tank by home use, the display LED should start to become
OFF one after another from the top to bottom. If all the LEDs becomes OFF that means the tank
becomes empty again and the water pump should becomes automatically ON again exactly after the
last LED becomes OFF. These operations should automatically perform as a cycle. This article
focuses on displaying the available local connections and the stored remote connections through the
internet & Designing interactive application software for remote PC or mobile should display data
in table format or in the graphical interface for integration of the wireless water level monitoring.
                                               12
[7]
R. S. SUNMONU, M. A. SODUNKE, O. S. ABDULAI & E. A. AGBOOLA
“DEVELOPMENT OF AN ULTRASONIC SENSOR BASED WATER LEVEL
INDICATOR WITH PUMP SWITCHING TECHNIQUE”, International Journal For
Research In Electronics & Electrical Engineering ISSN: 2208-2735
The liquid levels determination is done by electronically converting the time of arrival of echo as
recorded by the receiver (R) of the ultrasonic sensor from incident waves from transmitter (T).
Arduino UNO, an active microprocessor in this design is commercially available which is
electronically and mechanically fragile, hence the needs to replace Arduino UNO with rugged and
cost effective fabricated units from available cheap components. This paper looks into the
development and implementation of such a simple and cost effective feedback regulator for use in
applications where there are needs to real timely monitor the water levels. The aim of this present
work is to develop an independent water level control system with design based on ultrasonic
transducer (sensor) thereby addressing problems of untimely response and frequent breakdown of
contact sensors due to surface coating and corrosion from the water medium which characterized
existing water level control based contact sensors. Our developed system controls, monitors and
maintains the water level in the tank (overhead or surface ) and ensures the continuous flow of
water round the clock without the labor stress of manually switching the pump ON or OFF thereby
saving time, electrical energy, water, and prevent overworking of the feed pump. The non contact
ultrasonic sensor is strategically positioned on the peak of the vessel thereby solving the problems
of frequent replacement of contact and submersible sensor which characterize existing commercial
and expensive water indicator. The module detected, controlled and maintained the level of water.
The level of the water in the vessel is indicated in % of the volume holding capacity of the tank
which is displayed on the Liquid Crystal Display (LCD) unit.
                                              13
CHAPTER 3
  (Theory)
     14
3.1       IoT (Internet of Things)
IoT (Internet of Things) is an advanced automation and analytics system which exploits networking,
sensing, big data, and artificial intelligence technology to deliver complete systems for a product or
service. These systems allow greater transparency, control, and performance when applied to any
industry or system.
IoT systems have applications across industries through their unique flexibility and ability to be
suitable in any environment. They enhance data collection, automation, operations, and much more
through smart devices and powerful enabling technology.
                                                  15
  •     Enhanced Data Collection − Modern data collection suffers from its limitations and its
        design for passive use. IoT breaks it out of those spaces, and places it exactly where humans
        really want to go to analyze our world. It allows an accurate picture of everything.
  •     Device Integration
        Software supporting integration binds (dependent relationships) all system devices to create the
        body of the IoT system. It ensures the necessary cooperation and stable networking between
        devices. These applications are the defining software technology of the IoT network because
        without them, it is not an IoT system. They manage the various applications, protocols, and
        limitations of each device to allow communication.
                                                 16
  •     Real-Time Analytics
        These applications take data or input from various devices and convert it into viable actions or
        clear patterns for human analysis. They analyze information based on various settings and
        designs in order to perform automation-related tasks or provide the data required by industry.
RFID (radio-frequency identification) and NFC (near-field communication) provide simple, low
energy, and versatile options for identity and access tokens, connection bootstrapping, and payments.
   •    RFID technology employs 2-way radio transmitter-receivers to identify and track tags
        associated with objects.
   •    NFC consists of communication protocols for electronic devices, typically a mobile device
        and a standard device.
Low-Energy Bluetooth
This technology supports the low-power, long-use need of IoT function while exploiting a standard
technology with native support across systems.
Low-Energy Wireless
This technology replaces the most power hungry aspect of an IoT system. Though sensors and other
elements can power down over long periods, communication links (i.e., wireless) must remain in
listening mode. Low-energy wireless not only reduces consumption, but also extends the life of the
device through less use.
Radio Protocols
ZigBee, Z-Wave, and Thread are radio protocols for creating low-rate private area networks. These
technologies are low-power, but offer high throughput unlike many similar options. This increases
the power of small local device networks without the typical costs.
LTE-A
LTE-A, or LTE Advanced, delivers an important upgrade to LTE technology by increasing not only
its coverage, but also reducing its latency and raising its throughput. It gives IoT a tremendous power
through expanding its range, with its most significant applications being vehicle, UAV, and similar
communication.
                                                 17
WiFi-Direct
WiFi-Direct eliminates the need for an access point. It allows P2P (peer-to-peer) connections with
the speed of WiFi, but with lower latency. WiFi-Direct eliminates an element of a network that often
bogs it down, and it does not compromise on speed or throughput.
IoT has applications across all industries and markets. It spans user groups from those who want to
reduce energy use in their home to large organizations who want to streamline their operations. It
proves not just useful, but nearly critical in many industries as technology advances and we move
towards the advanced automation imagined in the distant future.
Applications of IoT in these areas include improving production, marketing, service delivery, and
safety. IoT provides a strong means of monitoring various processes; and real transparency creates
greater visibility for improvement opportunities.
The deep level of control afforded by IoT allows rapid and more action on those opportunities, which
include events like obvious customer needs, nonconforming product, malfunctions in equipment,
problems in the distribution network, and more.
IoT applied to government and safety allows improved law enforcement, defense, city planning, and
economic management. The technology fills in the current gaps, corrects many current flaws, and
expands the reach of these efforts. For example, IoT can help city planners have a clearer view of the
impact of their design, and governments have a better idea of the local economy.
In our daily lives, IoT provides a personalized experience from the home to the office to the
organizations we frequently do business with. This improves our overall satisfaction, enhances
productivity, and improves our health and safety. For example, IoT can help us customize our office
space to optimize our work.
IoT pushes us towards our imagined future of medicine which exploits a highly integrated network of
sophisticated medical devices. Today, IoT can dramatically enhance medical research, devices, care,
and emergency care. The integration of all elements provides more accuracy, more attention to detail,
faster reactions to events, and constant improvement while reducing the typical overhead of medical
research and organizations.
                                               18
3.2      NODE MCU
Node MCU is an open source IoT platform.                 It includes       firmware      which runson
the ESP8266 from Espressif, and hardware which is based on the ESP12 module. The term
"Node MCU" by default refers to the firmware rather than the dev kits. The firmware uses
the Lua scripting language. It is based on the eLua project, and built on the Espress if Non-OS SDK
for ESP8266. It uses many open source projects, such as lua-cjson, and spiffs.
Node MCU was created shortly after theESP8266 came out. On December 30, 2013, Espressif system
began production of the ESP8266. The ESP8266 is a Wi-Fi SoCintegrated with a TensilicaXtensa
LX106 core, widely used in IoT applications
The ESP8266 is a low-cost Wi-Fi microchip with full TCP/IP stack and microcontroller capability
produced by Shanghai-based Chinese manufacturer, Espressif Systems.
                                               19
                         Table 1: Node MCU index↔gpio mapping
                                     ESP826
                      IO index        6 pin        IO index   ESP8266 pin
1 GPIO5 8 GPIO15
2 GPIO4 9 GPIO3
3 GPIO0 10 GPIO1
4 GPIO2 11 GPIO9
5 GPIO14 12 GPIO10
6 GPIO12
[*] D0(GPIO16) can only be used as GPIO read/write. No support for open-drain/interrupt/pwm/i2c
                                              20
                 Figure 6: Snapshot of the installation process of NODE MCU
  •     Node MCU Amica is a ESP8266 wifi Module based development board. It has got Micro
        USB slot that can be directly connected to the computer or other USB host devices. It has
        got 15X2 Header pins and a Micro USB slot, the headers can be mounted on breadboard
        and the micro USB slot is for connection to USB host device that may be a computer. It
        has got CP2102 USB to serial converter.
  •     In order to install CP2102 (USB to Serial Converter), user will need to download the
        driver for the same.
  •     Once user downloaded drivers as per the proper operating system; the syste         has got
        connected with the node MCU.
  •     From the device manager of the computer note down the COM port allocated to the
        newly connected USB device i.e. the node MCU Amcia. This com port number will be
        required while using Node MCU Amica.
                                                21
                              Figure 8: Arduino IDE preferences
After completing the above steps , go to Tools and board, and then select board Manager
                                               22
                      Figure 10: ESP 8266 board installation in Arduino
Navigate to esp8266 by esp8266 community and install the software for Arduino.
Once all the above process had been completed we are ready to program our esp8266 with Arduino
IDE.
 The ultrasonic se nsor works on the principle of SONAR and RADAR system which is used to
 determine the distance to an object.
 An ultrasonic sensor generates the high-frequency sound (ultrasound) waves. When this ultrasound
 hits the object, it reflects as echo which is sensed by the receiver as shown in below figure 1.
 By measuring the time required for the echo to reach to the re ceiver, we can calculate the distance.
 This is the basic working principle of Ultrasonic module to me asure distance.
                                               23
                         Figure 12: Ultrasonic Working Principle
                                              24
     3.3.2 Distance Calculation using HC SR 04
     We know that,
                                         Distance = Speed x Time
     Total distance is divided by 2 because signal travels from HC-SR04 to object and returns to the
     module HC-SR-04.
     Hcsr04 can measure distance between an active range of 2 cm to 4 meters. Hcsr04 requires 5 volts
     and 15 mA of power for operation. Hcsr04 has four pins. Two are power pins. Vcc is +ve pin apply
     5v to this pin and Gnd is ground pin connect -ve of 5v power source with it. The other two pins
     are Trigger and Echo.
                                                  25
                       Figure 14: Interfacing HC SR 04 with NODE MCU
Once the unique ID is generated the next step is to include that key in the coding which is
written in embedded C for communication between the NODE MCU and Blynk server. The
process is described below.
                                                 26
 The NODE MCU should be connected through
 wifi
                                            27
Figure 18: Blynk app user interface
                28
CHAPTER 4
(Logic & Operation)
         35
5.1 INTRODUCTION
  After assembling the system, what remains is to observe its operation and efficiency of the
  system. The total system is divided in several sub systems, like
      •    Low cost : The Node MCU is less costlier than any other IOT based Devices.Because the
           wifi module which is used in it is of lowest cost.
      •    Hardware Part: It has Arduino Like hardware I/O. It is becoming very popular in these days
           that Arduino IDE has extended their software to work in the field of ESP 8266 Field module
           version.
      •    Integrated Wifi Module: ESP 8266 is incorporated in NODE MCU. It is an easily accessible
           wifi module.
5.3.2 Disadvantages
   •      The operation of the circuit depends on the working internet connection. If the working
          internet connection is not available then it will not run.
   •      It also depends on the free server provided by the third party, if the free server is not
          working then it will not run.
   •      NODE MCU has less resources of official documentation
Blynk was designed for the Internet of Things. It can control hardware remotely, it can display
sensor data, it can store data, visualize it and do many other things.
There are three major components in the platform:
   •     Blynk App - allows to you create amazing interfaces for your projects using various widgets
         we provide.
   •     Blynk Server - responsible for all the communications between the smartphone and
         hardware. You can use our Blynk Cloud or run your private Blynk server locally. It’s open-
         source, could easily handle thousands of devices and can even be launched on a Raspberry
         Pi.
   •     Blynk Libraries - for all the popular hardware platforms - enable communication with the
         server and process all the incoming and outgoing commands.
Now imagine: every time you press a Button in the Blynk app, the message travels to space the
Blynk Cloud, where it magically finds its way to your hardware. It works the same in the opposite
direction and everything happens in a blynk of an eye.
                                                    37
                              Figure 25: Blynk working principle
                                      39
    Chapter 5
(Conclusion   & Future Scope)
               41
6.1    Conclusion
Here we developed a circuit which will control and monitor the water level of an overhead tank
using IOT. It also limits the wastage of water problem due to lack of proper monitoring in the
home. It consists mainly following parts wifi device, Node MCU, OLED, ultrasonic sensor (HC
SR 04). First it needs to be check whether our module is connected to wifi or not. If it is
connected, it will directly show the water level on OLED as well as on mobile. It continuously
monitors the water level of the tank. Whenever the level crosses the predefined set lower, water
pump will automatically start and if the water level crosses the upper limit of the tank then the
pump will automatically stop to prevent wastage of water.
6.2    Result
The experimental model was made according to the circuit diagram and the results were as
expected. The blink app and the OLED show the water level of an overhead tank as soon as it is
connected to the wifi. After proper monitoring it switch on water pump according to the
situation.
In our project, we have used 19W submersible centrifugal water pump which is installed in the
lower reservoir, but there is no sensor or setup which can measure lower reservoir water level. If
water is dried out and the water level becomes below the pump set up. Then pump would not be
submerged in the lower water reservoir, diffuser could not suck the water by backward curved
vanes. As a result, Motor may burn. So this is the main limitation of our project.
For the industry usage, when water pump will be allowed to uplift water from lower reservoir or
local pond, river, then mud, sand, pebbles, household junks, wastes, plastics can block the water
pipe attached with the motor. So we must check the basic quality of water by Turbidity
sensors. It measures the amount of light that is scattered by the suspended solids in water. As the
amount of total suspended solids (TSS) in water increases, the water's turbidity level (and
cloudiness or haziness) increases. On another hand, ph. meter is also used to make sure of the
acidity of the water.
Hot water can harm the valves, vanes and pumps efficiency. Some thermocouple sensors or
thermistors can measure the lower level reservoirs water temperature. The thermocouple is
prepared by two dissimilar metals which generate the electrical voltage indirectly proportional to
change the temperature. By this process, we can implement some IoT devices to show temp data
in both upper and lower reservoir and upload it in the server.
                                              42
4) Including the rain water storage
By 2020 about 30-40% of the world will have water scarcity, and according to the researchers,
climate change can make this even worse. By 2025, an estimated 1.8 billion people will live in areas
plagued by water scarcity, with two-thirds of the world’s population living in water-stressed
regions. Collecting rainwater has many advantages. When harvesting rainwater on a slope or hill,
it can prevent soil erosion caused by water runoff after heavy rains. Rainwater
harvesting structures are easy to build, do not require expensive materials and are low-
maintenance. So distilled water saving is very necessary. Rain water is the huge source of it. So our
future plan is to make a rain water reservoir for additional purpose.
                                              43
Chapter 6
 (References)
      44
[1]   Charles A, “IOT BASED WATER LEVEL MONITORING SYSTEM USING
      LABVIEW” ,International Journal of Pure and Applied Mathematics,Volume
      118 No. 20 2018, 9-14 ISSN: 1311-8080 (printed version); ISSN: 1314-3395
      (on-line version).
[3]   Neena Mani, Sudeesh T.P, Vinu Joseph, Titto V.D, Shamnas P.S, “Design and
      Implementation of a Automated Water Level Indicator”, International Journal of
      Advanced Research in Electrical, Electronics and Instrumentation Engineering
      2014 Vol 3 Issue 2, February 2014.
[5]   Priya B. Patel, Viraj M. Choksi, SwapnaJadhav, M.B. Potdar, “Smart Motion
      Detection System using Raspberry Pi”, International Journal of Applied
      Information Systems (IJAIS), Vol10 – No.5, February 2016.
                                        45
 Appendix A
(Hardware description)
          46
Transformer less AC to DC power supply circuit using
dropping capacitor
Production of low voltage DC power supply from AC power is the most important problem faced by
many electronics developers and hobbyists. The straight forward technique is the use of a step down
transformer to reduce the 230 V or 110V AC to a preferred level of low voltage AC. But SMPS
power supply comes with the most appropriate method to create a low cost power supply by avoiding
the use of bulky transformer. This circuit is so simple and it uses a voltage dropping capacitor in
series with the phase line. Transformer less power supply is also called as capacitor power supply. It
can generate 5V, 6V, 12V 150mA from 230V or 110V AC by using appropriate zener diodes.
•    This transformer less power supply circuit is also named as capacitor power supply since it uses
     a special type of AC capacitor in series with the main power line.
•    A common capacitor will not do the work because the mains spikes will generate holes in the
     dielectric and the capacitor will be cracked by passing of current from the mains through the
     capacitor.
• X rated capacitor suitable for the use in AC mains is vital for reducing AC voltage.
•    A X rated dropping capacitor is intended for 250V, 400V, 600V AC. Higher voltage versions
     are also obtainable. The dropping capacitor is non polarized so that it can be connected any way
     in the circuit.
•    The 470kΩ resistor is a bleeder resistor that removes the stored current from the capacitor when
     the circuit is unplugged. It avoids the possibility of electric shock.
•    Reduced AC voltage is rectified by bridge rectifier circuit. We have already discussed about
     bridge rectifiers. Then the ripples are removed by the 1000µF capacitor.
                                               47
•    This circuit provides 24 volts at 160 mA current at the output. This 24 volt DC can be regulated
     to necessary output voltage using an appropriate 1 watt or above zener diode.
•    Here we are using 6.2V zener. You can use any type of zener diode in order to get the required
     output voltage.
Relay Driver
Resistor
Resistance is the opposition of a material to the current. It is measured in Ohms Ω. All conductors
represent a certain amount of resistance, since no conductor is 100% efficient. To control the electron
flow (current) in a predictable manner, we use resistors. Electronic circuits use calibrated lumped
resistance to control the flow of current. Broadly speaking, resistor can be divided into two groups
viz. fixed & adjustable (variable) resistors. In fixed resistors, the value is fixed & cannot be varied. In
variable resistors, the resistance value can be varied by an adjuster knob. It can be divided into (a)
Carbon composition (b) Wire wound (c) Special type. The most common type of resistors used in our
projects is carbon type. The resistance value is normally indicated by color bands. Each resistance has
four colors, one of the band on either side will be gold or silver, this is called fourth band and
indicates the tolerance, others three band will give the value of resistance (see table). For example if a
resistor has the following marking on it say red, violet, gold. Comparing these colored rings with the
                                                  48
color code, its value is 27000 ohms or 27 kilo ohms and its tolerance is ±5%. Resistor comes in
various sizes (Power rating).The bigger the size, the more power rating of 1/4 watts. The four color
rings on its body tells us the value of resistor value.
                                              49
RELAY
F
i
g
u
r
e
A relay is an electrically operated switch. Current flowing through the coil of the relay
creates a magnetic field which attracts a lever and changes the switch contacts. The
coil current can be on or off so relays have two switch positions and they are double
throw (changeover) switches.
The relay’s switch connections are usually labeled COM (POLE), NC and NO:
NC = Normally Closed, COM/POLE is connected to this when the relay coil is not
magnetized.
                                         50
OLED
An organic light-emitting         diode (OLED) is a light-emitting          diode (LED) in which
the emissive electroluminescent layer is a film of organic compound that emits light in response to an
electric current. This organic layer is situated between two electrodes; typically, at least one of these
electrodes is transparent. OLEDs are used to create digital displays in devices such
as television screens, computer monitors, portable systems such as smart phones, handheld game
consoles and PDAs. A major area of research is the development of white OLED devices for use
in solid-state lighting applications.
NodeMCU
NodeMCU is an o pen source IoT platform. It includes firmware which runs on the ESP8266 Wi-
Fi SoC from Espressif Systems, and hardware which is based on the E SP-12 module. The t erm
"NodeMCU" by default refers to the firmware rather than the development kits. The firmware uses
the Lua scripting la nguage. It is based on the eLua project, and built on the Espressif Non-OS SDK
for ESP8266. It uses many ope n source pr ojects, such as lua-cjson and SPIFFS.
Piezo buzzer
A buzzer or beeper is an audio signaling device, w ich may be mechanical, electromechanical, or
piezoelectric. Typical uses of buzzers and beepers include alarm devices, timers and confirmation of
                                                 51
user input such as a mouse click or keystroke. A piezoelectric element may be driven by an
oscillating electronic circuit or other audio signal source, driven with a piezoelectric audio amplifier.
Sounds commonly used to indicate that a button has been pressed are a click, a ring or a beep.
Blank PCB
A printed circuit board (PCB) mechanically supports and electrically connects electronic
components using conductive tracks,      pads     and     other    features etched from      copper
sheets laminated onto a non-conductive substrate. PCBs can be single sided (one copper
layer), double sided (two copper layers) or multi-layer (outer and inner layers). Multi-layer PCBs
allow for much higher component density. Conductors on different layers are connected with plated-
through holes called vias. Advanced PCBs may contain components - capacitors, resistors or active
devices - embedded in the substrate.
FR-4 glass epoxy is the primary insulating substrate upon which the vast majority of rigid PCBs are
produced. A thin layer of copper foil is laminated to one or both sides of an FR-4 panel. Circuitry
interconnections are etched into copper layers to produce printed circuit boards. Complex circuits are
produced in multiple layers.
Printed circuit boards are used in all but the simplest electronic products. Alternatives to PCBs
include wire wrap and point-to-point construction. PCBs require the additional design effort to lay
out the circuit, but manufacturing and assembly can be automated. Manufacturing circuits with PCBs
is cheaper and faster than with other wiring methods as components are mounted and wired with one
single part. Furthermore, operator wiring errors are eliminated.
                                                 52
Appendix B
(Software coding)
        53
PROGRAM CODE:
   #include <ESP8266WiFi.h>
   #include <BlynkSimpleEsp8266.h>*
   #include <SPI.h>
   #include <Wire.h>
   #include <Adafruit_GFX.h>
   #include <Adafruit_SSD1306.h>
   #define TRIGGERPIN D4
   #define ECHOPIN D5
   #define PUMP   D6
   /* TIMER */
   #include <SimpleTimer.h>
   SimpleTimer timer;
void loop()
{
timer.run(); // Initiates SimpleTimer
Blynk.run();
display.drawLine(6,40,120,40, WHITE);
display.setCursor(33,46);
display.setTextSize(1);
display.println("R C C I I T");
display.display();
}
/***************************************************
 * Send Sensor data to Blynk
 **************************************************/
void getSendData()
{
  // Clears the trigPin
digitalWrite(TRIGGERPIN, LOW);
delayMicroseconds(3);
digitalWrite(TRIGGERPIN, HIGH);
delayMicroseconds(12); // it may be 10 us
                                             55
digitalWrite(TRIGGERPIN, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(ECHOPIN, HIGH);
// Calculating the distance
  distance = (duration/2) / 29.1;
  distance1=20-distance;
  percentage = (distance1*100)/15;
  if (distance1 <= 3)
    {
digitalWrite(PUMP, HIGH);
pumpstatus = 255;
    }
    else if (distance1 >= 13)
      {
digitalWrite(PUMP, LOW);
pumpstatus = 0;
      }
Serial.println(" ");
Serial.print("Free Level : ");
Serial.print(distance);
Serial.print(" cm. Water Level: ");
Serial.print(distance1);
Serial.print(" cm. ");
Serial.print(" percentage = ");
Serial.print(percentage);
Serial.print(" %");
Blynk.virtualWrite(3, distance); //virtual pin V3
Blynk.virtualWrite(2, distance1); //virtual pin V2
Blynk.virtualWrite(4, pumpstatus); //virtual pin V4
Blynk.virtualWrite(5, percentage); //virtual pin V5
delay(500);
}
                                            56
Appendix C
 (Data sheets)
       57
                                              Tech Support: services@elecfreaks.com
Product features:
⚫   5V Supply
⚫   Trigger Pulse Input
⚫   Echo Pulse Output
⚫   0V Ground
Electric Parameter
Working Voltage                               DC 5 V
Working Current                               15mA
Working Frequency                             40Hz
Max Range                                     4m
Min Range                                     2cm
MeasuringAngle                                15 degree
Trigger Input Signal                          10uS TTL pulse
Echo Output Signal                            Input TTL lever signal and the range in
                                              proportion
Dimension                                     45*20*15mm
                                    Vcc   Trig Echo       GND
Timing diagram
The Timing diagram is shown below. You only need to supply a short 10uS
pulse to the trigger input to start the ranging, and then the module will send out
an 8 cycle burst of ultrasound at 40 kHz and raise its echo. The Echo is a
distance object that is pulse width and the range in proportion .You can
calculate the range through the time interval between sending trigger signal and
receiving echo signal. Formula: uS / 58 = centimeters or uS / 148 =inch; or: the
range = high level time * velocity (340M/S) / 2; we suggest to use over 60ms
measurement cycle, in order to prevent trigger signal to the echo signal.
    Attention:
                                 www.Elecfreaks.com
                Handson Technology
User Manual V1.2
The ESP8266 is the name of a micro controller designed by Espressif Systems. The
ESP8266 itself is a self-contained WiFi networking solution offering as a bridge from
existing micro controller to WiFi and is also capable of running self-contained applications.
This module comes with a built in USB connector and a rich assortment of pin-outs. With a
micro USB cable, you can connect NodeMCU devkit to your laptop and flash it without any
trouble, just like Arduino. It is also immediately breadboard friendly.
     1                                                            www.handsontec.com
Table of Contents
1.      Specification .............................................................................................................................................................. 3
2.      Pin Definition ............................................................................................................................................................. 3
3.      Using Arduino IDE...................................................................................................................................................... 3
     3.1        Install the Arduino IDE 1.6.4 or greater ............................................................................................................. 4
     3.2        Install the ESP8266 Board Package.................................................................................................................... 4
     3.3        Setup ESP8266 Support ..................................................................................................................................... 5
     3.4        Blink Test ........................................................................................................................................................... 7
     3.5        Connecting via WiFi ........................................................................................................................................... 9
4.      Flashing NodeMCU Firmware on the ESP8266 using Windows .............................................................................. 12
     4.1 Parts Required ....................................................................................................................................................... 12
     4.2 Pin Assignment ...................................................................................................................................................... 12
     4.3 Wiring .................................................................................................................................................................... 13
     4.4 Downloading NodeMCU Flasher for Windows ...................................................................................................... 13
     4.5 Flashing your ESP8266 using Windows.................................................................................................................. 13
5.      Getting Started with the ESPlorer IDE ..................................................................................................................... 15
     5.1 Installing ESPlorer .................................................................................................................................................. 15
     5.2 Schematics ............................................................................................................................................................. 18
     5.3 Writing Your Lua Script .......................................................................................................................................... 18
6. NodeMCU GPIO for Lua ............................................................................................................................................... 22
7. Web Resources ............................................................................................................................................................ 22
           2                                                                                                                        www.handsontec.com
1. Specification:
   • Voltage:3.3V.
   • Wi-Fi Direct (P2P), soft-AP.
   • Current consumption: 10uA~170mA.
   • Flash memory attachable: 16MB max (512K normal).
   • Integrated TCP/IP protocol stack.
   • Processor: Tensilica L106 32-bit.
   • Processor speed: 80~160MHz.
   • RAM: 32K + 80K.
   • GPIOs: 17 (multiplexed with other functions).
   • Analog to Digital: 1 input with 1024 step resolution.
   • +19.5dBm output power in 802.11b mode
   • 802.11 support: b/g/n.
   • Maximum concurrent TCP connections: 5.
2. Pin Definition:
 3                                                           www.handsontec.com
The most basic way to use the ESP8266 module is to use serial commands, as the chip is basically a WiFi/Serial
transceiver. However, this is not convenient. What we recommend is using the very cool Arduino ESP8266 project,
which is a modified version of the Arduino IDE that you need to install on your computer. This makes it very
convenient to use the ESP8266 chip as we will be using the well-known Arduino IDE. Following the below step to
install ESP8266 library to work in Arduino IDE environment.
You can also try downloading the ready-to-go package from the ESP8266-Arduino project, if the proxy is giving you
problems.
      4                                                                                 www.handsontec.com
                          Click ‘Tools’ -> ‘Board:’ -> ‘Board Manager…’ to access this panel.
Scroll down to ‘ esp8266 by ESP8266 Community ’ and click “Install” button to install the ESP8266 library package.
Once installation completed, close and re-open Arduino IDE for ESP8266 library to take effect.
Select 80 MHz as the CPU frequency (you can try 160 MHz overclock later)
      5                                                                               www.handsontec.com
Select ‘115200’ baud upload speed is a good place to start - later on you can try higher speeds but 115200 is a good
safe place to start.
Go to your Windows ‘Device Manager’ to find out which Com Port ‘USB-Serial CH340’ is assigned to. Select the
matching COM/serial port for your CH340 USB-Serial interface.
      6                                                                             www.handsontec.com
Find out which Com Port is assign for CH340            Select the correct Com Port as indicated on ‘Device Manager”
Note: if this is your first time using CH340 “ USB-to-Serial ” interface, please install the driver first before proceed
the above Com Port setting. The CH340 driver can be download from the below site:
https://github.com/nodemcu/nodemcu-devkit/tree/master/Drivers
Enter this into the sketch window (and save since you'll have to). Connect a LED as shown in Figure3-1.
                    void setup() {
                      pinMode(5, OUTPUT);            // GPIO05, Digital Pin D1
                    }
                    void loop() {
                      digitalWrite(5, HIGH);
                      delay(900);
                      digitalWrite(5, LOW);
                      delay(500);
                    }
Now you'll need to put the board into bootload mode. You'll have to do this before each upload. There is no timeout
for bootload mode, so you don't have to rush!
        7                                                                              www.handsontec.com
    •   When you release the ‘RST’ button, the blue indication will blink once, this means its ready to bootload.
Once the ESP board is in bootload mode, upload the sketch via the IDE, Figure 3-2.
        8                                                                              www.handsontec.com
                           Figure 3.2: Uploading the sketch to ESP8266 NodeMCU module.
The sketch will start immediately - you'll see the LED blinking. Hooray!
OK once you've got the LED blinking, let’s go straight to the fun part, connecting to a webserver. Create a new sketch
with this code:
to your WiFi access point and password, then upload the same way: get into bootload mode, then upload code via
IDE.
             /*
              * Simple HTTP get webclient test
              */
             #include <ESP8266WiFi.h>
             const char* ssid     = "handson";                    // key in your own SSID
             const char* password = "abc1234";                    // key in your own WiFi access point
             password
      9                                                                              www.handsontec.com
     const char* host = "www.handsontec.com";
     void setup() {
       Serial.begin(115200);
       delay(100);
         Serial.println();
         Serial.println();
         Serial.print("Connecting to ");
         Serial.println(ssid);
WiFi.begin(ssid, password);
         Serial.println("");
         Serial.println("WiFi connected");
         Serial.println("IP address: ");
         Serial.println(WiFi.localIP());
     }
int value = 0;
     void loop() {
       delay(5000);
       ++value;
         Serial.print("connecting to ");
         Serial.println(host);
         // Read all the lines of the reply from server and print them to Serial
         while(client.available()){
           String line = client.readStringUntil('\r');
           Serial.print(line);
         }
         Serial.println();
         Serial.println("closing connection");
     }
10                                                           www.handsontec.com
Open up the IDE serial console at 115200 baud to see the connection and webpage printout!
That's it, pretty easy right ! This section is just to get you started and test out your module.
      11                                                                         www.handsontec.com
                              Product          Sample &         Technical           Tools &            Support &
                              Folder           Buy              Documents           Software           Community
2 Applications
                                                                                               Device Information(1)
•   Relay Drivers                                                         PART NUMBER           PACKAGE            BODY SIZE (NOM)
•   Stepper and DC Brushed Motor Drivers                                 ULx200xD           SOIC (16)           9.90 mm × 3.91 mm
•   Lamp Drivers                                                         ULx200xN           PDIP (16)           19.30 mm × 6.35 mm
•   Display Drivers (LED and Gas Discharge)                              ULN200xNS          SOP (16)            10.30 mm × 5.30 mm
•   Line Drivers                                                         ULN200xPW          TSSOP (16)          5.00 mm × 4.40 mm
•   Logic Buffers                                                        (1) For all available packages, see the orderable addendum at
                                                                             the end of the data sheet.
3 Description
The ULx200xA devices are high-voltage, high-current
Darlington transistor arrays. Each consists of seven
NPN Darlington pairs that feature high-voltage
outputs with common-cathode clamp diodes for                                             Simplified Block Diagram
switching inductive loads.                                                                                               9
                                                                                                                             COM
The collector-current rating of a single Darlington pair                                1                              16
                                                                                  1B                                         1C
is 500 mA. The Darlington pairs can be paralleled for
higher current capability. Applications include relay                                   2                              15
drivers, hammer drivers, lamp drivers, display drivers                            2B                                         2C
(LED and gas discharge), line drivers, and logic
buffers. For 100-V (otherwise interchangeable)                                          3                              14
versions of the ULx2003A devices, see the SLRS023                                 3B                                         3C
data sheet for the SN75468 and SN75469 devices.
                                                                                        4                              13
The ULN2002A device is designed specifically for use                              4B                                         4C
with 14-V to 25-V PMOS devices. Each input of this
device has a Zener diode and resistor in series to                                      5                              12
                                                                                  5B                                         5C
control the input current to a safe limit. The
ULx2003A devices have a 2.7-kΩ series base resistor                                     6                               11
for each Darlington pair for operation directly with                              6B                                         6C
TTL or 5-V CMOS devices.
                                                                                        7                              10
                                                                                  7B                                         7C
      An IMPORTANT NOTICE at the end of this data sheet addresses availability, warranty, changes, use in safety-critical applications,
      intellectual property matters and other important disclaimers. PRODUCTION DATA.
ULN2002A, ULN2003A, ULN2003AI
ULQ2003A, ULN2004A, ULQ2004A
SLRS027O – DECEMBER 1976 – REVISED JANUARY 2016                                                                                                                    www.ti.com
                                                                         Table of Contents
    1   Features .................................................................. 1      7    Parameter Measurement Information.................. 10
    2   Applications ............................................................ 1        8    Detailed Description ............................................. 12
    3   Description .............................................................. 1             8.1    Overview ................................................................ 12
    4   Revision History ..................................................... 2                 8.2    Functional Block Diagrams ..................................... 12
    5   Pin Configuration and Functions .......................... 3                             8.3    Feature Description................................................. 13
    6   Specifications ......................................................... 4               8.4    Device Functional Modes........................................ 13
         6.1 Absolute Maximum Ratings ...................................... 4             9    Application and Implementation.......................... 14
         6.2 ESD Ratings............................................................. 4          9.1 Application Information............................................ 14
         6.3 Recommended Operating Conditions ....................... 4                          9.2 Typical Application .................................................. 14
         6.4 Thermal Information.................................................. 4             9.3 System Examples ................................................... 17
         6.5 Electrical Characteristics: ULN2002A........................ 5                10 Power Supply Recommendations ....................... 18
         6.6 Electrical Characteristics: ULN2003A and                                      11 Layout ................................................................... 18
             ULN2004A ................................................................ 5         11.1    Layout Guidelines ................................................. 18
         6.7 Electrical Characteristics: ULN2003AI....................... 6                      11.2    Layout Example .................................................... 18
         6.8 Electrical Characteristics: ULN2003AI....................... 6                12 Device and Documentation Support .................. 19
         6.9 Electrical Characteristics: ULQ2003A and                                            12.1    Documentation Support ........................................ 19
             ULQ2004A ................................................................ 7
                                                                                                 12.2    Related Links........................................................ 19
         6.10 Switching Characteristics: ULN2002A, ULN2003A,
                                                                                                 12.3    Community Resources ......................................... 19
             ULN2004A ................................................................ 7
                                                                                                 12.4    Trademarks .......................................................... 19
         6.11 Switching Characteristics: ULN2003AI .................... 7
                                                                                                 12.5    Electrostatic Discharge Caution ............................ 19
         6.12 Switching Characteristics: ULN2003AI .................... 8
                                                                                                 12.6    Glossary ............................................................... 19
         6.13 Switching Characteristics: ULQ2003A, ULQ2004A 8
         6.14 Typical Characteristics ............................................ 8       13 Mechanical, Packaging, and Orderable
                                                                                              Information ............................................................ 19
4 Revision History
NOTE: Page numbers for previous revisions may differ from page numbers in the current version.
•   Added Pin Configuration and Functions section, ESD Ratings table, Feature Description section, Device Functional
    Modes, Application and Implementation section, Power Supply Recommendations section, Layout section, Device
    and Documentation Support section, and Mechanical, Packaging, and Orderable Information section.................................. 1
•   Deleted Ordering Information table. No specification changes................................................................................................ 1
•   Moved Typical Characteristics into Specifications section. ..................................................................................................... 8
• Updated temperature rating for ULN2003AI in the ORDERING INFORMATION table ........................................................... 1
                                                             1B    1       16   1C
                                                             2B    2       15   2C
                                                             3B    3       14   3C
                                                             4B    4       13   4C
                                                             5B    5       12   5C
                                                             6B    6       11   6C
                                                             7B    7       10   7C
                                                              E    8        9   COM
                                                                Pin Functions
             PIN
                               I/O(1)                                                 DESCRIPTION
 NAME              NO.
 1B                 1
 2B                 2
 3B                 3
 4B                 4             I       Channel 1 through 7 Darlington base input
 5B                 5
 6B                 6
 7B                 7
 1C                16
 2C                15
 3C                14
 4C                13            O        Channel 1 through 7 Darlington collector output
 5C                12
 6C                11
 7C                10
 COM                9            —        Common cathode node for flyback diodes (required for inductive loads)
 E                  8            —        Common emitter shared by all channels (typically tied to ground)
6 Specifications
6.1 Absolute Maximum Ratings
at 25°C free-air temperature (unless otherwise noted)(1)
                                                                                                               MIN             MAX            UNIT
 VCC            Collector-emitter voltage                                                                                       50              V
                                              (2)
                Clamp diode reverse voltage                                                                                     50              V
 VI             Input voltage(2)                                                                                                30              V
                Peak collector current, See Figure 4 and Figure 5                                                               500            mA
 IOK            Output clamp current                                                                                            500            mA
                Total emitter-terminal current                                                                                 –2.5             A
                                                                                            ULN200xA           –20              70
                                                                                            ULN200xAI          –40             105
 TA             Operating free-air temperature range                                                                                            °C
                                                                                            ULQ200xA           –40              85
                                                                                            ULQ200xAT          –40             105
 TJ             Operating virtual junction temperature                                                                          150             °C
                Lead temperature for 1.6 mm (1/16 inch) from case for 10 seconds                                                260             °C
 Tstg           Storage temperature                                                                            –65             150              °C
(1)     Stresses beyond those listed under Absolute Maximum Ratings may cause permanent damage to the device. These are stress ratings
        only, and functional operation of the device at these or any other conditions beyond those indicated under Recommended Operating
        Conditions is not implied. Exposure to absolute-maximum-rated conditions for extended periods may affect device reliability.
(2)     All voltage values are with respect to the emitter/substrate terminal E, unless otherwise noted.
(1)     JEDEC document JEP155 states that 500-V HBM allows safe manufacturing with a standard ESD control process.
(2)     JEDEC document JEP157 states that 250-V CDM allows safe manufacturing with a standard ESD control process.
(1) For more information about traditional and new thermal metrics, see the Semiconductor and IC Package Thermal Metrics application
    report, SPRA953.