0% found this document useful (0 votes)
4 views

Automation and Management System Using Power Line Communication and IoT

Uploaded by

Megha Raj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Automation and Management System Using Power Line Communication and IoT

Uploaded by

Megha Raj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 74

AUTOMATION AND MANAGEMENT SYSTEM USING

POWER LINE COMMUNICATION AND IoT

A PROJECT REPORT

submitted by

AKHIL C S. (PKD16EE006)
AROMAL ANAND (PKD16EE013)
MEGHA RAJ (PKD16EE037)
MOHAMMED AJMAL V. (PKD16EE039)

to
the APJ Abdul Kalam Technological University
in partial fulfillment of the requirements for the award of the Degree

of

Bachelor of Technology
in
Electrical & Electronics Engineering

DEPARTMENT OF ELECTRICAL ENGINEERING


GOVERNMENT ENGINEERING COLLEGE PALAKKAD
June 2020
DEPARTMENT OF ELECTRICAL ENGINEERING
GOVERNMENT ENGINEERING COLLEGE PALAKKAD

CERTIFICATE

11th June, 2020

This is to certify that the report entitled ”Automation and Management System
Using Power Line Communication and IoT” submitted by Akhil C S. (PKD16EE006),
Aromal Anand (PKD16EE013), Megha Raj (PKD16EE037) and Mohammed Ajmal V.
(PKD16EE039) to the APJ Abdul Kalam Technological University in partial fulfillment of the
requirements for the award of the Degree of Bachelor of Technology in Electrical & Electronics
Engineering is a bonafide record of the project work carried out by them under our guidance
and supervision.

Project Guide Project Co-ordinator


Prof. Abdul Kareem Puthiya Veetil Dr. Vinita Chellappan
Assistant Professor Associate Professor
Dept. of Electrical Engineering Dept. of Electrical Engineering

Head of the Department


Dept. of Electrical Engineering
Contents

Acknowledgement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iv
Abstract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
List of Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
List of Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii

1 Introduction 2
1.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Literature Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2.1 Power Monitoring and Control for Electric Home Appliances Based on
Power Line Communication . . . . . . . . . . . . . . . . . . . . . . . 3
1.2.2 Power Line Communication Based Automation System Using a Hand-
held Wi-Fi Device . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2.3 Power Line Carrier Communication Based Low Cost Power Monitoring
and Management System . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2.4 Mobile based Home Automation using Internet of Things . . . . . . . 5
1.2.5 Smart Energy Efficient Home Automation System Using IoT . . . . . 5
1.2.6 A step towards Home Automation using IoT . . . . . . . . . . . . . . 6
1.2.7 Controlling home light using WiFi Node MCU, and Relay module us-
ing IoT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2.8 The power line home automation for voice communication and data
transmission using an existing power line . . . . . . . . . . . . . . . . 7
1.2.9 Design of Power Line Communication System . . . . . . . . . . . . . 7
1.2.10 FM generation and detection using CD4046 PLL IC . . . . . . . . . . 8
1.3 Outline of the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

2 Background and Methodology 10


2.1 Power Line Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

i
Contents ii

2.2 Internet of Things . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11


2.3 NodeMCU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.4 Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.5 PLC Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.6 FM Modulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.7 FM Demodulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.8 Coupling Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.9 Line Trap Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.10 Relay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.11 Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.11.1 Current Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.11.2 Temperature Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.11.3 Power Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.12 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

3 Model Configuration 21
3.1 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.2 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

4 System Design 23
4.1 Functional Block Diagram of PLC . . . . . . . . . . . . . . . . . . . . . . . . 23
4.2 FM Modulation and Demodulation using PLL . . . . . . . . . . . . . . . . . . 24
4.2.1 Circuit Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.2.2 Design of FM Modulation . . . . . . . . . . . . . . . . . . . . . . . . 25
4.2.3 Design of FM Demodulation . . . . . . . . . . . . . . . . . . . . . . . 26
4.3 Coupling Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.4 Line Trap Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

5 Simulation Studies 29
5.1 Control of Switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
5.2 Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5.3 FM Modulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
5.4 FM Demodulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.5 PLC Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
6 Experimental Setup 37
6.1 Hardware Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
6.2 Software requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
6.3 Working principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
6.4 Circuit Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
6.5 Hardware Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
6.6 MIT Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

7 Conclusions 42
7.1 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

References 43

Appendices 44

iii
Acknowledgements

First and foremost we wish to express our wholehearted inbedtedness to God Almighty for
the gracious constant care and blessings showered over us for the successfull completion of the
project.

We would like to take this oppurtunity to extend our sincere gratitude to Dr. Jose Sebastian
T K. , Head of Department, Electrical Engineering, for extending every facility to complete our
project work successfully.

We would like to express our sincere indebtedness to Prof. Abdul Kareem Puthiya Vet-
til, our guide and Assistant Professor, Department of Electrical Engineering, for his valuable
guidance, constructive criticism, wholehearted co-operation and continuous encouragement
throughout the project .

We also extend our gratitude towards all the teaching and non teaching staffs of Depart-
ment of Electrical Engineering for their sincere support and motivation during the course of our
project.

iv
Abstract

This project aims to develop a system for controlling and monitoring of electrical equip-
ments using power line communication and IoT. This system deals with the real time moni-
toring of power and current supplied to the domestic appliances. IoT is used to control the
turn ON and OFF of switches. A sensor that can be installed at an outlet to sense the power
and current of electrical appliances and to detect whether the switches are ON or OFF using
PLC. An android phone is used to display the current and power consumed by each equipment.
To improve the communication infrastructure, power lines can be utilized as communication
channel. The project also aims to design and implement Power Line Communication system
that consist of transmitter, receiver, coupling circuit and the power lines as the communication
medium. Advancement in IoT based application has become the state-of-the art technology due
to the availability of Internet everywhere. Smart energy efficient home automation system is
proposed that can access and control the home equipments from every corner of the world.

v
List of Figures

2.1 NodeMCU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.2 ATmega328 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.3 Relay Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.4 Current Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.5 Temperature Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.6 Power Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

3.1 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

4.1 Functional Block Diagram of PLC . . . . . . . . . . . . . . . . . . . . . . . . 23


4.2 Circuit for FM generation and detection using CD4046 PLL IC . . . . . . . . . 24
4.3 Coupling Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.4 Line Trap Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

5.1 Light ON Condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30


5.2 Light OFF Condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.3 Temperature Sensor Circuit Diagram . . . . . . . . . . . . . . . . . . . . . . 31
5.4 Temperature Sensor Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5.5 FM Modulation Circuit Diagram . . . . . . . . . . . . . . . . . . . . . . . . . 32
5.6 Carrier Wave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
5.7 FM Modulation Waveform . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.8 FM Demodulation Circuit Diagram . . . . . . . . . . . . . . . . . . . . . . . . 34
5.9 FM Demodulation Waveform . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
5.10 PLC Module Circuit Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . 35
5.11 PLC Module Waveform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

vi
6.1 Working principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
6.2 Circuit Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
6.3 Hardware Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
6.4 Mobile Application Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

7.1 PLC1762 Power Line Modem . . . . . . . . . . . . . . . . . . . . . . . . . . 46


7.2 Pin diagram of an ATmega 328 . . . . . . . . . . . . . . . . . . . . . . . . . . 47
7.3 Pin diagram of a NodeMCU ESP8266 . . . . . . . . . . . . . . . . . . . . . . 50
7.4 Block diagram of a PLL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
7.5 Pin diagram of a PLL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

vii
List of Tables

6.1 Connection between Relay module and Node MCU . . . . . . . . . . . . . . . 39

1
Chapter 1

Introduction

Home automation system is one of the systems that fits well in this scenario. Home au-
tomation or smart homes can be described as a technology which is used within the home
environment to provide comfort, security, convenience, and energy efficiency to its user or oc-
cupants. Home automation is a concept which involves real time control and monitoring of
multiple domestic appliances.

Power monitoring and control through home networks is becoming important for electric
home appliances. Together with the construction of access networks, several standards for
wired home networks have been proposed and developed. Power line communication (PLC) is
used to utilize a domestic power line as a communication medium. Home network devices are
categorized as wired devices. The PLC provides high bit-rate data services by using the power
grid in the vast infrastructure already in place for power distribution, which means that the
potential effect of the service could be much higher than that of any other wire line alternative.
Because PLC is a home network medium without any new additional wiring, it is easily installed
in an existing residence.

IoT is an environment of inter - connected physical objects that have been assigned an IP
and have the ability to connect to a network without manual intervention of humans. It is
able to transfer data over a network without requiring human-to-human or human-to-computer
interaction. An IoT system consists of a set of hardware devices like microprocessors, sensors
etc. which are responsible for communicating data to/from server and microcontroller. Time is
a very much valuable thing. Everybody wants to save time as much as they can. To contribute

2
for the same this paper proposes Home Automation system using IoT. With the help of the
proposed system the user can control all of its home appliances from his/her mobile/computer
remotely from any place.

1.1 Objectives

• To control the switching of electrical equipments

• To sense the power and current drawn by electrical equipments

• To design the PLC Module

1.2 Literature Review

1.2.1 Power Monitoring and Control for Electric Home Appliances Based

on Power Line Communication

An embedded system without any new additional wiring has been developed for home
power management. By using Power Line Communication (PLC) technology, electric home
appliances can be controlled and monitored through domestic power lines. This describe a PP-
COM (PLC Power-Controlled Outlet Module) which integrates the multiple AC power sockets,
the power measuring module, the PLC module and a microcontroller into a power outlet to
switch the power of the sockets on/off and to measure the power consumption of plugged-in
electric home appliances. And also designed an embedded home server which supports the
Web page user interface, thus allowing the user to easily control and monitor the electric home
appliances by means of the Internet.

Any electric home appliance plugged into the socket of a PPCOM can be controlled and
monitored without any additional setting. The PLC and the asymmetric Digital Subscriber Line
(ADSL) which has been selected for a wide area network have also been selected for the home

3
network. By combining PLC and Ethernet technologies, PPCOM can connect to the embedded
home server without any new additional wire lines [3] .

1.2.2 Power Line Communication Based Automation System Using a Hand-

held Wi-Fi Device

An open source automation system for controlling electrical appliances using power line
communication is presented here. Control messages are sent over Wi-Fi network from a Wi-Fi
device to the micro-controller which then couples the messages to the power lines. Ubiqui-
tous power lines are used as physical media to transmit data over 220V/50Hz signal to control
appliances/equipment.

The data from the microcontroller is coupled onto the power lines using a PLC (Power Line
Communication) modem and DCSK (Differential Code Shift Keying) modulation technique is
employed to transmit data. Each receiver unit consists of PLC modem plus microcontroller
and can be connected anywhere in the power line network. The receivers have addresses as-
signed to them and only respond to the commands sent to them by the transmitter PLC modem.
The receiver unit controls the flow of electricity to the socket. The entire system is devoid of
a computer to save power and make it low cost. Use of open source hardware, Power Line
Communication and micro-controller collectively reduce the cost of controlling appliances re-
motely [5] .

1.2.3 Power Line Carrier Communication Based Low Cost Power Moni-

toring and Management System

Smart meter is an advanced energy meter which not only measures the electrical energy
consumption, but also provides real time data on power consumed by electrical loads. Any
smart meter needs an infrastructure, wired/wireless, for data communication with the central
server. To enable this two way communication link, we propose a narrow band Power Line
Communication(PLC) system operating at a rate of few kbps and this can be deployed over
existing outdoor/indoor power lines. This design demonstrates reusing the existing wired elec-

4
trical network to provide communication between the smart meter and a central server.

A low-cost dedicated hardware for measuring the power usage of electrical appliance is de-
signed. Further, a user interface is developed to remotely access the power usage measurements
stored at the central hub database with features of power management. With the usage data
at hand, smart decisions can be made in saving energy and, reducing carbon foot-prints. This
design uses low cost and off the shelf devices and no additional wiring as it communicates over
the existing power line infrastructure [1] .

1.2.4 Mobile based Home Automation using Internet of Things

Availability of high speed mobile networks like 3G and Long Term Evolution (LTE) coupled
with cheaper and accessible smart phones, mobile industry has seen a tremendous growth in
terms of providing various services and applications at the finger tips of the citizens. Internet of
Things(IoT) is one of the promising technologies which can be used for connecting, controlling
and managing intelligent objects which are connected to Internet through an IP address.

Applications ranging from smart governance, smart education, smart agriculture, smart
health care, smart homes etc can use IoT tor effective delivery of services with out manual
intervention in a more effective manner. This paper discusses about loT and how it can be
used for realizing smart home automation using a micro-controller based Arduino board and
Android mobile app. In this paper, two prototypes namely home automation using Bluetooth
in an indoor environment and home automation using Ethernet in an outdoor environment are
presented [4] .

1.2.5 Smart Energy Efficient Home Automation System Using IoT

Advancement in IoT based application has become the state-of-the art technology among
the researcher due to the availability of Internet everywhere. To make the application more user
friendly, web based and android based technologies have gained their importance in this cutting
edge technology. In this paper, smart energy efficient home automation system is proposed that
can access and control the home equipments from every corner of the world.

5
For this system, Internet connectivity module is attached to the main supply unit of the
home system which can be accessed through the Internet. For wireless connectivity, the static
IP address is used. Home automation is based on multi model application that can be operated
using voice recognition command of the user using the Google Assistant or through a web based
application. Thus, main objective of this work is to make our home automation system more
secure and intelligent [8] .

1.2.6 A step towards Home Automation using IoT

The aim of this paper is to develop home automation system based on IoT using Wi-Fi based
microcontroller. As scope of technology is widening every day, we are making our tech advance
in mobile, robotics, Machine Learning, then why an exception for our home. Today’s houses
are gradually transferring from ordinary/human’s input-based appliances to smart/IoT enabled
appliances to be controlled remotely.

At Present, existing home automation systems use technology that is limited to only that
device. So, in a nutshell, we are making our devices IOT enabled not our homes. As far as this
paper is concerned, NodeMCU (ESP8266) microcontroller along with Relays is used to control
electrical switches remotely from the server which is built on NodeMCU. User can control
switches using a Web Application after authenticating [6] .

1.2.7 Controlling home light using WiFi Node MCU, and Relay module

using IoT

The Internet of Things refers to anything and everything in day to day life which is ac-
cessed or connected through the internet.IoT is an advanced automation and analytics system
which deals with artificial intelligence, sensor, networking, electronic, cloud messaging etc. to
deliver complete systems for the product or services. The system created by IoT has greater
transparency, control, and performance.

In this paper describes about the home light controlling system using the Wi-Fi network or
Internet (Mobile data) . Using this we are able to control our home light from anywhere in the

6
world. The Wi-Fi Node MCU, 4 Channel Relay module, etc are used for purpose [7] .

1.2.8 The power line home automation for voice communication and data

transmission using an existing power line

This paper states about the voice communication and data transmission at a time on a single
existing power line that reduces the complexity of so much wires used in communication system
and it is applicable in a large automated area with low cost and easy installation process.

The message (voice, tone or digital data) is modulated with a high frequency carrier by
frequency modulation (FM) or frequency shift keying (FSK) process and after amplification it
passes to the power line through the bidirectional coupler. At the receiver section the signal
(FM or FSK) is recovered by coupler and then demodulated.

The demodulated signal is then passed through the low pass filter to recover the voice or tone
signal and a comparator is used to recover data signal. Here the authors use different carrier
frequencies for different users and also use corresponding filter and comparator. A trap circuit
is used here to localize the communication area which obstructs the transmitted signal to pass
out of that area and hence losses are reduced [2] .

1.2.9 Design of Power Line Communication System

This paper describes the design of a system that transmit digital data from the sender to the
receiver using power lines as communication channel. The transmission system has to convert
the information data in a suitable form before it is injected in the communication channel.
There are several multiplex and modulation schemes which are investigated to be applied in the
PLC transmission systems. The frequency of the carrier signal should be much higher than the
frequency of the 220 V signal (50Hz) to avoid the interference between these two signals.

PLC circuit must be insulated from power line, which is very important for human health
and for the operation of the circuit. For this purpose, a coupling circuit must be designed to
inject the modulated signal into the power line and block the AC mains signal preventing it

7
from reaching the input of modem communication system.

On the other side, the modulated signal must be extracted from the power line using the
coupling circuit. The receiver must recover the digital data from the modulated signal through
applying one of the demodulation techniques. Transceiver system must include filters to avoid
the noise and attenuation caused by using power lines as communication channel [9] .

1.2.10 FM generation and detection using CD4046 PLL IC

Communication is the transfer of information from one place to another. Radio communi-
cation uses electrical energy to transmit information. The transmitted information is the intel-
ligence signal or message signal. Message signals are in the Audio Frequency (AF) range of
low frequencies from about 20 Hz to 20 kHz. The Radio Frequency (RF) is the carrier signal.
Carrier signals have high frequencies that range from 10 kHz up to about 1000 GHz. A radio
transmitter sends the low frequency message signal at the higher carrier signal frequency by
combining the message signal with the carrier signal.

Modulation is the process of changing a characteristic of the carrier signal with the message
signal. In the transmitter, the message signal modulates the carrier signal. The modulated carrier
signal is sent to the receiver where demodulation of the carrier occurs to recover the message
signal. This paper aims to implement FM modulation and demodulation circuits using PLL IC
CD4046.

1.3 Outline of the Project

In the project all sections of system have been simulated seperately and obtained the results
using Arduino and Proteus Professional 8.8 SP1. The hardware of Controlling of equipments
using IoT is made and obtained results.

The brief description and literature review of the project is given is Chapter 1. Chapter 2,
describes study about Power Line Communication, Internet of Things, NodeMCU, Microcon-
troller, PLC Module, FM Modulation, FM Demodulation, Coupling Circuit, Line Trap Circuit,

8
Relay and Sensor. The study about Block diagram of the project is provided in Chapter 3.
Chapter 4 provides the system design of the project. The simulation studies of circuits that are
used in the project is given in Chapter 5. Chapter 6 provides the hardware setup of the project.
And at last the conclusions and future work of the project is given in Chapter 6.

9
Chapter 2

Background and Methodology

This chapter gives an introduction to the technologies used and components required for
automation and control of electrical equipments .

2.1 Power Line Communication

Power line communication (PLC) is one of the technologies that have proved useful for
control applications and it is a system where communication signals can be sent and received
on household or industrial current carrying power line. This concept involves transmitting in-
formation using the electrical power distribution network as the communication channel. The
principle of PLC consists of transmitting a high frequency signal at low energy levels over the
50 Hz electrical signal by superimposing a modulated carrier signal on line voltage. This data
signal is transmitted via the power line and can be received and decoded at another location in
the same electrical network.

Home energy management systems (HEMS) are expected to reduce power consumption
in houses, thereby addressing the issue of global warming. It determines the health of the
elderly by monitoring the usage time zones of consumer electronics. Monitoring the power
consumption of each electrical appliance in a house is a key technology for PLC.

In this project the current or power consumed can be detected using PLC and also sense
whether equipment is turn ON or OFF.

10
2.2 Internet of Things

Internet of Things (IoT) deals with billions of intelligent objects which would be connected
to sense collect the data and also communicate with surrounding people using mobile, wireless
and sensor technologies.

Main objective of IoT is to manage and control physical objects around us in a more intelli-
gent and meaningful manner and also improve quality of life by providing cost effective living
including safety, security and entertainment. Smart objects gather useful contextual data au-
tonomously and send to remote application servers for offering context aware or location based
services.

IoT application is a unique mobile based home automation solution that can facilitate people
to remotely control home appliances using their personal android smart phones anywhere and
anytime.

In this project the turn ON or OFF control of equipment is done using IoT .

2.3 NodeMCU

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 prototyping hardware typically used is a circuit board functioning as a dual in-line pack-
age (DIP) which integrates a USB controller with a smaller surface-mounted board containing
the MCU and antenna. The choice of the DIP format allows for easy prototyping on bread-
boards. The design was initially based on the ESP-12 module of the ESP8266, which is a Wi-Fi
SoC integrated with a Tensilica Xtensa LX106 core, widely used in IoT applications

11
Figure 2.1: NodeMCU

2.4 Microcontroller

The ATmega328 is a single-chip microcontroller created by Atmel in the megaAVR family


(later Microchip Technology acquired Atmel in 2016). It has a modified Harvard architecture
8-bit RISC processor core.

This microcontroller combines 32KB ISP flash memory with read-while-write capabilities,
1KB EEPROM, 2KB SRAM, 23 general purpose I/O lines, 32 general purpose working reg-
isters, three flexible timer/counters with compare modes, internal and external interrupts,serial
programmable USART, a byte-oriented 2-wire serial interface, SPI serial port, 6-channel 10-bit

12
Figure 2.2: ATmega328

A/D converter (8-channels in TQFP and QFN/MLF packages), programmable watchdog timer
with internal oscillator, and five software selectable power saving modes. The device operates
between 1.8-5.5 volts.

By executing powerful instructions in a single clock cycle, the device achieves through
inputs approaching 1 MIPS per MHz, balancing power consumption and processing speed.

2.5 PLC Module

Power line Modem is a communication module (Also called as PLC Module) which sends
data on the 230 Volt mains power lines. Power line communication module basically uses the
existing power lines to transfer both AC power as well as data simultaneously. This form of
communication is also known as power-line carrier, power-line digital subscriber line (PDSL),
mains communication, power-line telecommunications, or power-line networking (PLN).

13
2.6 FM Modulation

In frequency modulation (FM), we utilize the amplitude of audio signal to modulate the
frequency of carrier signal. The transmitted high and low frequency signals will follow the
received audio signal, which has different frequency that keeps on changing.

The VCO part of the PLL may be used for the frequency modulation of the carrier. In
a VCO, the output frequency is proportional to the control volatge input. In the absance of
control voltage, the free running frequency is determined by the supply voltage VCC , the exter-
nally connected resistances R1 and R2 and the capacitance C. The control input of the VCO is
VCC VCC
clamped at a voltage 2
. The modulating signal voltage which is less than 2
is applied at
this pin through a capacitor. This results in variation in the frequency of oscillation of the VCO,
which is the frequency modulated signal.

2.7 FM Demodulation

Frequency demodulator is also called frequency discriminator, which can convert the varia-
tion of frequency to the variation of linear voltage.

PLL IC has to be used for FM demodulation. The VCO part of this IC is configured for the
same free running frequency as that of the modulator IC. One of the phase detector input is fed
with the modulated FM signal and the other input of the phase detector is fed with the VCO
output after filtering out high frequency components.

The phase variation between the two will be corresponding to the message which was used
for modulation. The PD output is passed through an emitter follower internally to the demod-
ulated output pin. The output from this pin may contain high frequency ripples which may be
eliminated by proper filtering to obtain the actual message.

14
2.8 Coupling Circuit

The biggest technical challenge in a power line carrier is to couple the low voltage and high
frequency carrier set to the high voltage and low frequency power line. The carrier signal is
injected on the power line through the coupling network.

There are two methods of connecting the power line communication module into the net-
work:

• Capacitive Coupling: A capacitor is responsible for the actual coupling and the signal is
modulated onto the network’s voltage waveform

• Inductive Coupling: An inductor is used to couple the signal onto the network’s current
waveform. Inductive coupling some time is rather noisy, however, the advantage is, no
physical connection to the network has to be made. Thus make it safer to install as
compare to capacitive coupling

2.9 Line Trap Circuit

The line trap circuit is used for allowing the transmitted signal to receive over a limited area
such as a building, institution, market or a town. There may thousands of devices connected
over the power line at a time. So there may have a great signal loss of our transmitted signal.
To reduce this loss it is needed the line trap circuit.

The line trap circuit has been used in series with the power line which actually consists of
a parallel inductor and capacitor. For the 50 Hz ac signal of power line it gives a very lower
impedance but for our 150 KHz carrier signal it gives high impedance. So there is no restriction
for 50 Hz ac signal of the power line but due to high impedance for carrier signal the line trap
circuit will not allow to pass the transmitted signal out of the area bounded by the line trap
circuit. The impedances can be easily calculated from the following equations

XL = 2πf L

15
1
XC = 2πf C
XL XC
Z= XL +XC

2.10 Relay

Figure 2.3: Relay Module

A relay is an electrically operated switch. It consists of a set of input terminals for a single
or multiple control signals, and a set of operating contact terminals. The switch may have
any number of contacts in multiple contact forms, such as make contacts, break contacts, or
combinations thereof.

16
Relays are used where it is necessary to control a circuit by an independent low-power
signal, or where several circuits must be controlled by one signal. Relays were first used in
long-distance telegraph circuits as signal repeaters: they refresh the signal coming in from
one circuit by transmitting it on another circuit. Relays were used extensively in telephone
exchanges and early computers to perform logical operations.

2.11 Sensor

A sensor is a device, module, machine, or subsystem whose purpose is to detect events or


changes in its environment and send the information to other electronics, frequently a computer
processor. A sensor is always used with other electronics. A sensor’s sensitivity indicates
how much the sensor’s output changes when the input quantity being measured changes. Most
sensors have a linear transfer function. The sensitivity is then defined as the ratio between the
output signal and measured property.

2.11.1 Current Sensor

A current sensor is a device that detects electric current in a wire and generates a signal
proportional to that current. The generated signal could be analog voltage or current or even
a digital output. The generated signal can be then used to display the measured current in an
ammeter, or can be stored for further analysis in a data acquisition system, or can be used for
the purpose of control.

17
Figure 2.4: Current Sensor

2.11.2 Temperature Sensor

Temperature sensors measure the amount of heat energy or even coldness that is generated
by an object or system, allowing us to sense or detect any physical change to that tempera-
ture producing either an analogue or digital output. The temperature sensor vary from simple
ON/OFF thermostatic devices which control a domestic hot water heating system to highly
sensitive semiconductor types that can control complex process control furnace plants.

18
Figure 2.5: Temperature Sensor

2.11.3 Power Sensor

The power sensor converts high-frequency power to a DC or low-frequency signal that the
power meter can measure and relate to an RF power level. The meter displays the detected
signal as a power value in dBm or watts. The three main types of sensors are thermistors,
thermocouples, and diode detectors.

19
Figure 2.6: Power Sensor

2.12 Summary

The different components required in the project are discussed in this chapter. The de-
scription about Power Line Communication, Internet of Things, technologies that are used for
controlling and monitoring of equipments is given in this chapter. And then discussed about
components NodeMCU, Microcontroller, PLC Module, FM Modulation, FM Demodulation,
Coupling Circuit, Line Trap Circuit, Relay and Sensor. The next chapter deals with the Block
Diagram of System.

20
Chapter 3

Model Configuration

This chapter gives the Block Diagram of proposed work

3.1 Block Diagram

Figure 3.1: Block Diagram

This is the block diagram of the project. This is a bidirectional way of communication. The

21
first one is to control ON/OFF of an electrical equipment. A command is given to the android
phone and this transmits the signal to the Master Microcontroller which is placed near the main
MCB and is connected to the WiFi or Internet. This signal is recieved by the power line module
which consists of modulator, demodulator and coupling circuit and is given to the next power
line module. Slave microcontroller placed at each room process the recieved data and trigger
the corresponding relay to ON/OFF the equipments.

The second is to sense the temperature, current or power and to display the corresponding
quantities in the android phone, the reverse flow occurs. The sensor will sense the data, micro-
controller process the data and is given to the power line module. The master microcontroller
will provide control to display the sensed data in phone.

3.2 Summary

This chapter gives information on Block Diagram of System. The next chapter provides the
design of components used in the project.

22
Chapter 4

System Design

This chapter discuss about the block diagram and design of PLC Module.

4.1 Functional Block Diagram of PLC

Figure 4.1: Functional Block Diagram of PLC

The block diagram describes about the transmitting and recieving of a signal through a
power line. The total system runs at three parts named transmitter part, power line carrying part
and the receiving part. At transmitter part, the signal is modulated with carrier and then it is

23
transmitted through power line. At receiver, the modulated signal is received from power line
with the help of coupler and then message signal is separated from carrier by demodulation and
finally the message signal is recovered through filtering. In a PLC user module both transmitter
and receiver circuit exists for bidirectional communication. Power line isolator which works for
bidirectional coupling.

4.2 FM Modulation and Demodulation using PLL

4.2.1 Circuit Diagram

Figure 4.2: Circuit for FM generation and detection using CD4046 PLL IC

CD4046 IC is used to perform modulation. It contains a VCO (voltage control oscillator)


which gives oscillating frequency according to voltage given at pin-9. At pin-4 free running
oscillation occurs if any voltage is not provided at pin-9. The free running frequency or carrier
frequency is determined by the supply voltage VCC , the externally connected resistances R1 and
R2 and the capacitance C. The free running frequency f0 is given by

V
0.16 CC 1
f0 = R1 C
2
+ R2 C

The VCO in free running mode is the carrier generator. If voltage is provided(message
signal) at pin-9 then CD4046 gives modulated output in the manner that free running frequency

24
will be high if signal voltage is positive and low if message signal is negative. A voltage divider
Vcc
network of two resistors with R for clamping the control voltage input (pin-9) at 2
. The FM
output is obtained from V COout (pin-4) of first PLL IC.

For demodulation, another PLL IC has to be used for FM demodulation. The VCO part of
this IC is configured for the same free running frequency as that of the modulator IC. The FM
modulated signal should be given at pin-14 and the demodulated signal will be found at pin-10.
The pin-5 8 should be grounded. A capacitor should be inserted between pin-6 7. Here, pin-3
is a phase comparator input and pin-4 is VCO output. The pin-3 4 must be shorted and the
VCO output can be found here.

If the FM modulated frequency is greater than VCO output, then the PLL gives a higher
voltage according to the frequency variation and if the FM modulated frequency is less than
VCO output, then the PLL(Phase-Locked Loop) gives a voltage according to the frequency
variation. This demodulated output contains high frequency components. So a low pass filter is
needed to recover the original message signal.

4.2.2 Design of FM Modulation

• Supply VCC = 5V at pin-16 and ground pin-8 of both PLL ICs

• R = 10kΩ

Vcc
• 2
= 2.5V

• A message signal of frequency 1kHz and amplitude 1 Vpp is given at control voltage input
(pin-9) through a capacitor of C1 = 1µF

• R1 = 10kΩ (pin-11)

• R2 = 100kΩ (pin-12)

• C = 0.002µF (between pin-6 and pin-7)

(0.16)(2.5V ) 1
• f0 = (10kΩ)(0.002µF )
+ (100kΩ)(0.002µF )
= 25kHz

25
4.2.3 Design of FM Demodulation

• The same R1, R2 and C is used for the second PLL IC so that the free running frequency
remains the same as that of the modulating IC

• R2 = 10kΩ

• C = 0.01µF

• Demodulated output is obtained from the pin-10 by pulling down using a resistor RP =
10kΩ

• Output is low pass filtered at fc = 1.5kHz to eliminate higher order ripples

• Rf = 10kΩ

• Cf = 0.01µF

1
• fc = Rf Cf
= 1.5kHz

4.3 Coupling Circuit

Figure 4.3: Coupling Circuit

Coupling circuit is the most important part of PLC that should be designed very carefully.
As the modulated signal is transmitted over power line and a 220V ac (50 Hz) already existing

26
there so it is needed to isolate the 220V ac (50 Hz) from our transmitter and receiver circuit for
protection. To isolate the 220V ac (50 Hz) signal it is needed to apply a high pass filter to allow
the high frequency modulated signal to pass through while blocking the low frequency signal.

Here a high voltage low valued capacitor (C1 = 1nF ) is used in series with a coupling
transformer between the power line and the transmitter or receiver. This will block any signal
of a frequency lower than the cut off frequency and allow passing any signal having a frequency
greater than the cut off frequency.

4.4 Line Trap Circuit

Figure 4.4: Line Trap Circuit

The line trap circuit has been used in series with the power line which actually consists of a
parallel inductor and capacitor.

• L = 1mH

• C = 1nF

27
4.5 Summary

This chapter gives design of FM Modulation and Demodulation Circuit, Coupling Circuit
and Line Trap Circuit. The next chapter provides the simulation studies of the circuits that are
used in the project using Arduino and Proteus Professional 8.8 SP1.

28
Chapter 5

Simulation Studies

This chapter describes the simulation studies of the project in Arduino and Proteus Pro-
fessional 8.8 SP1. The simulation for Control of Switch and Temperature Sensor is done in
Arduino. FM Modulation, FM Demodulation and PLC Module simulation is done in Proteus
Professional 8.8 SP1. The simulation studies are conducted to verify the design values before
starting the hardware setup.

5.1 Control of Switch

An arduino is used to the relay for a simple lamp circuit. It is loaded with BLINK program.
A display is provided to indicate the status of the circuit. In pin-13 of arduino, ON or OFF
signal is obtained with a delay of 1sec. This signal is given to the input of relay.

29
Figure 5.1: Light ON Condition

Figure 5.2: Light OFF Condition

30
5.2 Sensor

This is the simulation for sensor part of the circuit. A temperature sensor LM35 is used in
the circuit and a virtual terminal is placed to view the sensed data or temperature. The sensed
data is obtained in every 1 sec. This circuit is implemented to control AC or Fan to turn ON or
OFF if the temperature exceeds a preset value.

Figure 5.3: Temperature Sensor Circuit Diagram

Figure 5.4: Temperature Sensor Output

31
5.3 FM Modulation

The circuit and waveform of FM Modulation is given in Fig. 5.5 and Fig. 5.7 respectively.
The free running frequency or carrier wave obtained when message is not given to IC is given
in Fig. 5.6

Figure 5.5: FM Modulation Circuit Diagram

Figure 5.6: Carrier Wave

32
Figure 5.7: FM Modulation Waveform

5.4 FM Demodulation

The circuit and waveform of FM Demodulation is given in Fig. 5.8 and Fig. 5.9 respectively.

33
Figure 5.8: FM Demodulation Circuit Diagram

Figure 5.9: FM Demodulation Waveform

34
5.5 PLC Module

The circuit and waveform of PLC Module is given in Fig. 5.10 and Fig. 5.11 respectively.

Figure 5.10: PLC Module Circuit Diagram

35
Figure 5.11: PLC Module Waveform

36
Chapter 6

Experimental Setup

This chapter describes about the Experimental setup of controlling the electrical equipments
using IoT. The hard ware setup to control our home light from anywhere in the world using Iot
is made.

6.1 Hardware Requirements

• Wi-Fi Node MCU ESP8266

• Standard USB cable to connect Node MCU

• 4 Channel Relay module (5V)

• Jumper wires

• Home Light (Bulb)

• Bulb holder

• Wire

• AC 220V/120V home appliances

37
6.2 Software requirements

• Arduino software

• MIT App Inventor

6.3 Working principle

Figure 6.1: Working principle

In this project, there are three main components used an MIT App, Wi-Fi Node MCU and 4
Channel Relay module. The Android MIT app sends the serial data to the Wi-Fi Node MCU by
clicking ON button. The Wi-Fi Node read the input data and process it according to program
uploaded inside it and generate the output to 4 Chanel Relay Module. When the MIT app’s
button turns on, it turns ON the home light, and when the MIT app’s buttons turns OFF, it turns
OFF the home light.This circuit is operated using Wi-Fi.

6.4 Circuit Diagram

The digital pins in the Node MCU are connected to the relay module and each signal is used
to control the corresponding relay. The relay module has 2 sides, high voltage side and low
voltage side. The message signal is given to the low voltage side and different components are
connected to the high voltage side.

Generally, relay module has 2 operating modes,

38
Figure 6.2: Circuit Diagram

• Normally open mode

• Normally closed mode

So, here the relays are connected in normally open mode which makes the circuit in open
circuit condition. If the relay gets a signal, it operates in normally closed mode which makes
the circuit closed.

Table 6.1: Connection between Relay module and Node MCU

4 Channel Relay Module Node MCU

GND GND
IN1 D0
IN2 D1
IN3 D2
IN4 D3
Vcc Vin

39
6.5 Hardware Setup

Figure 6.3: Hardware Setup

This is the hardware setup for controlling relay module with IoT. A setup for controlling
60W light using MIT application which is controlled using internet is made.

40
6.6 MIT Application

Figure 6.4: Mobile Application Layout

This is layout of MIT application made using MIT app inventor. MIT app inventor is an
IDE in application are made using drag and drop method.

41
Chapter 7

Conclusions

The power line carrier communication system uses the existing AC electrical wiring as the
network medium to provide high speed network access points almost anywhere there is an AC
outlet. This system uses IoT which allow mobile devices and computers to remotely control
all the functions and features of home appliances from anywhere around the world using the
internet connection. So, the proposed model is more economical.

In this project work, the system that transmit digital data from the sender to reciever using
PLC module is designed and simulated. The hardware setup and simulation for controlling
equipments using IoT is done.

7.1 Future Work

The future work includes the implementation of hardware setup of controlling and commu-
nication using PLC and integrating with IoT. This setup in a home, shopping complexes, and
malls can be monitored and controlled without any additional laying of wires.

42
Bibliography

[1] Vidyalaxmi Dani, Rebanta Kumar Chowdhury, and Sreenath Vasan. Power line carrier
communication based low cost power monitoring and management system. IEEE Journal,
24(7):1351–1363, July 2016.

[2] Abdus Samad Imamul Arefeen and Asadujjaman Nur. The power line home automation
type communication system for voice communication and data transmission using an exist-
ing power line. In 9th International Forum on Strategic Technology (IFOST), pages 73–77,
Cox’s Bazar, Bangladesh. IEEE.

[3] Chia-Hung Lien, , Ying-Wen Bai, and Ming-Bo Lin. Power monitoring and control for
electric home appliances based on power line communication. IEEE International Instru-
mentation and Measurement Technology Conference, pages 112–120, May 2008.

[4] Kumar Mandula, Ramu Parupalli, CH.A.S.Murty, and E.Magesh. Mobile based horne au-
tomation using internet of things(iot). International Conference on Control lnstrumentation,
Communication and Computational Technologies, 5:1–15, JAug 2015.

[5] Karthik Shivaram, Nikhil Rajendra, and Kavi Mahesh. Power line communication based
automation system using a handheld wi-fi device. IEEE 16th International Symposium,
19(4):1–6, July 2012.

[6] Harsh Kumar Singh, Saurabh Verma, Shashank Pal, and Kavita Pandey. A step towards
home automation using iot. IEEE Trans., pages 556–561, Mar 2019.

[7] Allam Vamseekrishna, Boddapati Taraka Phani Madhav, and Tirunagari Anilkumar. Con-
trolling home light using wifi node mcu, and relay module using iot. IEEE Sensors Letters,
3(10):1–7, October 2019.

43
[8] Satyendra K. Vishwakarma and Prashant Upadhyaya. Smart energy efficient home automa-
tion system using iot. IEEE Trans., pages 1–10, Feb 2019.

[9] Sun Wenyou and Hu Yonghong. Design of power line communication system. In 2009
WASE International Conference on Information Engineering), pages 95–124, Taiyuan,
Chanxi, China, 10. IEEE.

44
APPENDIX A

PLC1762 Power Line Modem

PLC1762 Power Line modem can directly be interfaced to any of 8051, PIC, AVR or ARM
microcontrollers. It can also be directly interfaced to Arduino and Raspberry pi. This is an easy
to use plug and play power line communication module. No need for settings of any type just
connects it to the mains, power it up and you are ready to go.

The communication is quite simple and any serial data at 9600 bps can be easily transmitted
via power line. The interfacing is also quite simple just connect your controllers Tx line to
Modules Rx line and the controllers Rx line to the Modules Tx line and you are ready to go. No
need of any settings or anything just a simple plug and play module.

Normally the data transfer rate over power line is 100 bytes/Second (bps) i.e. though it takes
data at 9600 bps from controller it can send data over the power line only at 100 bps. So when
you are transmitting data serially please make sure the there is a delay of 5 ms after each byte.

This Power Line Communication modem used FSK modulation technique with a center
frequency of 72 kHz. The module has onboard 5volt voltage regulator so you can provide
external supply of 12-24 Volt DC.

Specifications Features

• Power Supply : DC 12-24 Volt (12 Volt recommended)

• Max current : 200mA

• Default Baudrate of 9600

45
Figure 7.1: PLC1762 Power Line Modem

• Communication in half duplex mode

• Working environment : 230V 50/60Hz

• Communication distance : 150m

• Power line carrier frequency : 72kHz

• Modulation and demodulation mode : FSK

• Relimate connector provided for easy interfacing with your circuit

46
APPENDIX B

ATmega 328

Figure 7.2: Pin diagram of an ATmega 328

Specifications Features

Advanced RISC Architecture

• 131 Powerful Instructions – Most Single Clock Cycle Execution

47
• 32 x 8 General Purpose Working Registers

• Fully Static Operation

• Up to 20 MIPS Throughput at 20 MHz

• On-chip 2-cycle Multiplier

High Endurance Non-volatile Memory Segments

• 4/8/16/32K Bytes of In-System Self-Programmable Flash program memory (ATmega


48P/ 88P/ 168P/ 328P)

• 256/512/512/1K Bytes EEPROM (ATmega48P/88P/168P/328P)

• 512/1K/1K/2K Bytes Internal SRAM (ATmega48P/88P/168P/328P)

• Write/Erase Cycles: 10,000 Flash/100,000 EEPROM

• Data retention: 20 years at 85C/100 years at 25C(1)

• Optional Boot Code Section with Independent Lock Bits In-System Programming by On-
chip Boot Program True Read-While-Write Operation

• Programming Lock for Software Security

Peripheral Features

• Two 8-bit Timer/Counters with Separate Prescaler and Compare Mode

• 32 x 8 General Purpose Working Registers– One 16-bit Timer/Counter with Separate


Prescaler, Compare Mode, and Capture Mode

• Real Time Counter with Separate Oscillator

• Six PWM Channels

• 8-channel 10-bit ADC in TQFP and QFN/MLF package

• 6-channel 10-bit ADC in PDIP Package

48
• Programmable Serial USART

• Master/Slave SPI Serial Interface

• Byte-oriented 2-wire Serial Interface (Philips I2 C compatible)

• Programmable Watchdog Timer with Separate On-chip Oscillator

• On-chip Analog Comparator

• Interrupt and Wake-up on Pin Change

Special Microcontroller Features

• Power-on Reset and Programmable Brown-out Detection

• Internal Calibrated Oscillator

• External and Internal Interrupt Sources

• Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Standby, and
Extended Standby

I/O and Packages

• 23 Programmable I/O Lines

• 28-pin PDIP, 32-lead TQFP, 28-pad QFN/MLF and 32-pad QFN/MLF

Operating Voltage:

• 1.8 - 5.5V for ATmega48P/88P/168PV

• 2.7 - 5.5V for ATmega48P/88P/168P

• 1.8 - 5.5V for ATmega328P

49
APPENDIX C

NodeMCU ESP8266

Figure 7.3: Pin diagram of a NodeMCU ESP8266

Specifications Features

• Microcontroller: Tensilica 32-bit RISC CPU Xtensa LX106

50
• Operating Voltage: 3.3V

• Input Voltage: 7-12V

• Digital I/O Pins (DIO): 16s

• Analog Input Pins (ADC): 1

• UARTs: 1

• SPIs: 1

• AC 220V/120V home appliances

• I2Cs: 1

• Flash Memory: 4 MB

• SRAM: 64 KB

• Clock Speed: 80 MHz

• PCB Antenna

• USB-TTL based on CP2102 is included onboard, Enabling Plug n Play

51
APPENDIX D

CD 4046 - PLL IC

A phase-locked loop or phase lock loop (PLL) is a control system that generates an output
signal from an oscillator which is synchronized in phase and frequency with its input signal. It
is an electronic circuit consisting of a voltage controlled variable frequency oscillator(VCO), a
phase detector and a low pass filter. The oscillator generates a periodic signal.

The phase detector compares the phase of that signal with the phase of the input periodic
signal. Proportional to the phase difference a voltage waveform is generated. It is low pass
filtered to obtain a dc voltage which is proportional to the phase difference. This voltage is fed
back to the VCO to control and adjust the oscillator to keep the phases matched.

Figure 7.4: Block diagram of a PLL

52
Figure 7.5: Pin diagram of a PLL

Specifically PLL synchronizes its VCO phase and frequency with the input for a given range
of frequencies. The block diagramatic representation of a PLL is shown in Fig 7.1.

The range of input frequencies(fi = fmin to fi = fmax ) for which the the PLL remains in
this locked condition is called lock range of the PLL. If PLL is initially locked and the input
frequency fi becomes less than fm in or if fi exceeds fm ax, PLL becomes unlocked.

When PLL is unlocked, VCO oscillates at free running frequency or centre frequency, f0 .
The lock can be re-established if fi becomes sufficiently close to f0 . The range of frequencies
around f0 (ie, f0 − fcap to f0 + fcap ) which when applied as input captures a PLL into lock is
called capture range of the PLL.

53
CD4046 is a PLL IC. It has a linear voltage controlled oscillator(VCO) and two phase
comparators(P C1 and P C2 )- Any of which can be used for PLL operation. The periodic signal
generated by the VCO is the output signal which is synchronized with the input signal. The
amplitude of VCO output depends on Vcc and its free running frequency is determined by Vcc as
well as the value of externally connected resistors and capacitors R1 , R2 and C.

54
APPENDIX E

Program for Control of Switch

/ / i n c l u d e t h e l i b r a r y code :
# i n c l u d e < L i q u i d C r y s t a l . h>
// i n i t i a l i z e t h e l i b r a r y by a s s o c i a t i n g any n e e d e d LCD i n t e r f a c e p i n
/ / w i t h t h e a r d u i n o p i n number i t i s c o n n e c t e d t o
c o n s t i n t r s = 9 , en = 8 , d4 = 5 , d5 = 4 , d6 = 3 , d7 = 2 ;
L i q u i d C r y s t a l l c d ( r s , en , d4 , d5 , d6 , d7 ) ;

void setup ( )
{
/ / s e t up t h e LCD’ s number o f c o l u m n s and rows :
lcd . begin (16 , 2 ) ;
/ / P r i n t a m e s s a g e t o t h e LCD .
pinMode ( LED BUILTIN , OUTPUT ) ;
}

void loop ( )
{
d i g i t a l W r i t e ( LED BUILTIN , HIGH ) ; / / t u r n t h e LED on ( HIGH i s t h e
voltage level )
lcd . setCursor (0 , 1);
l c d . p r i n t ( ” L1 i s on ” ) ;

55
delay (1000); / / wait f o r a second
d i g i t a l W r i t e ( LED BUILTIN , LOW) ; / / t u r n t h e LED o f f by making t h e
v o l t a g e LOW
lcd . setCursor (0 , 1);
l c d . p r i n t ( ” L1 i s OFF ” ) ;
delay (1000);
}

56
APPENDIX F

Program for Sensor

int val ;
i n t tempin = 1;
void setup ( )
{
S e r i a l . begin (9600);
}

void loop ( )
{
val = analogRead ( tempin ) ;
f l o a t mv = ( v a l / 1 0 2 4 . 0 ) ∗ 5 0 0 0 ;
f l o a t c e l = mv / 1 0 ;
f l o a t farh = ( cel ∗9)/5+32;
Serial . p r i n t (” temprature =”);
Serial . print ( cel );
S e r i a l . p r i n t (”∗ c ” ) ;
Serial . println ();
delay (1000);
}

57
APPENDIX G

Program for Hardware Setup

\# i n c l u d e <ESP8266WiFi . h>
/ / H e a d e r f i l e f o r u s e t h e w i f i f a c i l i t y o f ESP8266
/ / network s s i d
c h a r s s i d [ ] = ” a j u 1 ” ; / / E n t e r y o u r SSID
/ / network password
char password [ ] = ” 1 2 3 4 5 6 7 8 ” ; / / Enter your w i f i password
i n t k e y I n d e x = 0 ; / / Only f o r WEP c o n n e c t i o n
i n t i = 0;
WiFiServer s e r v e r ( 8 0 ) ;

void setup ( )
{
S e r i a l . begin (115200); // initialize s e r i a l communication
pinMode ( D2 , OUTPUT ) ; / / s e t t h e PinMode
pinMode ( D3 , OUTPUT ) ;
/ / a t t e m p t to connect to Wifi network :
S e r i a l . p r i n t ( ” A t t e m p t i n g t o c o n n e c t t o Network named : ” ) ;
// p r i n t t h e n e t w o r k name ( SSID ) ;
Serial . println ( ssid );
/ / C o n n e c t t o WPA/WPA2 n e t w o r k .
Change t h i s l i n e i f u s i n g open o r WEP n e t w o r k :

58
WiFi . b e g i n ( s s i d , p a s s w o r d ) ;

w h i l e ( WiFi . s t a t u s ( ) ! = WL CONNECTED)
{
// p r i n t d o t s w h i l e we w a i t t o c o n n e c t
Serial . print (”.”);
delay (300);
}

S e r i a l . p r i n t l n ( ” \ nYou ’ r e c o n n e c t e d t o t h e n e t w o r k ” ) ;
S e r i a l . p r i n t l n ( ” W a i t i n g f o r an i p a d d r e s s ” ) ;
w h i l e ( WiFi . l o c a l I P ( ) == INADDR NONE)
{
// p r i n t d o t s w h i l e we w a i t f o r an i p a d d r e s s
Serial . print (”.”);
delay (300);
}
S e r i a l . p r i n t l n (”\ nIP Address o b t a i n e d ” ) ;
/ / you ’ r e c o n n e c t e d now , s o p r i n t o u t t h e s t a t u s
printWifiStatus ();
S e r i a l . p r i n t l n ( ” S t a r t i n g w e b s e r v e r on p o r t 8 0 ” ) ;
server . begin ( ) ;
// s t a r t t h e web s e r v e r on p o r t 80
S e r i a l . p r i n t l n ( ” Webserver s t a r t e d ! ” ) ;
}

void loop ( )
{
WiFiClient c l i e n t = server . a v a i l a b l e ( ) ;
// l i s t e n f o r incoming c l i e n t s

59
if ( client )
// i f get a client ,
{
S e r i a l . p r i n t l n ( ” new c l i e n t ” ) ;
// p r i n t a message out t h e s e r i a l p o r t
char b u f f e r [150] = {0};
/ / make a b u f f e r t o h o l d i n c o m i n g d a t a
while ( c l i e n t . connected ( ) )
/ / loop while the c l i e n t ’ s connected
{
if ( client . available ())
// i f t h e r e ’ s b y t e s t o r e a d from t h e c l i e n t ,
{
char c = c l i e n t . read ( ) ;
/ / read a byte , then
Serial . write ( c );
// print i t out the s e r i a l monitor
i f ( c == ’\ n ’ )
// i f the byte i s a newline c h a r a c t e r
{
// i f t h e c u r r e n t l i n e i s b l a n k , you g o t two n e w l i n e c h a r a c t e r s i n a
row .
/ / t h a t ’ s t h e end o f t h e c l i e n t HTTP r e q u e s t , s o s e n d a r e s p o n s e :

i f ( s t r l e n ( b u f f e r ) == 0 )
{
/ / HTTP h e a d e r s a l w a y s s t a r t w i t h a r e s p o n s e c o d e ( e . g . HTTP / 1 . 1
200 OK)
/ / and a c o n t e n t −t y p e s o t h e c l i e n t knows what ’ s coming , t h e n a
blank l i n e :

60
c l i e n t . p r i n t l n ( ” HTTP / 1 . 1 200 OK ” ) ;
c l i e n t . p r i n t l n ( ” C o n t e n t −t y p e : t e x t / h t m l ” ) ;
client . println ();
/ / t h e c o n t e n t o f t h e HTTP r e s p o n s e f o l l o w s t h e h e a d e r :
/ / Only f o r t h e webview and c o n t r o l Via w e b s e r v e r
c l i e n t . p r i n t l n (” < html ><head>< t i t l e >V o i c e Home A u t o m a t i o n </ t i t l e >
</ head><body a l i g n = c e n t e r s t y l e =\” b a c k g r o u n d −c o l o r : g r e e n \ ” > ” ) ;
c l i e n t . p r i n t l n (” < h1 a l i g n = c e n t e r ><f o n t c o l o r =\” r e d \”>

Welcome t o t h e NodeMCU WiFi Web S e r v e r </ f o n t ></h1 > ” ) ;


c l i e n t . p r i n t ( ” LIGHT ONE <b u t t o n
o n c l i c k =\” l o c a t i o n . h r e f = ’ / r1on ’\” >HIGH</ b u t t o n > ” ) ;
c l i e n t . p r i n t l n ( ” <b u t t o n o n c l i c k =\” l o c a t i o n . h r e f = ’ / r 1 o f f ’\” >
LOW</ b u t t o n ><br > ” ) ;
/ / The HTTP r e s p o n s e e n d s w i t h a n o t h e r b l a n k l i n e :
client . println ();
/ / break out of the while loop :
break ;
}

else
{
// i f you g o t a n e w l i n e , t h e n c l e a r t h e b u f f e r :
memset ( b u f f e r , 0 , 1 5 0 ) ;
i = 0;
}
}

e l s e i f ( c ! = ’\ r ’ )
// i f you g o t a n y t h i n g e l s e b u t a c a r r i a g e r e t u r n c h a r a c t e r ,

61
{
b u f f e r [ i ++] = c ; / / add i t t o t h e end o f t h e c u r r e n t L i n e
}

/ / Check t o s e e i f t h e c l i e n t r e q u e s t was ”GET /H” o r ”GET / L ” :


i f ( e n d s W i t h ( b u f f e r , ”GET / r 1 o n ” ) | |
e n d s W i t h ( b u f f e r , ”GET / t u r n on l i g h t one ” ) | |
e n d s W i t h ( b u f f e r , ”GET / t u r n on l i g h t on ” ) | |
e n d s W i t h ( b u f f e r , ”GET / on l i g h t one ” ) | |
e n d s W i t h ( b u f f e r , ”GET / on l i g h t on ” ) )
{
d i g i t a l W r i t e ( D2 , LOW) ;
}

i f ( e n d s W i t h ( b u f f e r , ”GET / r 1 o f f ” ) | |
e n d s W i t h ( b u f f e r , ”GET / t u r n o f f l i g h t one ” ) | |
e n d s W i t h ( b u f f e r , ”GET / o f f l i g h t one ” ) | |
e n d s W i t h ( b u f f e r , ”GET / o f f l i g h t on ” ) )
{
d i g i t a l W r i t e ( D2 , HIGH ) ;
}
i f ( e n d s W i t h ( b u f f e r , ”GET / r 2 o n ” ) | |
e n d s W i t h ( b u f f e r , ”GET / t u r n on l i g h t t o ” ) )
{
d i g i t a l W r i t e ( D3 , LOW) ;
}
i f ( e n d s W i t h ( b u f f e r , ”GET / r 2 o f f ” ) | |
e n d s W i t h ( b u f f e r , ”GET / t u r n o f f l i g h t t o ” ) )
{
d i g i t a l W r i t e ( D3 , HIGH ) ;

62
}
i f ( e n d s W i t h ( b u f f e r , ”GET / r 3 o n ” ) | |
e n d s W i t h ( b u f f e r , ”GET / t u r n on f a n 1 ” ) )
{
d i g i t a l W r i t e ( D4 , LOW) ;
}
i f ( e n d s W i t h ( b u f f e r , ”GET / r 3 o f f ” ) | |
e n d s W i t h ( b u f f e r , ”GET / t u r n o f f f a n 1 ” ) )
{
d i g i t a l W r i t e ( D4 , HIGH ) ;
}
i f ( e n d s W i t h ( b u f f e r , ”GET / r 4 o n ” ) | |
e n d s W i t h ( b u f f e r , ”GET / t u r n on f a n t o ” ) )
{
d i g i t a l W r i t e ( D5 , LOW) ;
}
i f ( e n d s W i t h ( b u f f e r , ”GET / r 4 o f f ” ) | |
e n d s W i t h ( b u f f e r , ”GET / t u r n o f f f a n 2 ” ) )
{
d i g i t a l W r i t e ( D5 , HIGH ) ;
}
}
}
c l i e n t . stop ( ) ;
Serial . p r i n t l n (” c l i e n t disonnected ” ) ;
}
}

//
/ / a way t o c h e c k i f one a r r a y e n d s w i t h a n o t h e r a r r a y

63
//
boolean endsWith ( char ∗ i n S t r i n g , char ∗ compString )
{
i n t compLength = s t r l e n ( c o m p S t r i n g ) ;
int strLength = strlen ( inString );
/ / compare t h e l a s t ” compLength ” v a l u e s o f t h e i n S t r i n g
int i ;
f o r ( i = 0 ; i < compLength ; i ++)
{
char a = i n S t r i n g [ ( strLength − 1) − i ] ;
c h a r b = c o m p S t r i n g [ ( compLength − 1 ) − i ] ;
i f ( a != b )
{
return false ;
}
}
return true ;
}

void p r i n t W i f i S t a t u s ( )
{
// p r i n t t h e SSID o f t h e n e t w o r k you ’ r e a t t a c h e d t o :
S e r i a l . p r i n t ( ” SSID : ” ) ;
S e r i a l . p r i n t l n ( WiFi . SSID ( ) ) ;
// p r i n t y o u r WiFi I P a d d r e s s :
I P A d d r e s s i p = WiFi . l o c a l I P ( ) ;
S e r i a l . p r i n t ( ” IP Address : ” ) ;
Serial . p r i n t l n ( ip ) ;
// print the received signal strength :
l o n g r s s i = WiFi . RSSI ( ) ;

64
S e r i a l . p r i n t ( ” s i g n a l s t r e n g t h ( RSSI ) : ” ) ;
Serial . print ( rssi );
S e r i a l . p r i n t l n ( ” dBm ” ) ;
// p r i n t where t o go i n a b r o w s e r :
S e r i a l . p r i n t ( ” To s e e t h i s p a g e i n a c t i o n , open a b r o w s e r t o h t t p : / / ” ) ;
Serial . p r i n t l n ( ip ) ;
}

65

You might also like