0% found this document useful (0 votes)
12 views88 pages

Ultrasonic Sensor Based Water Level Monitoring and Control Using Iot

The document presents a project report on an Ultrasonic Sensor based Water Level Monitoring and Control system using IoT, submitted by four B.Tech students from RCC Institute of Information Technology. The project aims to automate water level management in overhead tanks by using ultrasonic sensors and NodeMCU to monitor and control water levels remotely via the Blynk app. It includes detailed sections on the project's introduction, theory, hardware modeling, logic and operation, and future scope.

Uploaded by

Goku Son
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views88 pages

Ultrasonic Sensor Based Water Level Monitoring and Control Using Iot

The document presents a project report on an Ultrasonic Sensor based Water Level Monitoring and Control system using IoT, submitted by four B.Tech students from RCC Institute of Information Technology. The project aims to automate water level management in overhead tanks by using ultrasonic sensors and NodeMCU to monitor and control water levels remotely via the Blynk app. It includes detailed sections on the project's introduction, theory, hardware modeling, logic and operation, and future scope.

Uploaded by

Goku Son
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 88

Ultrasonic Sensor based Water Level

Monitoring and Control using IoT

A Project report submitted in partial fulfillment


of the requirements for the degree of B. Tech in Electrical Engineering

by

SOUVIK NASKAR (11701616021)


TANMOY SAMANTA (11701616014)
SK MD RAMIZE RAJA(11701616026)
RAJCHANDRA BANERJEE(11701616043)

Under the supervision of

Mr. Budhaditya Biswas


Assistant Professor
Department of Electrical Engineering

Department of Electrical Engineering


RCC INSTITUTE OF INFORMATION TECHNOLOGY
CANAL SOUTH ROAD, BELIAGHATA, KOLKATA – 700015, WEST BENGAL
Maulana Abul Kalam Azad University of Technology (MAKAUT)
© 2020
Department of Electrical Engineering
RCC INSTITUTE OF INFORMATION TECHNOLOGY
CANAL SOUTH ROAD, BELIAGHATA, KOLKATA – 700015, WEST BENGAL
PHONE: 033-2323-2463-154, FAX: 033-2323-4668
Email: [email protected], Website: http://www.rcciit.org/academic/ee.aspx

CERTIFICATE
To whom it may concern

This is to certify that the project work entitled Ultrasonic Sensor based Water Level
Monitoring and Control using IoTis the bonafide work carried out bySouvikNaskar
(11701616021), Tanmoy Samanta (11701616014), Sk Md Ramize Raja
(11701616026),Rajchandra Banerjee (11701616043),the students of B.Tech in the
Department of Electrical Engineering, RCC Institute ofInformation Technology (RCCIIT),
Canal South Road, Beliaghata, Kolkata-700015,affiliated to Maulana Abul Kalam Azad
University of Technology (MAKAUT), WestBengal, India, during the academic year 2019-
20, in partial fulfillment of therequirements for the degree of Bachelor of Technology in
Electrical Engineeringand that this project has not submitted previously for the award of any
otherdegree, diploma and fellowship.

(Budhaditya Biswas)
Assistant Professor
Department of Electrical Engineering
RCC Institute of Information Technology

Countersigned by

(Dr. Debasish Mondal)


HOD, Electrical Engineering Dept (External Examiner)
RCC Institute of Information Technology
ACKNOWLEDGEMENT

It is our great fortune that we have got opportunity to carry out this project work
under the supervision of Mr. Budhaditya Biswas in the Department of Electrical
Engineering, RCC Institute of Information Technology (RCCIIT), Canal South
Road, Beliaghata, Kolkata-700015, 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 Engineering, RCCIIT for their whole hearted
cooperation to make this work turn into reality.

We are very thankful to our Department and to the authority of RCCIIT for
providing all kinds of infrastructural facility towards the research work.

Thanks to the fellow members of our group for working as a team.

SOUVIK NASKAR (11701616021)

TANMOY SAMANTA (11701616014)

SK MD RAMIZE RAJA (11701616026)

RAJCHANDRA BANERJEE(11701616043)
To

The Head of the Department


Department of Electrical Engineering
RCC Institute of Information Technology
Canal South Rd. Beliaghata, Kolkata-700015

Respected Sir,

In accordance with the requirements of the degree of Bachelor of Technology in the Department
of Electrical Engineering, RCC Institute of Information 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. Budhadtiya Biswas, Assistant
Professor in the Dept. of Electrical 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,

SOUVIK NASKAR (11701616021)

TANMOY SAMANTA (11701616014)

SK MD RAMIZE RAJA (11701616026)

RAJCHANDRA BANERJEE(11701616043)
Contents
Topic Page No.
List of figures i

List of tables ii

Abbreviations and acronyms iii

Abstract 1

Chapter 1 (Introduction)

1.1 Introduction 3

1.2 Ultrasonic Module HC-SR04 3

1.3 HC-SR04 Ultrasonic Module Timing Diagram 4

1.4 Distance calculation using HC-SR04 5

1.5 Overview & Benefits of the project 5

1.5.1 Advantages of Water level Indicators 5

& Float Switch

1.5.2 Applications & Uses of Water Level Indicator 6

1.5.3 Benefits of Water level Indicators 7

& Water Alarms

1.6 Organization of thesis 7

Chapter 2 (Literature Review) 9

Chapter 3 (Theory)

3.1 IoT (Internet of Things) 15

3.1.1 IoT – Key Features 15

3.1.2 IoT – Advantages 15

3.1.3 IoT - Disadvantages 16

3.1.4 IoT Software 16


3.1.5 IoT – Technology and Protocols 17

3.1.6 IoT common uses 18

3.2 Node MCU 19

3.2.1 Pin Configuration of Node MCU Dev Board 19

3.2.2 Installation of Node MCU and coding 20

3.2.3 Interfacing of Node MCU with Arduino IDE 21

3.3 Ultrasonic Module HC-SR04 23

3.3.1 HC-SR04 Ultrasonic Module Timing Diagram 24

3.3.2 Distance Calculation using HC-SR04 25

3.3.3 Interfacing the Ultrasonic Sensor The µC 25

3.4 Overview of the projects 26

3.5 Circuit Diagram 27

Chapter 4 (Hardware Modeling)

4.1 Main Features of the Prototype 30

4.2 Photographs of the prototype 30

4.3 Step by step operation of the prototype 31

4.4 Components Required 32

4.5 Hardware Interfacing 32

4.5.1 Relay Driver Interfacing with µC 32

4.5.2 HC-SR04 Interfacing with Node MCU 33

4.5.3 OLED Interfacing with Node MCU 33

Chapter 5 (Logic & Operation)

5.1 Introduction 36

5.2 Flow chart 36

5.3 Principle & operations 36

5.3.1 Advantages of Node MCU 37


5.3.2 Disadvantages of Node MCU 37

5.4 Blynk App 37

5.5 HC-SR04 Ultrasonic Sensors features 38

5.6 Cost estimation of the project 38

5.7 Photographs of the prototype 39

Chapter 6 (Conclusion & Future scope)

6.1 Conclusion 42

6.2 Results 42

6.3 Future works 42

Chapter 7 (Reference) 44

Appendix A (Hardware Description) 46 – 52

Appendix B (Software Coding) 53 – 56

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

Sl. No. Table Page No.

1 Node MCU index↔ GPIO mapping 20


2 Component Listing 32
3 Cost estimation of the project 38

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.

In this project a transmitter circuit consists of an ultrasonic sensor to


measure the water level in terms of distance. This data is sent to the
microcontroller and a local OLED display is there to monitor the water
level all time. The controller is attached with a relay driver which
further controls the water pump. The controller decides when the pump
should be ON and OFF according the level of the water present in the
overhead tank. It simultaneously sends the data to the Blynk clouds
using internet. User can monitor the water level in a smart phone using
Blynk app.

1
CHAPTER 1
(Introduction)
2
1.1 INTRODUCTION
The process requirement in many industries,farms, hostels, hotels etc includes an
overheadtank for water, which is usually fed through anelectric pump that is switched off when the
tankis filled up, and on when it becomes empty. Assuch, the most common way of knowing when
thetank is filled is by observing when it overflowsthe brim. Depending on the type of liquid
beinghandled, the overfilling of such a tank could leadto heavy material losses. These losses can
beprevented if the tank is regulated automaticallyby incorporating a feed-back control
mechanism,which would be capable of tripping the pump onor off as required. Although pumps
equippedwith variable speed motors could be more efficientthan on/off mechanisms, the former are
expensiveto procure and maintain, especially for small andmedium enterprises. Furthermore,
commerciallyavailable water level sensors are expensive beingimported into the country and as
such cannot bedeployed in every household.Control systems are classified as open loop orclosed
loop. In open loop systems a command isgiven to a system and it is assumed the systemperforms
properly. A closed loop system, on theother hand, compares the result or output of thesystem to a
desired output and takes appropriatecorrective 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.

NodeMCU 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.

1.2 Ultrasonic Module HC-SR04

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
Figgure 1: Ultraasonic Work
king Principple

1.3 HC-SR044 Ultrason


nic Modu
ule Timing
g Diagram
m

1. We need to trransmit triggger pulse of


W o at least 100 us to the HC-SR04
H Trrig Pin.
2. Thhen the HC C-SR04 autoomatically sends Eigh ht 40 kHz soound wave and wait for f rising eddge
ouutput at Echho pin.
3. W
When the rissing edge caapture occurrs at Echo pin,
p start the Timer andd wait for falling
f edge on
Echo pin.
4. A soon as thhe falling eddge is captuured at the Echo
As E pin, reead the counnt of the Tim
mer. This tiime
coount is the time
t requireed by the sennsor to deteect an objectt and returnn back from an object.

Figuree 2: Ultrasonnic Module Timing Diaagram

4
1.4 Distance Calculation using HC SR 04
We know that,
Distance = Speed x Time

The speed of sound waves is 343 m/s.


So,

Total distance is divided by 2 because signal travels from HC-SR04 to object and returns to the
module HC-SR-04.

1.5 Overview and benefits of the project

1.5.1 Advantages of Water Level Indicators & Float Switches


There are many advantages of water level controls, also known also water level indicators,
including:

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.

6. New Control Minimize Fouling & Deterioration


Proving to be less costly, over time, than the original float design for the ‘toilet tank’. The solid-
state electronics are designed to minimize volt usage (less than 1 volt). This directly minimizes the
mineral fouling, plating, rusting, and deterioration of probes, proving to be safer and more efficient.
These factors extend the life span of the controllers significantly, which saves money and energy.

7. Easy Installation with LED Monitoring


These new solid-state electronics and integrated electronics offer superior performance, hassle-free
installation, and lower cost to operate over time when compared to the lifespan of the original
design. For continuous monitoring, the integrated firmware and digital dry-contact circuitry easily
and quickly connect to the automation systems of a building. Each function of the integrated
electronics and relays use LED lights to offer operators the ability to visually scan them in order to
verify proper operations.

1.5.2 Applications & Uses of Water Level Indicator


The uses of a water level indicator include the following applications:

 Can be used in water tanks to control water levels


 Automatically turn ON/OFF pumps
 Can be used in factories, commercial complexes, apartments, home,
 Fuel tank level gauging
 Oil tank level control
 High & low-level alarms
 Pool water level control
 Life station switches
 Leachate level control
 Cooling tower water level control
 Sewage pump level control
 Remote monitoring liquid
 Water level control
 Pump controller
 Stream level monitoring
 Sump pump
6
 Tsunami warning and sea level monitoring
 Process batch control & monitoring
 Irrigation control

1.5.3 Benefits of Water Level Indicators & Water Alarms


There are many benefits of water level indicators and water alarms including:

 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
.

1.6 Organization of thesis

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.

Chapter 7 References are listed in this chapter

Appendix A, B & C Hardware description, software coding and datasheets are listed here.

8
CHAPTER 2
(Literature Review)
9
[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).

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.

Machine-to-Machine (M2M) communications involvemachines communicating with each other and


exchanginginformation with remote servers, possibly over a
cellularnetworkinfrastructure.Currently, in LTE-Advanced systems, themain focus has been on
supporting massive deployment of lowcost devices, with enhanced radio access network
coverage.One key requirement for supporting M2M in LTE is theavailability of low cost devices.
Typical LTE devices havebeen designed to provide broadband services. For example,
the least capable LTE device, called Category-1 device, has 2receive antennas, RF bandwidth of 20
MHz, and can supportdata rates of 10 Mbps in the downlink and 5 Mbps in theuplink.One key
requirement for supporting M2M in LTE is theavailability of low cost devices. Typical LTE
devices havebeen designed to provide broadband services. For example,the least capable LTE
device, called Category-1 device, has 2receive antennas, RF bandwidth of 20 MHz, and can
supportIt is predicted that in 2020 the total number of connected
devices will be about 50 billion , almost double comparingto today’s number.data rates of 10 Mbps
in the downlink and 5 Mbps in theuplink.Machine-to-Machine communication, with its capability
ofproviding diverse set of applications and services, isconsidered to be a key technology
enhancement for 4G LTEAdvancedsystems, and is anticipated to maintain itsdominance in 5G
systems as well.

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 anlcd 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.Thenon 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 (Internat 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.

3.1.1 IoT − Key Features


The most important features of IoT include artificial intelligence, connectivity, sensors, active
engagement, and small device use. A brief review of these features is given below
 AI − IoT essentially makes virtually anything “smart”, meaning it enhances every aspect of
life with the power of data collection, artificial intelligence algorithms, and networks. This can
mean something as simple as enhancing your refrigerator and cabinets to detect when milk and
your favorite cereal run low, and to then place an order with your preferred grocer.
 Connectivity − New enabling technologies for networking, and specifically IoT networking,
mean networks are no longer exclusively tied to major providers. Networks can exist on a
much smaller and cheaper scale while still being practical. IoT creates these small networks
between its system devices.
 Sensors − IoT loses its distinction without sensors. They act as defining instruments which
transform IoT from a standard passive network of devices into an active system capable of
real-world integration.
 Active Engagement − Much of today's interaction with connected technology happens
through passive engagement. IoT introduces a new paradigm for active content, product, or
service engagement.
 Small Devices − Devices, as predicted, have become smaller, cheaper, and more powerful
over time. IoT exploits purpose-built small devices to deliver its precision, scalability, and
versatility.

3.1.2 IoT − Advantages


The advantages of IoT span across every area of lifestyle and business. Here is a list of some of the
advantages that IoT has to offer
 Improved Customer Engagement − Current analytics suffer from blind-spots and significant
flaws in accuracy; and as noted, engagement remains passive. IoT completely transforms this
to achieve richer and more effective engagement with audiences.
 Technology Optimization − The same technologies and data which improve the customer
experience also improve device use, and aid in more potent improvements to technology. IoT
unlocks a world of critical functional and field data.
 Reduced Waste − IoT makes areas of improvement clear. Current analytics give us
superficial insight, but IoT provides real-world information leading to more effective
management of resources.

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.

3.1.3 IoT − Disadvantages


Though IoT delivers an impressive set of benefits, it also presents a significant set of challenges.Here
is a list of some its major issues

 Security − IoT creates an ecosystem of constantly connected devices communicating over


networks. The system offers little control despite any security measures. This leaves users
exposed to various kinds of attackers.
 Privacy − The sophistication of IoT provides substantial personal data in extreme detail
without the user's active participation.
 Complexity − Some find IoT systems complicated in terms of design, deployment, and
maintenance given their use of multiple technologies and a large set of new enabling
technologies.
 Flexibility − Many are concerned about the flexibility of an IoT system to integrate easily
with another. They worry about finding themselves with several conflicting or locked systems.
 Compliance − IoT, like any other technology in the realm of business, must comply with
regulations. Its complexity makes the issue of compliance seem incredibly challenging when
many consider standard software compliance a battle.

3.1.4 IotSoftware
IoT software addresses its key areas of networking and action through platforms, embedded systems,
partner systems, and middleware. These individual and master applications are responsible for data
collection, device integration, real-time analytics, and application and process extension within the
IoT network. They exploit integration with critical business systems (e.g., ordering systems, robotics,
scheduling, and more) in the execution of related tasks.
 Data Collection
This software manages sensing, measurements, light data filtering, light data security, and
aggregation of data. It uses certain protocols to aid sensors in connecting with real-time,
machine-to-machine networks. Then it collects data from multiple devices and distributes it in
accordance with settings. It also works in reverse by distributing data over devices. The system
eventually transmits all collected data to a central server.

 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.

 Application and Process Extension


These applications extend the reach of existing systems and software to allow a wider, more
effective system. They integrate predefined devices for specific purposes such as allowing
certain mobile devices or engineering instruments access. It supports improved productivity
and more accurate data collection.

3.1.5 Internet of Things - Technology and Protocols


IoT primarily exploits standard protocols and networking technologies. However, the major enabling
technologies and protocols of IoT are RFID, NFC, low-energy Bluetooth, low-energy wireless, low-
energy radio protocols, LTE-A, and WiFi-Direct. These technologies support the specific networking
functionality needed in an IoT system in contrast to a standard uniform network of common systems.

NFC and RFID

RFID (radio-frequency identification) and NFC (near-field communication) provide simple,


lowenergy, 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.

3.1.6 Internet of Things - Common Uses

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.

Engineering, Industry, and Infrastructure

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.

Government and Safety

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.

Home and Office

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.

Health and Medicine

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
M

NodeMCU is an open source s IoT platform.


p It incluudes firm mware wh hich runsson
the ESP8266 from Espressif,
E a
and hardwaare which is based on the E ESP12 mod dule.The teerm
"NodeMC CU" by deefault referrs to the firmware
f raather than the dev kkits. The firmware
f u
uses
the Lua sccripting lannguage. It iss based on the eLua prroject, and built on thee Espressif Non-OS SD DK
for ESP82266. It usess many openn source proojects, such as lua-cjsonn,and spiffss.

Figuree 3: NODE MCU Deveelopment booard

NodeMCU was creaated shortly after theES SP8266 camme out. On December
D 30, 2013,Esppressiv systtem
beganproduction of the ESP82266. The ES SP8266 is a Wi-Fi SooCintegratedd with a TeensilicaXtennsa
LX106 coore,widely used
u in IoT applicationns
The ESP88266 is a low-cost Wii-Fi microchhip with fu ull TCP/IP stack and m
microcontro
oller capabillity
producedd by Shanghhai-based Chhinese manuufacturer, Espressif
E Systems.

Figure 4:
4 NODE MCU
M with in
nbuilt wifi module
m

3.2.1 Pin configuration of NODE


E MCU deevelopment board
This moddule providdes access to t the GPIO O (General Purpose
P Inpput/Output)) subsystem
m.All accesss is
based on the I/O inddex numberr on the NodeMCU dev v kits, not the
t internall GPIO pin.. For exampple,
the D0 pin on the devv kit is mappped to the internal
i GPIO pin 16.
Please reffer to the beelow GPIO pin maps foor the index
x↔gpio mappping.

19
Table 1: Node MCU index↔gpio mapping

ESP826
IO index IO index ESP8266 pin
6 pin
0 [*] GPIO16 7 GPIO13

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

Figure 5: NODE MCU pin configuration

3.2.2 Installation of Node MCU & Coding


Mostly these days devices download and install drivers on their own, automatically. Windows
doesn’t know how to talk to the USB driver on the Node MCU so it can’t figure out that the
board is a Node MCU and proceed normally.

20
Figgure 6: Snappshot of the installation
n process off NODE MC
CU

• Node MCU Amica


N A is a ESP8266
E w Module based development booard. It has got
wifi g Micro
U slot thatt can be direectly conneected to the computer or other USB
USB B host devicces. It has
goot 15X2 Heeader pins annd a Micro USB slot, the
t headers can be mouunted on brreadboard
annd the microo USB slot is for connnection to USB
U host deevice that m
may be a com
mputer. It
haas got CP21102 USB to serial convverter.

• Inn order to innstall CP21102 (USB to


t Serial Co
onverter), user
u will neeed to down
nload the
drriver for thee same.

• Once user doownloaded drivers as per the pro


oper operatiing system;; the system
m has got
coonnected wiith the nodee MCU.

• Frrom the devvice managger of the computer


c note
n down the
t COM pport allocated to the
neewly connected USB device
d i.e. the
t node MCU Amcia.. This com port numbeer will be
reequired whille using Node MCU Am mica.

Figuree 7: Driver Installation


I for NODE MCU

3.2.3 Interfacin
ng of nod
de mcu wiith arduin
no IDE
Firstly oppen the Arduuino IDE. Go
G to files and
a click on
n the prefereence in the A
Arduino IDE
E

21
Figure 8: Arduino IDE preferences

copy the below code in the Additional boards Manager


http://arduino.esp8266.com/stable/package_esp8266com_index.json
click OK to close the preference Tab

Figure 9: Arduino IDE board manager installation

After completing the above steps , go to Tools and board, and then select board Manager

22
Figure 100: ESP 82666 board insttallation in Arduino
A

Navigate to esp8266 by esp8266 community c and insstall the software for Arduino.
Once all the above process
p hadd been comppleted we are
a ready to program our esp8266 with Arduino
IDE.

Figure 11: NODE MCU


M interfaacing with Arduino
A

3.3 Ultrasoniic Modulee HC-SR004

The ulttrasonic sennsor works on the prinnciple of SONAR andd RADAR system wh
hich is usedd to
determiine the distaance to an object.
An ultraasonic sensor generates the high-ffrequency sounds (ultraasound) wavves. When this
t ultrasouund
hits the object, it reeflects as eccho which iss sensed by the receiveer as shown in below fig
gure 1.

By meaasuring the time


t requireed for the echo
e to reacch to the recceiver, we ccan calculate the distannce.
This is the
t basic woorking princciple of Ulttrasonic mod dule to meaasure distance.
23
Figuure 12: Ultrrasonic Worrking Princiiple

3.3.1 HC-SR044 Ultrason


nic Modu
ule Timing
g Diagram
m

5. We need to trransmit triggger pulse of


W o at least 100 us to the HC-SR04
H Trrig Pin.
6. Thhen the HC C-SR04 autoomatically sends Eigh ht 40 kHz soound wave and wait for f rising eddge
ouutput at Echho pin.
7. W
When the rissing edge caapture occurrs at Echo pin,
p start the Timer andd wait for falling
f edge on
Echo pin.
8. A soon as thhe falling eddge is captuured at the Echo
As E pin, reead the counnt of the Tim
mer. This tiime
coount is the time
t requireed by the sennsor to deteect an objectt and returnn back from an object.

Figure 13: Ultrasoonic Modulee Timing Diiagram

24
3.3.2 Distance Calculation using HC SR 04
We know that,
Distance = Speed x Time

The speed of sound waves is 343 m/s.


So,

Total distance is divided by 2 because signal travels from HC-SR04 to object and returns to the
module HC-SR-04.

3.3.3 Interfacing the Ultrasonic sensor with the microcontroller


Hcsr04 ultrasonic sensor is composed of ultrasonic transmitter, ultrasonic receiver and a control
circuit. Hscr04 ultrasonic transmitter transmits ultrasound waves at 40,000 Hz. Transmitted waves
bounce back if they hit any flat surface/object in their path. Bounced back waves reach the
ultrasonic receiver. Ultrasonic receiver receives the bounced back waves and notifies the control
circuit about it. Control circuit than calculates the time taken by waves to reach back after
transmission. Time is than manipulated to approximate the distance travelled by waves or what is
the distance between the sensor and the object? from which ultrasound waves bounced back.

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.

 Trigger pin is triggered by external controller to out burst an ultrasound wave.


 Echo pin notifies external controller when receiver receives back the bounced back wave.

25
Figure 144: Interfacinng HC SR 04
0 with NOD
DE MCU

3.4 Overview
w of the prroject
The folloowing proceess describees how to create
c an acccount in Blynk
B and ggenerate a unique
u ID
against a particular device.
d The ID is the iddentifier forr the particuular device in the Blynk
k server.

Downlload the Blynk


B app from play
ystore

Crreat an acccout in thee Blynk ussing faceb


book or
gooogle loginn

An unique ID is generatedd by the appp under


new project for each
e particcular devicce

Thhat ID shouuld be putt into the program


p w
which
is written
w in embedded dC

Thus Bllynk indenntifies the particularr device


and prov
vides partticular serrver for itss working
Figuree 15: Accouunt creation and generaation of uniqque ID in Blynk server

Once thee unique ID D is generatted the nexxt step is to


o include thhat key in tthe coding which is
written inn embeddedd C for com mmunicatioon between the NODE E MCU andd Blynk serrver. The
process iss described below.
26
The NODE
N MC
CU should be conneccted throu
ugh
wifi

thhe SSID annd passwoord of the wifi


w shoulld be
inncluded in the coodiing

Open Blynk
B app and creat a new pro
oject

Inssert the verrtical level display annd the Buttoon in


thee dashboardd with propper GPIO mentioned
m in the
coooding
Cretat annd event too control thhe water levvel if it
reaches the
t limits and
a a contrrol button to t control
the pumpp manuallyy

Figure 16: working prrocess of thee water leveel control deevice

3.5 Circuit Diagram


D

Figgure 17: Connnection diaagram of thhe project

27
Figure 18: Blynk app user interface

28
CHAPTER 4
(Hardware Modeling)
29
4.1 Main features of the prototype

The features of the developed prototype are:

 Automatic and manual control of the water pump


 Real time water level percentagedisplay in the OLED and mobile screen
 Static relay can handle the water pump easily (250 volt, 7 amp max, ON/OFF control)
 Maintain the water level to ensure all time availability of water
 Not contact sensor increases the life of the sensor
 Secure control
 5 Volt operation (both control board and relay board)

4.2 Photographs of the prototype

Figure 19: Main Controller with relay and OLED display module

30
4.3 Step by step operaation of th
he prototy
ype

1. Connect thhe DC adappter (5V, 1A


A) to the DC
C jack.

2. Enable thee pre-specifi


fied wifi (knnown SSID and passwoord mentionned
in the codee)

3. After enabbling the wifi check thee circuit OL


LED displayy.

4. Power On
4. Open the blynk app in
i the mobiile and check the wateer
level.

5. In the ‘Evventer’ wizaard of the Blynk


B app set
s the wateer
level limiits and the correspondding IO to operate thhe
controllingg water pum
mp.

6. Monitor thhe water levvel.

31
4.4 Components required

Table 2: Component listing

Sl.
Component Qtn
No.
1. HC SP 04 1
2. NODE MCU 1
3. Static Relay (5 volt) 1
4. 0.96” OLED 1
5. Water Pump 1
6. BC 547 1
7. 1k Resistor 1
8. 5mm Led 3
9. Relay terminals 1
10. Single strand wire 2m
11. IC base (14 pin) 1
12. Female PCB Header Connector 1
13. IC 7432 1
14. Latch Switch 1

4.5 Hardware connection


4.5.1 Relay Driver interfacing with microcontroller

Figure 20: ULN2003A interfacing with microcontroller

The ULN2003A is a active high relay driver. 7 relays are controlled by this relay driver. Pin 1-7
are for controlling the relays which are connected to pin 10-16. For a ‘0’ from microcontroller
the corresponding relay is turned off and a ‘1’ from microcontroller is turned on the relay.
32
4.5.2 HC SR 04 interfacing with NODE MCU

Hcsr04 ultrasonic sensor is composed of ultrasonic transmitter, ultrasonic receiver and a control
circuit. Hscr04 ultrasonic transmitter transmits ultrasound waves at 40,000 Hz. Transmitted
waves bounce back if they hit any flat surface/object in their path. Bounced back waves reach
the ultrasonic receiver. Ultrasonic receiver receives the bounced back waves and notifies the
control circuit about it. Control circuit than calculates the time taken by waves to reach back
after transmission. Time is than manipulated to approximate the distance travelled by waves or
what is the distance between the sensor and the object? from which ultrasound waves bounced
back.

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.

 Trigger pin is triggered by external controller to out burst an ultrasound wave.


 Echo pin notifies external controller when receiver receives back the bounced back wave.

Figure 21: Interfacing HC SR 04 with NODE MCU

4.5.3 OLED Graphic Display Interfacing with NodeMCU


OLED Display Module

The OLED module shown in the figure 22 is a very popular module available in the market.There
are many variants of this module available in market, having different resolutions, communication
protocol or pixel colors.They do not require backlight since the display creates its own light. Hence,
they consume less power. Both I2C and SPI based OLED modules are available in market.
33
A NodeMCU can communicate with this module using I2C communication protocol.
Pin Description

Figure 22: 128x64 I2C based OLED module.

VCC: This is the power pin for the module. A supply of 3.3V or 5V can be provided to this pin to
power the display.

GND:This is the ground pin for the module.

SCL and SDA:These are the serial clock and serial data pins for I2C Interface.

Interfacing Diagram

Figure 23: Interfacing OLED Display with NodeMCU

34
CHAPTER 5
(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

 Node MCU Section


 HC SR04 Section
 OLED Section
 Relay Section

The operation of the whole circuit is depending on every sections performance.

5.2 Flow Chart

Figure 24: Flow chart of the program

5.3 Principle &Operations

NodeMCU is an open source IoT platform. It includes firmware which runs on


the ESP8266 Wi-Fi SoC from Espressif Systems, and hardware which is based on the ESP-12
module. The term “NodeMCU” by default refers to the firmware rather than the development
kits. The firmware uses the Lua scripting language. It is based on the eLua project, and built on
the Espressif Non-OS SDK for ESP8266. It uses many open source projects, such as lua-cjson,
and spiffs.
36
5.3.1 Advantages of the NODE MCU

 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.

 Network API: Node MCU has easily configurable network API.

 Integrated Wifi Module: ESP 8266 is incorporated in NODE MCU.It is an easily


accessiblewifi 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 resourcesof official documentation

5.4 Blynk app

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

5.5 HC SR04 Ultrasonic sensors features


 Input Voltage: 5V
 Current Draw: 20mA (Max)
 Digital Output: 5V
 Digital Output: 0V (Low)
 Working Temperature: -15°C to 70°C
 Sensing Angle: 30° Cone
 Angle of Effect: 15° Cone
 Ultrasonic Frequency: 40kHz
 Range: 2cm - 400cm
 Dimensions
 Length: 43mm
 Width: 20mm
 Height (with transmitters): 15mm
 Centre screw hole distance: 40mm x 15mm
 Screw hole diameter: 1mm (M1)
 Transmitter diameter: 8mm

5.6 Cost estimation of the project


In this project we have used the cheapest IOT module NODE MCU. So the total cost of
the project is reduced compare to the other IOT project. The total estimated cost of the
complete project is listed in table 3.

Table 3: Costing of the projects

Sl. No. Component Cost


1. HC SP 04 120
2. NODE MCU 330
38
3. Static Relay (5 volt) 25
4. 0.96” OLED 400
5. Water Pump 290
6. BC 547 2
7. 1k Resistor 1
8. 5mm Led 3
9. Relay terminals 5
10. Single strand wire 30
11. IC base (14 pin) 5
12. Female PCB Header Connector 8
13. IC 7432 10
14. Latch Switch 5
15. General Blank PCB (KS100) 40
Total 1274/-

5.7 Photographs of the prototype

Figure 26: Main Controller Board

39
Figure 27: The whole prototype

Figure 28: The Blynk app user interface

40
Chapter 6
(Conclusion & Future Scope)
41
6.1 Conclusion
Here we developed a circuit which will control and monitor the water level of an overhead tank
usingIOT. It also limits the wastage of water problem due to lack of proper monitoring in the
home. It consists mainly following parts wifidevice,NodeMcu, 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.

6.3 Future work


Ultrasonic sensor based Water level Monitoring & Control using IoT:

1) Monitoring the lower reservoir level:

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.

2) Measuring the water quality:

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 byTurbidity 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.

3) Measuring the water temperature

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 7
(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).

[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.

[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.

[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.

[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.

[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.

[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

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.

Figure 29: Transformer less SMPS 5 volt power supply

Working of Transformer less capacitor power supply

 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

Figure 30: ULN2003A Internal Block Diagram

Resistor

Figure 31: 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.

Color Code of the resistor

Figure 32: Color Code for resistance

49
RELAY

F
i
g
u
r
e

Figure33: 6 volt Cube Relay

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:

COM/POLE= Common, NC and NO always connect to this, it is the moving part of


the switch.

NC = Normally Closed, COM/POLE is connected to this when the relay coil is not
magnetized.

NO = Normally Open, COM/POLE is connected to this when the relay coil is


MAGNETIZED and vice versa.

50
OLED
An organnic light-eemitting diode (OLE ED) is a light-em mitting dioode (LED) in whhich
the emisssive electrolluminescentt layer is a film
f of orgaanic compouund that emmits light in response too an
electric cuurrent. Thiss organic laayer is situatted betweenn two electrrodes; typiccally, at leasst one of these
electrodes is trannsparent. OLEDs O arre used to create digital
d dissplays in devices
d suuch
as television screens, computer monitors, portable sy ystems succh as smart phones, haandheld gaame
consoles and PDAs. A major area a of reseearch is the developmeent of whitte OLED deevices for use u
in solid-state lightingg applicatioons.

Figure34: 128X64 OLE


ED Moduule

NodeMCU
NodeMCU is an oppen source IoT platform m. It includdes firmwarre which ruuns on the ESP8266 Wi- W
Fi SoC frrom Espresssif Systemss, and harddware which h is based on the ES SP-12 modu ule. The teerm
"NodeMC CU" by deffault refers to the firmw ware ratherr than the development
d t kits. The firmware uses
u
the Lua sccripting lannguage. It iss based on the eLua prroject, and built on thee Espressif Non-OS SD DK
for ESP82266. It usess many openn source proojects, such as lua-cjsonn and SPIFF FS.

Figure35: Node
N MCU
U Modulee

Piezo bu
uzzer
A buzzerr or beeper is an audioo signaling device, wh hich may be mechaniccal, electrom mechanical,, or
piezoelecctric. Typicaal uses of buuzzers and beepers incclude alarm
m devices, tim
mers and co
onfirmationn 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.

Figure 36: Piezo Buzzer

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.

Figure 37: Blank glass epoxy PCB Board

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

char auth[] = "f6zC863whG90ypmSeKGSOUjDeBfhiy7R";

// Your WiFi credentials.


// Set password to "" for open networks.
char ssid[] = "Tanmoy";
char pass[] = "password1234";

/* TIMER */
#include <SimpleTimer.h>
SimpleTimer timer;

#define OLED_RESET D5 //14


Adafruit_SSD1306 display(OLED_RESET);

long duration, distance, distance1;


float percentage;
int pumpstatus;
void setup()
{
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.setCursor(0,0);
display.setTextSize(1);
display.drawRoundRect(0, 0, 128, 64, 8, WHITE);
display.drawRoundRect(5, 5, 118, 54, 8, WHITE);
// Sets the color to black with a white background
display.setTextColor(WHITE);
display.setCursor(30,8);
display.println("WATER LEVEL");
display.drawLine(6,17,120,17, WHITE);
display.setCursor(20,20);
display.println("Please connect");
display.setCursor(32,30);
display.println("the wifi...");
display.drawLine(6,40,120,40, WHITE);
display.setCursor(33,46);
display.println("R C C I I T");
display.display();
54
// Debug console
Serial.begin(115200);
pinMode(TRIGGERPIN, OUTPUT);
pinMode(ECHOPIN, INPUT);
pinMode(PUMP, OUTPUT);
Blynk.begin(auth, ssid, pass);
timer.setInterval(2000L, getSendData);
Serial.println(" ");
Serial.println("Sensing the Water Level");
}

void loop()
{
timer.run(); // Initiates SimpleTimer
Blynk.run();

//display the level into OLED


display.clearDisplay();
display.setCursor(0,0);
display.drawRoundRect(0, 0, 128, 64, 8, WHITE);
display.drawRoundRect(5, 5, 118, 54, 8, WHITE);

// Sets the color to black with a white background


display.setTextColor(WHITE);
display.setCursor(30,8);
display.setTextSize(1);
display.println("WATER LEVEL");
display.drawLine(6,17,120,17, WHITE);
display.setCursor(15,25);
display.println("LEVEL = ");
display.setTextSize(2);
display.setCursor(65,20);
display.println(distance1);
display.setCursor(100,20);
display.setTextSize(2);
display.println("cm");

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: [email protected]

Ultrasonic Ranging Module HC - SR04

 Product features:

Ultrasonic ranging module HC - SR04 provides 2cm - 400cm non-contact


measurement function, the ranging accuracy can reach to 3mm. The modules
includes ultrasonic transmitters, receiver and control circuit. The basic principle
of work:
(1) Using IO trigger for at least 10us high level signal,
(2) The Module automatically sends eight 40 kHz and detect whether there is a
pulse signal back.
(3) IF the signal back, through high level , time of high output IO duration is
the time from sending ultrasonic to returning.
Test distance = (high level time×velocity of sound (340M/S) / 2,

 Wire connecting direct as following:

 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:

  The module is not suggested to connect directly to electric, if connected


electric, the GND terminal should be connected the module first, otherwise,
it will affect the normal work of the module.
  When tested objects, the range of area is not less than 0.5 square meters
and the plane requests as smooth as possible, otherwise ,it will affect the
results of measuring.

www.Elecfreaks.com
Handson Technology
User Manual V1.2

ESP8266 NodeMCU WiFi Devkit

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. Using Arduino IDE

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.

3.1 Install the Arduino IDE 1.6.4 or greater


Download Arduino IDE from Arduino.cc (1.6.4 or greater) - don't use 1.6.2 or lower version! You can use your
existing IDE if you have already installed it.

You can also try downloading the ready-to-go package from the ESP8266-Arduino project, if the proxy is giving you
problems.

3.2 Install the ESP8266 Board Package


Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs
field in the Arduino v1.6.4+ preferences.

Click ‘File’ -> ‘Preferences’ to access this panel.

Next, use the Board manager to install the ESP8266 package.

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.

3.3 Setup ESP8266 Support


When you've restarted Arduino IDE, select ‘Generic ESP8266 Module’ from the ‘Tools’ -> ‘Board:’ dropdown menu.

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

3.4 Blink Test

We'll begin with the simple blink test.

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!

• Hold down the ‘Flash’ button.


• While holding down ‘ Flash’, press the ‘RST’ button.
• Release ‘RST’, then release ‘Flash’

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.

Figure3-1: Connection diagram for the blinking test

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!

3.5 Connecting via WiFi

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:

Don’t forget to update:

const char* ssid = "yourssid";

const char* password = "yourpassword";

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);

// We start by connecting to a WiFi network

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

WiFi.begin(ssid, password);

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


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

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

int value = 0;

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

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

// Use WiFiClient class to create TCP connections


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

// We now create a URI for the request


String url = "/projects/index.html";
Serial.print("Requesting URL: ");
Serial.println(url);

// This will send the request to the server


client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
delay(500);

// 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

ULN2002A, ULN2003A, ULN2003AI


ULQ2003A, ULN2004A, ULQ2004A
SLRS027O – DECEMBER 1976 – REVISED JANUARY 2016

ULN200x, ULQ200x High-Voltage, High-Current Darlington Transistor Arrays


1 Features The ULx2004A devices have a 10.5-kΩ series base
resistor to allow operation directly from CMOS

1 500-mA-Rated Collector Current (Single Output) devices that use supply voltages of 6 V to 15 V. The
• High-Voltage Outputs: 50 V required input current of the ULx2004A device is
• Output Clamp Diodes below that of the ULx2003A devices, and the required
• Inputs Compatible With Various Types of Logic voltage is less than that required by the ULN2002A
device.
• Relay-Driver Applications
.
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
8.4 Device Functional Modes........................................ 13
6 Specifications......................................................... 4
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.

Changes from Revision N (June 2015) to Revision O Page

• Changed Pin Functions table to correct typographical error. ................................................................................................ 3

Changes from Revision M (February 2013) to Revision N Page

• 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

Changes from Revision L (April 2012) to Revision M Page

• Updated temperature rating for ULN2003AI in the ORDERING INFORMATION table ........................................................ 1

Changes from Revision K (August 2011) to Revision L Page

• Removed reference to obsolete ULN2001 device.................................................................................................................. 1

2 Submit Documentation Feedback Copyright © 1976–2016, Texas Instruments Incorporated

Product Folder Links: ULN2002A ULN2003A ULN2003AI ULQ2003A ULN2004A ULQ2004A


ULN2002A, ULN2003A, ULN2003AI
ULQ2003A, ULN2004A, ULQ2004A
www.ti.com SLRS027O – DECEMBER 1976 – REVISED JANUARY 2016

5 Pin Configuration and Functions

D, N, NS, and PW Package


16-Pin SOIC, PDIP, SO, and TSSOP
Top View

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)

(1) I = Input, O = Output

Copyright © 1976–2016, Texas Instruments Incorporated Submit Documentation Feedback 3


Product Folder Links: ULN2002A ULN2003A ULN2003AI ULQ2003A ULN2004A ULQ2004A
ULN2002A, ULN2003A, ULN2003AI
ULQ2003A, ULN2004A, ULQ2004A
SLRS027O – DECEMBER 1976 – REVISED JANUARY 2016 www.ti.com

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.

6.2 ESD Ratings


VALUE UNIT
Electrostatic Human body model (HBM), per ANSI/ESDA/JEDEC JS-001 (1) ±2000
V(ESD) V
discharge Charged device model (CDM), per JEDEC specification JESD22-C101 (2) ±500

(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.

6.3 Recommended Operating Conditions


over operating free-air temperature range (unless otherwise noted)
MIN MAX UNIT
VCC Collector-emitter voltage (non-V devices) 0 50 V
TJ Junction temperature –40 125 °C

6.4 Thermal Information


ULx200x
D N NS PW
THERMAL METRIC (1) UNIT
(SOIC) (PDIP) (SO) (TSSOP)
16 PINS 16 PINS 16 PINS 16 PINS
RθJA Junction-to-ambient thermal resistance 73 67 64 108 °C/W
RθJC(top) Junction-to-case (top) thermal resistance 36 54 n/a 33.6 °C/W
RθJB Junction-to-board thermal resistance n/a n/a n/a 51.9 °C/W
ψJT Junction-to-top characterization parameter n/a n/a n/a 2.1 °C/W
ψJB Junction-to-board characterization parameter n/a n/a n/a 51.4 °C/W

(1) For more information about traditional and new thermal metrics, see the Semiconductor and IC Package Thermal Metrics application
report, SPRA953.

4 Submit Documentation Feedback Copyright © 1976–2016, Texas Instruments Incorporated

Product Folder Links: ULN2002A ULN2003A ULN2003AI ULQ2003A ULN2004A ULQ2004A


ULN2002A, ULN2003A, ULN2003AI
ULQ2003A, ULN2004A, ULQ2004A
www.ti.com SLRS027O – DECEMBER 1976 – REVISED JANUARY 2016

6.5 Electrical Characteristics: ULN2002A


TA = 25°C
ULN2002A
PARAMETER TEST FIGURE TEST CONDITIONS UNIT
MIN TYP MAX
VI(on) ON-state input voltage Figure 14 VCE = 2 V, IC = 300 mA 13 V
High-level output voltage after
VOH Figure 18 VS = 50 V, IO = 300 mA VS – 20 mV
switching
II = 250 μA, IC = 100 mA 0.9 1.1
Collector-emitter saturation
VCE(sat) Figure 12 II = 350 μA, IC = 200 mA 1 1.3 V
voltage
II = 500 μA, IC = 350 mA 1.2 1.6
VF Clamp forward voltage Figure 15 IF = 350 mA 1.7 2 V
Figure 9 VCE = 50 V, II = 0 50
ICEX Collector cutoff current VCE = 50 V, II = 0 100 μA
Figure 10
TA = 70°C VI = 6 V 500
II(off) OFF-state input current Figure 10 VCE = 50 V, IC = 500 μA 50 65 μA
II Input current Figure 11 VI = 17 V 0.82 1.25 mA
VR = 50 V TA = 70°C 100
IR Clamp reverse current Figure 14 μA
VR = 50 V 50
Ci Input capacitance VI = 0, f = 1 MHz 25 pF

6.6 Electrical Characteristics: ULN2003A and ULN2004A


TA = 25°C
TEST ULN2003A ULN2004A
PARAMETER TEST CONDITIONS UNIT
FIGURE MIN TYP MAX MIN TYP MAX
IC = 125 mA 5
IC = 200 mA 2.4 6
ON-state input IC = 250 mA 2.7
VI(on) Figure 14 VCE = 2 V V
voltage IC = 275 mA 7
IC = 300 mA 3
IC = 350 mA 8
High-level output
VOH voltage after Figure 18 VS = 50 V, IO = 300 mA VS – 20 VS – 20 mV
switching
II = 250 μA, IC = 100 mA 0.9 1.1 0.9 1.1
Collector-emitter
VCE(sat) Figure 13 II = 350 μA, IC = 200 mA 1 1.3 1 1.3 V
saturation voltage
II = 500 μA, IC = 350 mA 1.2 1.6 1.2 1.6
Figure 9 VCE = 50 V, II = 0 50 50
Collector cutoff
ICEX VCE = 50 V, II = 0 100 100 μA
current Figure 10
TA = 70°C VI = 6 V 500
Clamp forward IF = 350 mA
VF Figure 16 1.7 2 1.7 2 V
voltage
Off-state input VCE = 50 V,
II(off) Figure 11 IC = 500 μA 50 65 50 65 μA
current TA = 70°C,
VI = 3.85 V 0.93 1.35
II Input current Figure 12 VI = 5 V 0.35 0.5 mA
VI = 12 V 1 1.45
Clamp reverse VR = 50 V 50 50
IR Figure 15 μA
current VR = 50 V TA = 70°C 100 100
Ci Input capacitance VI = 0, f = 1 MHz 15 25 15 25 pF

Copyright © 1976–2016, Texas Instruments Incorporated Submit Documentation Feedback 5


Product Folder Links: ULN2002A ULN2003A ULN2003AI ULQ2003A ULN2004A ULQ2004A
ULN2002A, ULN2003A, ULN2003AI
ULQ2003A, ULN2004A, ULQ2004A
SLRS027O – DECEMBER 1976 – REVISED JANUARY 2016 www.ti.com

6.7 Electrical Characteristics: ULN2003AI


TA = 25°C
TEST ULN2003AI
PARAMETER TEST FIGURE UNIT
CONDITIONS MIN TYP MAX
IC = 200 mA 2.4
VI(on) ON-state input voltage Figure 14 VCE = 2 V IC = 250 mA 2.7 V
IC = 300 mA 3
High-level output voltage after
VOH Figure 18 VS = 50 V, IO = 300 mA VS – 50 mV
switching
II = 250 μA, IC = 100 mA 0.9 1.1
VCE(sat) Collector-emitter saturation voltage Figure 13 II = 350 μA, IC = 200 mA 1 1.3 V
II = 500 μA, IC = 350 mA 1.2 1.6
ICEX Collector cutoff current Figure 9 VCE = 50 V, II = 0 50 μA
VF Clamp forward voltage Figure 16 IF = 350 mA 1.7 2 V
II(off) OFF-state input current Figure 11 VCE = 50 V, IC = 500 μA 50 65 μA
II Input current Figure 12 VI = 3.85 V 0.93 1.35 mA
IR Clamp reverse current Figure 15 VR = 50 V 50 μA
Ci Input capacitance VI = 0, f = 1 MHz 15 25 pF

6.8 Electrical Characteristics: ULN2003AI


TA = –40°C to 105°C
ULN2003AI
PARAMETER TEST FIGURE TEST CONDITIONS UNIT
MIN TYP MAX
IC = 200 mA 2.7
VI(on) ON-state input voltage Figure 14 VCE = 2 V IC = 250 mA 2.9 V
IC = 300 mA 3
High-level output voltage after
VOH Figure 18 VS = 50 V, IO = 300 mA VS – 50 mV
switching
II = 250 μA, IC = 100 mA 0.9 1.2
VCE(sat) Collector-emitter saturation voltage Figure 13 II = 350 μA, IC = 200 mA 1 1.4 V
II = 500 μA, IC = 350 mA 1.2 1.7
ICEX Collector cutoff current Figure 9 VCE = 50 V, II = 0 100 μA
VF Clamp forward voltage Figure 16 IF = 350 mA 1.7 2.2 V
II(off) OFF-state input current Figure 11 VCE = 50 V, IC = 500 μA 30 65 μA
II Input current Figure 12 VI = 3.85 V 0.93 1.35 mA
IR Clamp reverse current Figure 15 VR = 50 V 100 μA
Ci Input capacitance VI = 0, f = 1 MHz 15 25 pF

6 Submit Documentation Feedback Copyright © 1976–2016, Texas Instruments Incorporated

Product Folder Links: ULN2002A ULN2003A ULN2003AI ULQ2003A ULN2004A ULQ2004A

You might also like