0% found this document useful (0 votes)
36 views68 pages

Projectbook Final

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)
36 views68 pages

Projectbook Final

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

Heaven's Light is Our Guide

Implementation of IoT Based Protection Relay


A project submitted in partial
fulfillment for the requirements of the
degree of

Bachelor of Science
in
Electrical & Electronic Engineering
by
Md. Touhidul Islam
Roll no: 1601074
&
Md. Hasibul Hassan Shuvo
Roll no: 1601091

to the

Department of Electrical & Electronic Engineering


Rajshahi University of Engineering & Technology
November, 2022
Implementation of IoT Based Protection Relay

A project submitted in partial


fulfillment for the requirements of the
degree of

Bachelor of Science
in
Electrical & Electronic Engineering

by

Md. Touhidul Islam


Roll no: 1601074
&
Md. Hasibul Hassan Shuvo
Roll no: 1601091

to the

Department of Electrical & Electronic Engineering


Rajshahi University of Engineering & Technology
November, 2022
DECLARATION

This is to certify that this project report entitled “Implementation of IoT-based


Protection Relay”. has been submitted by Md. Touhidul Islam, Roll: 1601074 & Md.
Hasibul Hassan Shuvo, Roll: 1601091 under my guidance and supervision as a
requirement for the degree of Bachelor of Science in Electrical & Electronic Engineering
of Rajshahi University of Engineering & Technology, Bangladesh.

Supervisor External Examiner

----------------------------------------- -------------------------------------------

Dr. Md. Rafiqul Islam Sheikh Md. Rashidul Islam

Professor Assistant Professor

Department of Electrical & Department of Electrical &

Electronic Engineering Electronic Engineering

Rajshahi University of Engineering Rajshahi University of Engineering

& Technology & Technology

Rajshahi-6204, Bangladesh Rajshahi-6204, Bangladesh

i
ACKNOWLEDGEMENT

Thanks to Almighty, the most gracious and the most merciful who bequeathed us the ability and
scope for the successful completion of the thesis work.

We would like to express sincere appreciation, implementation, and gratitude to our respective
supervisor, Dr. Md. Rafiqul Islam Sheikh, Professor, Department of Electrical & Electronic
Engineering, Rajshahi University of Engineering & Technology (RUET), for his cordial guidance,
inspiration, valuable assistance, and encouraging instructions in completing this project. He
encouraged us not only to perform the project but also motivated us to enhance our self-abilities.
Without his encouragement and support, we would face many major difficulties to complete this
project.

We would like to wish special thanks and appreciation to the persons who helped us to complete
the project by sharing their research ideas. We would also like to express gratefulness to all
respected teachers, officials of our department

Finally, we are thankful to our loving parents for their everlasting moral support and
encouragement.

Authors,

Md. Touhidul Islam

&

Md. Hasibul Hassan Shuvo

RUET, Rajshai.

ii
Abstract

It is now possible to send and receive data between gadgets without a human being because of the
development of the internet and wireless technology. The Internet of Things, also known as IoT,
is a network of connected computers, mechanical and digital equipment, and items that may
exchange data across a network without the need for human-to-human or human-to-computer
interaction. The ATmega328p MCU chip is utilized in this project's to remotely monitor and
control protective relays has been developed to be linked with smart environments like smart
homes or smart cities for protecting electrical equipment, and it improves electrical safety by
providing the ability to quickly disconnect the power supply in the case of fault situations. Through
the Blynk application interface, the system also offers in-the-moment event monitoring and
notification. Remote monitoring and control are also possible with the system. As a result, the user
can use the system fully from any location in the world with internet access.

iii
Contents

Declaration i

Acknowledgment ii

Abstract iii

Contents iv

List of Figures viii

List of Tables ix

Chapter 1: Introduction

1.1 Introduction 1
1.2 Overview of internet of things (IoT) 2
1.3 Application 3
1.4 The motivation for project 3
1.5 Literature review 4
1.6 Aims and objectives of the project 7
1.7 Project outline 7

iv
Chapter 2: Block Diagram and Description

2.1 Introduction 8

2.2 Block diagram description 8

2.3 Block diagram 9

2.3.1 Power supply 10

2.3.2 Microcontroller 10

2.3.3 Current Sensor 13

2.3.4 Cloud Application Overview 14

2.3.5 Battery and Battery Charger 14

2.3.6 Boost Converter 15

2.3.7 GSM Module 15

2.3.8 Relay 16

2.4 Summary 17

Chapter 3: IoT-based Protection Relay

3.1 Internet of Things 18

3.2 System Architecture 19

3.3 Working Principle 19

3.4 Blynk Protocol 21

v
3.5 Protection Relay 22

3.6 Features of the Proposed System 22

3.7 Summary 23

Chapter 4: Circuit Diagram and PCB design

4.1 Project Model 24

4.2 Working Principle 26

4.3 PCB of the Project 26

4.4 Circuit operation 27

4.4.1 Voltage Measurement Operation 27

4.4.2 Current Measurement Operation 28

4.4.3 Relay Control Operation 29

4.4.4 Data Transfer Operation 29

4.4.5 Real-Time Status Monitoring 30

4.5 Picture of the Project 30

4.6 Cost Estimation 31

4.7 Summary 32

vi
Chapter 5: Result and Discussion

5.1 Introduction 33

5.2 Wiring Diagram 33

5.3 No load observation 34

5.4 Load observation 36

5.4.1 Load observation for two 60W bulb 36

5.4.2 Load observation for two 100W bulb 38

5.4.3 Load observation for 60W and 100W bulb 40

5.5 Summary 42

Chapter 6: Conclusion and Future Work

6.1 Conclusion 43

6.2 Shortcomings of the Project 44

6.3 Future Work 44

Reference 45

Appendix 48

vii
List of Figures

Fig. 1.1 Internet of things 3

Fig 2.1 Block diagram of IoT based protection relay 9

Fig. 2.2 Microcontroller (ATmega328P) 11

Fig. 2.3 Pin diagram of ATMega8 12

Fig. 2.4 Current sensor (ACS712-30A) 13

Fig. 2.5 Lithium-ion battery 15

Fig 2.6 SIM 800L 16

Fig.2.7 Channel relay module (SRD-05VDC-S-C) 17

Fig.3.1 System flow 20

Fig.4.1 Circuit diagram of the project 24

Fig 4.2 PCB top view 25

Fig 4.3 PCB bottom view 25

Fig 4.4 Pin diagram of ACS712 current sensor 27

Fig 4.5 Picture of the project 28

Fig 5.1 Wiring diagram 31

Fig 5.2 No load observation 32

Fig 5.3 Blynk application Data (No Load) 33

Fig 5.4 Load observation (60W) 34

Fig 5.5 Blynk application Data (60W) 35

Fig 5.6 Load observation (100W) 36

viii
Fig 5.7 Blynk application Data (100W) 37

Fig 5.8 Load observation (60W and 100W) 38

Fig 5.9 Blynk application Data (60W and 100W) 39

List of Tables

Table 4.1: cost analysis of the project 29

ix
Chapter 1

Introduction

1.1 Introduction

The world is moving toward embracing wireless technologies, which not only lessens human labor
but also improve system accuracy and dependability. An interconnected system of smart gadgets
that can exchange data is known as the internet of things (IoT).

The Internet of things (IoT) concept enables us to connect normal day-to-day services over the
internet. The devices connected through the IoT concept can be analyzed remotely. The IoT idea
offers the fundamental framework and possibilities for connecting the real world to computer-
based systems. The Internet of Things (IoT) is what's driving the transformation of the current
Internet into a network of linked items with the ability to sense their surroundings and
communicate with physical objects (i.e. actuation and control). In this scenario, the existing
Internet protocols are required to support information transfer, analytics, applications, and
communications. In the beginning, the IoT and wireless sensor networks concepts were used
interchangeably. The same happened with wireless sensor networks and IEEE 802.15.4 layer two
protocol. Now IoT is more embraced thus, it is not restricted to only one device type nor only one
particular layer two technology.

The security and reliability of the electrical energy infrastructure are of vital importance today
more than ever, given the degree to which electric-powered technology has become embedded in
all human activities. Protecting the electrical power supply system against interruptions due to
various faults is thus the main research concern[1]. The circuit breaker is one of the components
involved in power system protection. It is responsible for stopping the system when a defect or
anomaly arises to protect the electrical equipment.[2]. Differential relays are the type of relays that
operate when the difference of the measuring quantities (like voltage or current) exceeds a pre-set
value. A current differential relay is a type of relay that works when the difference in currents

Page | 1
between two sites exceeds a certain value. The current differential-type protection system is
applied widely for the protection of transmission lines as well as for the protection of various
equipment like alternators etc.[3]

To reduce unexpected conditions or accidents and to overcome the issues of human error in terms
of monitoring and controlling the system is proposed. In addition, it can also solve the manual
control and monitor the status of the line. To achieve this sophisticated system, communication
and networking are the major roles to track all kinds of connectivity among the individual devices.
The main objective of our proposed system is to implement and develop a very low-cost Wi-Fi-
based protection relay with an IoT concept. By using the Node-MCU Wi-Fi module, the system
can provide data communication between the line and the individuals, so that the individuals can
monitor the status of the line and control it.

1.2 Overview of the Internet of Things (IoT)

A new technological paradigm known as the Internet of Things (IoT), sometimes known as the
Internet of Everything or the Industrial Internet, is envisioned as a worldwide network of machines
and gadgets that are capable of interacting with one another. The Internet of Things (IoT) is
garnering considerable interest from a variety of businesses and is seen as one of the most
significant areas of future technology. Everything in the Internet of Things (IoT) is set up with an
Internet Protocol (IP) address, allowing for remote monitoring, control, and access thanks to web
technology. The primary benefit of this method is the ability to use Ethernet or Wi-Fi to link
"smart" devices like sensors and other transmitters to a local area network (LAN). But for home
automation, electrical systems like light switches and AC/DC systems were also connected. IP-
based inventory tracking is also done in IoT just as shown in figure 1.1.

Page | 2
Fig 1.1: Internet of Things [14]

1.3 Application

• Smart home.
• Industry.
• Energy conservation.
• Automatic circuit breaker protection.
• Power system protection devices.
• Home automation.
• Smart Grid.

1.4 Motivation of the Project

When designing an electrical power system, the protection of the system is a top priority. We just
need to protect these electrical power system components from the dangerous impact of the fault.
There are many faults in the transmission and distribution line. The most severe fault is open circuit

Page | 3
fault, short circuit fault, symmetrical fault, unsymmetrical fault, over-current, low-voltage, etc.
When a fault occurs, we can see linemen repairing the line. While repairing the electrical lines,
electrical accidents of linemen are increasing day by day. This occurs as a result of poor
communication between the maintenance team and the electrical substation. The lineman manually
monitors control and cut off the line. If the lineman can’t cut off the line properly, a severe accident
will happen. The main drawback of the previous system is the person has to go to the fault area
and then the breaker will cut off the circuit to prevent the accident. Hence the previous method is
time consuming and we can’t monitor remotely. The line status monitoring and control can’t be
done properly if the lineman is not present in the area and if there is no real-time control. If the
lineman can check the line status by using their mobile phone or laptop instead of manual
monitoring and control, it will be a great time-consuming and safe for the line. Since most people
have a smartphone, it will be a boon if they can monitor the line status from anywhere .

So, we need a system by which we can monitor the line status and fault location, and send data to
the service provider in real-time by wireless medium and the line, appliances can also be controlled
remotely, especially by mobile applications as the technology advances.

The proposed system will monitor and control electrical equipment from any kind of severe fault.
When any fault occurs relay will sense it quickly and the circuit breaker will cut off the circuit.
The system will monitor the line status using electrical and electronic sensors, convert analog data
by analog to digital converter and send data to a remote server or database over the internet i.e.
will use the IoT concept for remote monitoring and controlling. The system will minimize the
danger of accidents and electrocution. This method eliminates the need for human power during
monitoring and disconnecting the line when it is needed.

1.5 Literature Review

In recent years, a large number of papers has been proposed the design and implementation of IoT
based controlling and monitoring the electrical equipment. The fatal electrical accidents of
electrical linemen are rising due to poor communication between electrical linemen and
maintenance staff. The paper [4] proposed a system that focuses on the safety of linemen while

Page | 4
working. The lineman detects a fault in the electric line. SMS gets sent to the substation staff who
then switches off the line. The drawback of the method is, it contains it GSM modem, and it should
have sufficient balance or data. It cannot control areas besides the substations. Here, another smart
circuit breaker model is proposed in the paper [5]. The circuit system is manually controlled by
the Blynk application. By reducing the maintenance cost and unnecessary downtime the proposed
system maintained overall circuit breaker performance. The disadvantage of this system is it does
not interface with the GSM modem. The remote controlling feature is not possible. The IoT-based
circuit breaker monitoring and control will reduce the size of the circuit [6]. It will eliminate the
concern regarding the security vulnerability of third-party systems as the platform is open source.
Here, EMI/EMC test is not possible. Integration with computerized maintenance management
software and the development of an open-source hosting server is missing. A system is proposed
to enhance electrical safety by fast disconnecting the power supply when a fault occurs It provides
real-time monitoring and notification events through an advanced communication interface. The
research gap of this paper is, it can’t integrate the protection device in a smart city with Lo-Ra
(Long Range Wide area network). A reliable, low cost and user-friendly IOT-based smart system
has been designed for monitoring and controlling [7]. The given system is fully automated which
provides self-checking of the oil level and oil quality and continuously check the amount of current
and sends the data to the web page. If overcurrent is detected the system automatically controls
the circuit. Circuit breakers are the punctuation system that opens or closes the circuit according
to their system command, A miniature circuit breaker (MCB) uses an automated electrically driven
switch to protect against electrical faults, particularly short circuits and overloads of both electrical
equipment and people. Another project [8] was implemented which offers a practical Internet of
Things (IoT) implementation that can be used to monitor and manage home appliances online.
Portable devices are used as the user interface for home automation systems. Through an Internet
connection, they can connect with the home automation network using low power network
technologies like Wi-Fi. With the help of a Raspberry Pi server system and Wi-Fi as the
communication protocol, this project seeks to operate home appliances from a smartphone. The
paper [9] illustrates various IoT-based applications and demonstrates how the system's monitoring
and control are now adaptable, reliable, and efficient for any real-time implementation. With the

Page | 5
aid of several sensors that are connected to microcontrollers like the ATmega328P, various
physical factors may be successfully monitored and made more interactive. These characteristics
include humidity, temperature, raindrop, GSM, air pressure, and LDR. The ATmega328P
microcontroller can be used as the central processing unit for the entire framework and can be
linked to all sensors as well as plans. With the help of this IoT-based system, the various systems
may be monitored in real-time. A system can be designed [10] that combines IoT platform
advantages with the requirements of high-speed real-time applications, using a single high-
resolution time source as the reference for both steady-state and transient situations. A power
system substation is given a high-speed IoT-based monitoring system with recording capabilities.
Low-latency communication must be taken into account for the majority of control and monitoring
applications due to the great time-sensitivity of power system operation. For applications that
monitor and control power systems, the IoT's real-time capacity is regarded as a crucial feature.
As a result, system administrators can use the real-time monitoring system to make better
judgments about both technical and financial issues. IoT based monitoring and controlling of smart
home systems have also been proposed [11]. A door authorization system and intelligent
monitoring and management of home appliances are both provided by this specifically designed
home automation technology. Numerous methods, including the Internet, electrical switches, and
Graphical User Interface (GUI) interfaces, have been used to control and monitor the state
(ON/OFF of the appliances). The system is simple to install in a home or other multipurpose
structure and has a low-cost design. The user can use this technology to decrease electrical power
waste by properly arranging the ON/OFF times of their gadgets or by routinely monitoring their
household appliances. An Internet-of-Things-based power-system protection device is suggested
in this study [12] and is intended to be integrated into smart settings. The proposed system was
created with the intention of being integrated in smart environments like smart homes or smart
cities for the protection of the electrical equipment. It improves electrical safety by swiftly cutting
off the power supply in the event of fault events like leakage current, electrical arc, overcurrent,
or overvoltage. By utilizing a data concentrator design and a sophisticated communication
interface, the system also supports real-time event monitoring and notification. Internet of Things
(IoT) applications gradually appear in smart grid power generation, transmission, transportation,

Page | 6
distribution, and consumption, which is advantageous for efficient administration of the
infrastructure supporting the power grid. This study [13] developed a transmission tower security
system based on IoT technology, which can achieve full-range protection for high-voltage
backbone transmission facilities and realize classification, location, and early warning of threats
to high-voltage backbone transmission towers.

1.6 Aims and Objectives of the project

The following are the project's goals and objectives:-

• To monitor line status live from a remote location.

• To eliminate the use of slower fuses as they mechanically break the circuit.

• To be able to detect when and where the fault occurs.

• To be able to control circuit breaker status remotely with a mobile app or web platform.

• To be integrated into smart environments like smart homes or smart cities

1.7 Project Outline

In this project, we have designed and implemented an IoT-based protection relay using a GSM
module and microcontroller. In the first chapter, we have made some preliminary discussions about
the project. Circuit breaker protection and IoT have also been discussed. In the second chapter, the
block diagram of the project and its different blocks have been described. The power supply,
microcontroller, GSM module, current sensor, relay, and their pin diagram, pin descriptions, and
features have been described. In the third chapter, the IoT-based protection relay, its system
architecture, working principle, system flow diagram, Blynk protocol, and their features have been
described. In the fourth chapter, circuit diagram, PCB design and operation have been discussed.
In the fifth chapter, the testing result, wiring diagram, no load observation, load observation and
the project’s output have been discussed. In the sixth chapter. we have come to an interface about
the project, its limitation, and the future scope of this project.

Page | 7
Chapter 2

Block diagram and Description

2.1 Introduction

The basic block diagram of this project consists of the microcontroller, GSM Module, current
sensor (ACS712-30A), Blynk application, step down transformer, relay, boost converter, battery
and battery charger. All this equipment is embedded together to implement IoT based protection
relay which can provide real-time monitoring and control capabilities when it is connected to AC
main line. The Blynk application shows the output notification with the help of the GSM module,
the person can remotely monitor the status and control the line by the cut off the line when any
fault occurs.

2.2 Block Diagram Description

The block diagram and its brief description are explained below. This consists of the following
blocks:

• AC main.
• Step down transformer.
• Microcontroller.
• Current sensor.
• Voltage measurement unit.
• Battery.
• Battery charger.
• Bridge Rectifier.
• Voltage Regulator.
• Boost Converter.

Page | 8
• Relay.
• Loads.
• GSM module.
• Cloud.
• Smartphone.

2.3 Block Diagram

The Block diagram of IoT based protection relay is shown in Fig 2.1. This block diagram shows
all the components used in the system.

Ac Main

Bridge Voltage
Transformer
Rectifier Regulator

Web
Server
Battery
Charger

IoT

Sim GSM
Battery
800L

Switch

Boost
Converter

Voltage MCU
Transformer
Measurement Atmega 328P

Current Relay
Measurement Module

Load

Fig 2.1: Block diagram of IoT-based protection relay.

Page | 9
2.3.1 Power Supply

Every circuit runs on a different voltage, some circuits run on the power supply of 1.5V,3.6V,
5V,6V,9V, and 12V. For using ATmega8 we need a power supply of 5V.

To get this power supply we have used 4 steps-

• Stepping down voltage by using a Transformer.

• AC to DC conversion rectifier circuit is used.

• Removing ripple from DC, a filter is used.

• To set a regulated DC supply a voltage regulator is used.

The first step is to scale down the voltage with a step-down transformer. A step-down transformer
converts the 220V to 12V AC. Then the rectifier converts the alternating current into direct current.
The rectification is very important in designing a DC power supply. In the power supply, we use
a full bridge rectifier. It is made of 2 p-n junction diodes. After rectification, a filtering process of
DC is carried out with the help of a filter because the output of DC power contains some ripple or
distortion. In the power supply, we use a 0.01 uF capacitor in parallel. Then the voltage regulator
provides the regulated output.

2.3.2 Microcontroller

A microcontroller, often known as an MCU or UC (for u-controller), is a microcomputer that is


placed on a single integrated circuit. It is close to but less advanced than, a system on chip (SoC)
in modern technology. One of the components of an SoC may be a microcontroller has one or
more CPUs (processor cores), memory, programmable input/output peripherals, ferroelectric
RAM, NOR flash, or OTP ROM, which is frequently incorporated on-chip, along with a small
amount of RAM. In contrast to the general-purpose microprocessors used in personal computers
and other applications that employ a variety of discrete chips, microcontrollers are designed for
embedded applications.

Page | 10
In this project, an Arduino Nano is employed. Based on the ATmega328P, the Arduino Nano is a
tiny, robust, and breadboard-friendly board (Arduino Nano 3. x). It consists of a different package
but has nearly the same features as the Arduino Circuitry. It only lacks a DC power jack and uses
a Small USB port rather than a standard one to perform. The first tiny project board with an inbuilt
USB was the Arduino Nano. The Arduino Nano is the latest breadboard-mountable Arduino. The
nano has Fourteen digital pins and eight bits pins. The ISCP headers should be flashed.

Fig 2.2: Microcontroller (ATmega328P) [15]

There is also the Arduino Nano, which is lacking the pin headers that face downward.

• ATmega328 microcontroller.
• 5V is the operating voltage (logic level).
• Recommended input voltage range: 7–12V.
• 6-20V input voltage.
• Digital I/O pins, which may produce PWM.
• Pins 8 for analog input.

Page | 11
• 40 mA of DC per I/O pin.
• 32KB of flash memory (2KB used by bootloader) 2KB SRAM.
• 1 KB EEPROM.

All Arduino boards contain a variety of features that give them a lot of versatility. All Arduino
boards are designed with ATMEL's ATMEGA AVR series microcontrollers, which have both
analog and digital pins. Any of the Arduino microcontrollers may be programmed using the
software, commonly referred to as "Arduino," by choosing it from a drop-down menu. Since it is
open source and based on C, Arduino users are not limited to utilizing this software and can instead
use a variety of other programs to program the microcontroller. The pin diagram of ATmega8 is
given below in fig 2.3.

Fig 2.3: Pin diagram of ATMega328p [16]

It uses a 32-bit RISC microprocessor with either an 80 MHz clock frequency based on the Tensilica
Xtensa L106 (or overclocked to 160 MHz). There are 96 KB of data RAM, 64 KB of instruction
RAM, and 64 KB of startup ROM. Using SPI, external flash memory can be accessed. The

Page | 12
ESP8266 module is a low-cost standalone wireless transceiver that may be used for end-point IoT
innovations. The microcontroller has to utilize a certain set of AT instructions to connect with the
ESP8266 module. Utilizing UART with a predetermined Baud rate, the microcontroller talks with
the ESP8266-01 module.

2.3.3 Current Sensor

The ACS712 Module in Fig. 2.6 makes use of the well-known ACS712 IC to monitor current
utilizing the Hall Effect theory. Use the IC (ACS712) directly in your finished goods instead of
the module as the module's name comes from the IC it contains.

Fig 2.4: Current sensor (ACS712-30A) [17]

Specifications

• Calculates AC and DC.

• A 5A, 20A, or 30A module is available.


• It provides load separation.
• Simple MCU integration because it produces analog voltage.

Page | 13
2.3.4 Cloud Application Overview
A cloud application (or cloud app) is an application program that functions in the cloud, with some
characteristics of a pure desktop app and some characteristics of a pure web application. A desktop
application operates entirely on a single device at the consumer's location it could be a mobile,
laptop, or tablet. A cloud application is stored on a server that is managed remotely and is accessed
from the Internet through a browser interface. Here, in this project, we use the Blynk application
for monitoring and controlling the status of the line.

2.3.5 Battery and Battery charger


In the domains of electricity and electrochemistry, a battery is any device that directly transforms
chemical energy into electrical energy. Batteries come in a variety of varieties. Lithium-ion
batteries are used in this project. A lithium-ion battery, sometimes known as a Li-ion battery, is a
type of rechargeable battery.

A device known as a battery charger, sometimes known as a recharger, stores energy in a battery
by passing an electric current through it. We use a TP4056 battery charger. The input of the battery
charger is 5v and the output of the battery charger is 3.6V-4.2V. The output of the battery charger
is connected to the battery.

Fig 2.5: lithium-ion battery [18]

Page | 14
2.3.6 Boost Converter

Boost Converters, sometimes also known as step-up choppers, are the kind of chopper circuits that
produce an output voltage greater than the given input voltage. In the case of boost converters, the
dc to dc conversion occurs in such a way that the circuit offers a large magnitude of output voltage
compared to the magnitude of the supply input. Boost Converters, sometimes also known as step-
up choppers, are the kind of chopper circuits that produce an output voltage greater than the given
input voltage. In the case of boost converters, the dc to dc conversion occurs in such a way that
the circuit offers a large magnitude of output voltage compared to the magnitude of the supply
input. Since the microcontroller is operated at 5V.so, in this project boost converter is used to boost
the voltage of the battery from 3.7V to 5V.

2.3.7 GSM Module

A small GSM modem that may be included in a large range of IoT applications is the SIM800L
GSM/GPRS module. By using the module, we can send SMS, make phone calls, connect to the
internet via GPRS, and much more. We use the SIM800L module. The chip's operating voltage is
range from 3.4V to 4.4V. The GSM module is powered by the battery. The baud rate of the module
is ranging from 1200bps to 115200bps. The module must be linked to the network via an external
antenna. A helical antenna that may be soldered onto the module often comes with it. A U.FL
connection is also included on the board in case you wish to keep the antenna separate from the
board.

Fig 2.6: SIM 800L [19]

Page | 15
2.3.8 Relay

A relay is an electrically operated switch. It is made up of a set of working contact terminals and
a set of input terminals for one or more control signals. Any number of contacts in different contact
configurations, such as making contacts, breaking contacts, or combinations of them, may be
included on the switch. The traditional form of a relay uses an electromagnet to close or open the
contacts, but other operating principles have been invented, such as in solid-state relays which use
semiconductor properties for control without relying on moving parts. Relays with calibrated
operating characteristics and sometimes multiple operating coils are used to protect electrical
circuits from overload or faults. Power sources Digital devices still referred to as protective relays
carry out these tasks.

Ordinarily open relay contacts (NO) have an open contact even when the relay is not powered on.
A normally closed (NC) relay contact is closed even when the relay is not powered on. In either
scenario, the contacts' state will be altered by an electrical current.

Fig 2.7: 2-channel relay module (SRD-05VDC-S-C) [20]

Page | 16
2.4 Summary:

In this chapter, the block diagram of the project has been described. In this block diagram, the
transformer is connected to the AC main line. Here, Step down transformer is used to transform
the 220V to 12V. The bridge rectifier is used to convert the AC voltage to DC voltage because the
battery and all the chips are operated at DC voltage. The voltage measurement unit senses the
voltage and the current sensor sense the current. All the components of the block are described
briefly in this chapter.

Page | 17
Chapter 3

IoT-based Protection Relay

3.1 Internet of Things

The spread of Internet connectivity into tangible objects and ordinary objects is known as the
Internet of things (IoT). These devices can interact and communicate with one another over the
Internet and can be remotely monitored and controlled since they are embedded with electronics,
Internet connectivity, and other types of hardware (like sensors).

Real-time analytics, machine learning, commodity sensors, and embedded systems have all come
together to redefine what the Internet of Things is. The traditional domains of automation
(including home and building automation), wireless sensor networks, control systems, embedded
systems, and others all contribute to making the Internet of things possible. In the consumer
market, "smart home" products are most often associated with IoT technology because they include
gadgets and appliances (like lighting fixtures, thermostats, home security systems and cameras,
and other home appliances) that support one or more common ecosystems and can be operated by
gadgets linked to that ecosystem, like smartphones and smart speakers.

Through the internet, people desire to interact with all inanimate objects, including clothing,
furniture, office supplies, and household appliances. Although there are many technologies
available for interacting with live creatures, IoT makes it possible to converse comfortably with
non-living objects. The Internet of Things (IoT) is the convergence of many technologies,
including embedded systems, ubiquitous, pervasive computing, ambient intelligence, sensors,
actuators, communication technologies, and internet technologies.

Page | 18
3.2 System Architecture

With the advancement of telecommunication and computer technology, most of the power utilities
are implementing many levels of automation power management systems across the network. As
mentioned before, IoT is expected to drive so many internet standardization efforts and create a
future with real-world internet communication. The idea behind the proposed system is to develop
a low-cost IoT-based protection relay system and integrate the IoT gateway for transmission line
fault monitoring and controlling. The proposed project uses MCU ATmega328p to monitor and
control i.e., ON/OFF the electrical lines. In this system, the maintenance staff or lineman has to
login into the Blynk Application to view the status of the line and switch the electrical line ON or
OFF according to to need.

3.3 Working Principle

IoT is the main method of communication between the developed device and web server to a
mobile application. The voltage divider and ACS 712 collect data from the load and line. This is
then sent to the MCU ATmega328p through serial communication. The controller then performs
logically and automatically operates using IoT protocol. This data is then sent via a sim module to
the Blynk mobile application through GSM / GPRS internet. It is an IoT-based platform. This data
is displayed on the application UI (user interface) where the user can monitor the data and perform
the action they desire. The status of connected devices is then updated in real time with the data.
This updated data is sent to the relay to take the appropriate action. The graphical user interface of
the Blynk application allows users to turn the device ON/OFF remotely. Fig. 3.1 represents a
flowchart that describes the system flow.

Page | 19
Fig 3.1: system flowchart

Page | 20
The system also includes a rechargeable lithium-ion battery to power the chip and sim module
when a fault occurs at the line. The battery is charged via a battery charger TP 4056. It is connected
to a 7805 module for voltage regulation. Center-tap transformer is used to scale down the input
AC voltage to a suitable level.

The device will monitor system parameters in real time and will notify the user via an indicator
when abnormal conditions are detected. Also, remote controlling options are available via the
internet. So basically, with this IoT-based protection relay installed it can be monitored and
controlled in real-time from anywhere in the world.

3.4 Blynk Protocol

Blynk Library uses a proprietary binary protocol.

Every message consists of 2 parts.

1. Header:
Protocol command (1 byte)
• Message ID (2 bytes)
• Body message length (2 bytes)
2. Body:
string (could be up to 2^15 bytes)

The structure of a binary message sent by Blynk is as follows:

command Message-ID Length/status Body

1 byte 2 bytes 2 bytes variable

Message size is 1 byte + 2 bytes + 2 bytes + message Body * length [21]

Page | 21
3.5 Protection Relay

Relays are automatic devices that automatically close their connections when they detect an
abnormality in an electrical circuit. These contacts each close, in turn, completing the circuit
created by the circuit breaker trip coil, causing the circuit breaker to trip and disconnect the
problematic area of the electrical circuit from the rest of the working circuit. [22]

Relays are compact and self-contained devices that can detect abnormal conditions. Protective
relays detect abnormal conditions in the electric circuit by constantly measuring the electrical
quantities, which are different under normal and fault conditions. IoT enables relays to become
controllable easily via the internet from anywhere.

3.6 Features of the Proposed System

• Real-time data monitoring.

• Real-time voltage monitoring.

• Real-time current monitoring.

• Remote monitoring of load status.

• Remote access to load control.

• Faster communication between MCU to server and server to user.

• Controlling of devices by users remotely.

• Reduction of human involvement in getting to the fault site for line termination.

• The displayed data will be updated in real-time to inform the user about the load status.

Page | 22
3.7 Summary:

In this chapter, the Internet of Things (IoT), Blynk protocol, and protection relay are defined. The
way all of these are put together to make this project work is also discussed here. The flowchart
presented here shows the microcontroller's working logic.

Page | 23
Chapter 4

Circuit Diagram and PCB Design

4.1 Project Model

Fig 4.1 shows the circuit diagram of our IoT-based protection relay monitoring and controlling
system. The circuit is based on a microcontroller board based on the chip ATMega328p, an 8-bit
microcontroller with 32KB of RAM with 2KB SRAM and 1KB EEPROM as the heart of this
system. It contains everything needed to support the microcontroller. To power the system here a
lithium-ion battery of 3.7V is used. Which is connected to a boost converter to boost the dc voltage
to 5V which the MCU chip requires. The microcontroller possesses different types of features like
ADC, Timer, INTERRUPT, UART TTL 5v serial communication, etc.

For voltage measurement operation, a step-down transformer (12-0-12) is connected to the main
supply line which steps down the supply voltage to a measurable value. Then this voltage is
connected to a voltage divider circuit from which a microcontroller tolerable voltage is obtained.
The output of the voltage divider is fed to the MCU chip.

For current measurement operation, ACS712 current sensor is used. ACS712 is a Hall Effect-
Based Linear Current Sensor it can measure both DC (Direct Current) and AC (Alternating
Current). ACS712 Current Sensor uses the Indirect Sensing method to calculate the current. To
sense the current a liner, a low-offset Hall sensor circuit is used in this IC. This sensor is located
at the surface of the IC on a copper conduction path. When current flows through this copper
conduction path it generates a magnetic field which is sensed by the Hall effect sensor. A voltage
proportional to the sensed magnetic field is generated by the Hall sensor, which is used to measure
current.

Page | 24
For the controlling purpose, a relay is connected with the MCU as shown in fig 4.1. The relay
performs the job of controlling the cutoff. For communication through GSM / GPRS, a module
SIM800L is connected to the MCU.

Fig. 4.1: circuit diagram of the project

Page | 25
4.2 Working Principle

This circuit is powered by a rechargeable battery which can be charged using a regular 5W adapter.
The voltage output of the battery is boosted by using a boost converter. At the center of everything
is the microcontroller unit. The circuit can perform both voltage and current measurements. There
is also an IoT part. It includes a sim module to communicate data to the server. Via the IoT
application, the device can be easily monitored and controlled.

4.3 PCB of the Project

The designed PCB board is added below. It is designed using the “EasyEDA” tool.

Fig. 4.2: PCB top view

Page | 26
Fig. 4.3: PCB bottom view

4.4 Circuit Operation

The total circuit operation consists of five parts.

1. Voltage measurement operation

2. Current measurement operation

3. Relay control operation

4. Data transfer operation from MCU to SIM module

5. Real-time status monitoring

Page | 27
4.4.1 Voltage Measurement Operation

In our project, a potential transformer 12-0-12 step-down type is used which is connected directly
to the main ac supply 230V. The transformer then steps down the main voltage to a value of 12 V.
The signal conditioning electronics needs to convert the output of the transformer to a waveform
that has a positive peak that's less than 5V and a negative peak that is more than OV. So we need
to:

1. scale down the waveform

2. add an offset so there is no negative component.

The voltage is then fed to a voltage divider circuit with a ratio of 1/11 to step down the transformer
output voltage within 5V. An offset (bias) is added using a voltage source of 5V supplied by the
battery connected across the MCU’s power supply which ensures a negative peak that is more than
0V. The divided voltage is then fed to the MCU to sense the voltage for further calculation.

The voltage is then displayed in the Blynk app. When the voltage rises over the safe limit specified,
an indicator will turn red in the mobile application. Then the circuit can be turned off using the
relay.

4.4.2 Current Measurement Operation

For sensing the current of the load, we have used a current sensor module model ACS712 (fig 4.2)
and relay in series with the load.

Page | 28
Fig 4.4: pin diagram of ACS712 current sensor

Under normal conditions, the current level is displayed on the Blynk application. However, when
there is an overcurrent (short circuit condition), the indicator will turn red and notify the user of
the situation. The user can then take action remotely via the application.

4.4.3 Relay Control Operation

The relay can be controlled directly via the Blynk application. When it is turned off, it will trip the
circuit breaker and thus terminate the connection to that part of the fault line. After the required
maintenance operation is done, the relay can then again be turned on remotely via the Blynk
application.

4.4.4 Data Transfer Operation

The data is transmitted from the microcontroller to the web server via GSM / GPRS technology.
This is done with the help of a SIM 800L module. The SIM module works at 3.7 Volt power which
is supplied by the battery. The data on the web server can then be displayed via the Blynk mobile
application. The communication that happens here is two-way communication. One way is to send

Page | 29
information from the microcontroller through the web server to the mobile application. And the
other way is to send the command given by the user via the web server to the microcontroller to
execute the operation.

4.4.5 Real-Time Status Monitoring

The status of the line can be observed in real-time via the Blynk application. Application data is
automatically updated every 5 seconds. The information That is displayed in the application is the
voltage and current of the transmission line.

4.5 Picture of the Project

The picture of the completed project is given below.

Fig. 4.5: picture of the project

Page | 30
4.6 Cost Estimation

Table 4.1: cost analysis of the project (single set)

Name of the components Quantity Price

ACS712 module 1 300

12-volt transformer 1 150

1N4007 diode 4 5

LM7805 (SMD) 1 20

TP4056 1 50

MT3608 boost converter 1 100

ATMEGA328p 1 650

SIM800L 1 450

Relay module 1 30

Sim card 1 300

Resistors 4 5

Capacitors 11 20

Two pin socket 1 5

Bulb holder 1 40

Bulbs 1 150

Connecting wires 20

Battery 1 120

Transportation cost 200

Switch 1 5

Page | 31
16 MHz crystal oscillator 1 15

Total cost 2635

This is the estimated cost for each device. In this project, two of these devices are made. Hence,
the total cost of the project is estimated to be approximately 2635*2 = 5270 taka.

4.7 Summary

In this chapter, the circuit diagram as well as the PCB board diagram of the circuit is shown. All
the main parts of the circuit are discussed in details. The cost of the project is also estimated and
put together as a table for a single device and then for the full set (2 devices).

Page | 32
Chapter 5

Result and Discussion

5.1 Introduction

In this project, we use the Blynk application to show the reading of voltage and current in real
time. The server receives the same reading at that same time through which the lineman can
monitor the load status, voltage, and current remotely. The lineman can monitor the voltage and
current from anywhere. If over current or over voltage is detected the Blynk application gives an
alarm and the lineman can cut off the circuit remotely. Here, we have used 60W and 100W bulbs
for showing the no-load observation and the load observation. When a 100W bulb is used the
circuit shows overcurrent and the Blynk application gives the alarm, then the lineman cutoff the
load by the relay.

5.2 Wiring Diagram

The wiring diagram of this project is shown in fig 5.1

Fig 5.1: Wiring diagram

Page | 33
5.3 No load observation

When the load is disconnected from the server then the system is shown in fig 5.2. The Blynk
application shows the voltage and current in no load condition. When there no load is connected
the application shows the 0V and 0A current.

Fig 5.2 No load observation

Page | 34
Fig 5.3: Blynk application Data (No Load)

Fig 5.3 shows the data of Blynk application data when no load is connected. It shows no current
and voltage reading because there are connected no load.

Page | 35
5.4 Load observation

We observe the result for two different loads. Firstly, we observe the result for two 60W loads and
then we observe the result for two 100W loads. For different loads, the Blink application shows a
different result.

5.4.1 Load observation for two 60W bulb

Fig 5.4 shows the load observation i.e. when two 60W bulbs are turned on from the Blynk
application. Here, the two loads are 60W. The application shows the voltage and current with 60W.

Fig 5.4: Load observation (60W)

Page | 36
.

Fig 5.5: Blynk application Data (60W)

Here, fig 5.5 shows the testing result of two 60W loads. It is a little different for two loads because
of some garbage value. The limiting value of the current is 0.45A. So, if we connect a 60W load
the current rating is 0.37A which is below the limiting value. The green signal indicates that it is
in normal condition. If we press the off button the relay cut off the circuit.

Page | 37
5.4.2 Load observation for two 100W bulb

Fig 5.6 shows the load observation i.e. when the 100W bulb is turned on from the Blynk
application. The application shows the voltage and current at 100W.

Fig 5.6: Load observation (100W)

Page | 38
Fig 5.7: Blynk application Data (100W)

Fig 5.5 shows the result when two 100W bulbs are connected to the circuit. When two 100W bulbs
are connected the current reading is 0.51A which exceeds the limiting value. The Red signal
indicates the overcurrent condition and we need to cut off the load. When we press the OFF button,
the circuit will be closed.

Page | 39
5.4.3 Load observation for 60W and 100W

Fig 5.8 shows the load observation i.e. when a 60W bulb and a 100W bulb are turned on from the
Blynk application. Here, two different loads are connected. One is 60W and another is 100W. The
application shows the voltage and current of a 60W bulb and a 100W bulb.

Fig 5.8: Load observation (60W and 100W)

Page | 40
Fig 5.9: Blynk application Data (60W and 100W)

Fig 5.9 shows the result when one 60W and one 100W load is connected. When the 60W load is
connected, the current reading is 0.44A which is a normal condition. So, it shows a green signal.
When a 100W load is connected, the current reading is 0.51A which is an overcurrent condition.
The red signal indicates that we may need to cut off the load.

Page | 41
5.5 Summary

The system is tested and verified in a real-time environment. We have tested the project for
different loads. We set the current limit at 0.45A. If the current exceeds the limiting value the
Blynk application shows an overcurrent condition. For two 60W loads, the Blynk application
shows a current 0.37A. So, the application doesn’t give any alarm. But when we use a 100W bulb
the current is 0.51A. It exceeds the limiting value. So, the application gives an alarm and indicates
that it is in an overcurrent condition.

The accuracy of this circuit is good enough either in a calm or noisy environment. The IoT-based
protection relay has been implemented and developed in this project which is cost-effective and
user-friendly. But there may remain some problems regarding monitoring the real-time reading of
the protection relay using the server due to the low speed and availability of the internet facility.

Page | 42
Chapter 6

Conclusion and Future Work

6.1 Conclusion

The 21st century has brought great discoveries and advancements in the field of technology. These
developments also brought about several difficulties, which call for strategies to address them. The
IoT-based protection relay is one such approach. Transmission line protection relay operation
using IoT is an innovative application of the internet of things developed to monitor the
transmission line status and control circuit breakers upon fault detection remotely over the cloud
from anywhere in the world. In this proposed project, voltage is measured with the help of a step-
down transformer, voltage divider, and voltage biasing. The current measurement sensor module
is connected in series with the load and relay. The chip on board is a microcontroller of model
ATmega328p. For IoT operation, the sim module worked reliably. The Blynk application
displayed updates in real-time reliably. Also, the relay operation is controlled remotely over the
internet via the Blynk application using a login ID and password by the user. The lithium-ion
battery also works as expected and provides with update information even when a fault occurs and
the faulty section is isolated from the rest of the line. The real-time update is displayed and the
developed devices delivered their outputs reliably. The remote-control options also work as
intended. The data of a certain duration of time are saved on the database which can be downloaded
and used for future data analysis.

In summary, we can achieve a low-cost and reliable IoT-based protection relay system for remote
transmission line monitoring and controlling. It can be used to monitor line status to make sure
everything is in order. Then remotely turn the line ON / OFF if a fault occurs. This enables quick
action. Users can monitor and control the line from a local site or a substation or even anywhere

Page | 43
in the world. Hence, preventing the risk of accidents and minimizing the danger of hazards due to
faulty transmission lines.

6.2 Shortcomings of the Project

The main shortcoming of this IoT-based protection relay monitoring and controlling system is that
sometimes the server cannot monitor and send the real-time reading of the line due to the very low
speed of the internet. Also, the user can neither monitor nor control the protection relay status
without an internet connection and sometimes the server might be down in some cases. However,
to make the system as reliable as possible, we used GSM / GPRS sim module so that it does not
have to rely on Wi-Fi. Another one is the addition of a lithium-ion battery to make sure it works
even when there is power in the transmission line due to fault.

6.3 Future Work

More research can be done to increase the accuracy of measurements, especially for reactive loads.
The project can be further enhanced by implementing some more features. Such as,

• Large-scale implementation by installing IoT-based protection relay to more transmission


lines.

• Power factor, frequency measurement.

• Ground fault detection.

• Develop an AI (Artificial Intelligence) for real-time technology to control and monitor all
parameters remotely and take action more precisely.

Page | 44
References

[1] W. Yuan, L. Zhao, and B. Zeng, "Optimal power grid protection through a defender–
attacker–defender model," Reliability Engineering & System Safety, vol. 121, pp. 83-89,
2014.

[2] J. Liu, G. M. Huang, Z. Ma, and Y. Geng, "A novel smart high-voltage circuit breaker for
smart grid applications," IEEE Transactions on Smart Grid, vol. 2, no. 2, pp. 254-264,
2011.

[3] K. Abdel-Latif, M. Eissa, A. Ali, O. Malik, and M. Masoud, "Laboratory investigation of


using Wi-Fi protocol for transmission line differential protection," IEEE transactions on
power delivery, vol. 24, no. 3, pp. 1087-1094, 2009.

[4] J. Kumar, S. Kumar, V. Yadav, N. K. Singh, P. K. Gaur, and P. K. Tyagi, "Password Based
Circuit Breaker," International Journal of Recent Research Aspects, vol. 3, no. 1, pp. 80-
85, 2016.

[5] A. Vlasov, S. Filin, and A. Krivoshein, "Universal smart circuit breaker concept," in 2019
International Conference on Industrial Engineering, Applications and Manufacturing
(ICIEAM), 2019: IEEE, pp. 1-4.

[6] A. Das, K. Kalimuthu, and S. Biswas, "IOT Based Circuit Breaker Monitoring & Control,"
International Journal of Applied Engineering Research, vol. 13, no. 10, pp. 7806-7810,
2018.

[7] M. S. Hossain, M. Rahman, M. T. Sarker, M. E. Haque, and A. Jahid, "A smart IoT based
system for monitoring and controlling the sub-station equipment," Internet of things, vol.
7, p. 100085, 2019.

[8] D. Pavithra and R. Balakrishnan, "IoT based monitoring and control system for home
automation," 2015 Global Conference on Communication Technologies (GCCT), 2015,
pp. 169-173, doi: 10.1109/GCCT.2015.7342646.

Page | 45
[9] M. S., G, D., B, C. & D, D. (2021). IoT Based Monitoring and Control System using
Sensors. Journal of IoT in Social, Mobile, Analytics, and Cloud, 3(2), 111-120.
doi:10.36548/jismac.2021.2.004

[10] L. Zhao, I. Brandao Machado Matsuo, Y. Zhou and W. -J. Lee, "Design of an Industrial
IoT-Based Monitoring System for Power Substations," in IEEE Transactions on Industry
Applications, vol. 55, no. 6, pp. 5666-5674, Nov.-Dec. 2019, doi:
10.1109/TIA.2019.2940668.

[11] P. Kumar and U. C. Pati, "IoT based monitoring and control of appliances for smart home,"
2016 IEEE International Conference on Recent Trends in Electronics, Information &
Communication Technology (RTEICT), 2016, pp. 1145-1150, doi:
10.1109/RTEICT.2016.7808011.

[12] Machidon OM, Stanca C, Ogrutan P, Gerigan C, Aciu L (2018) Power-system protection
device with IoT-based support for integration in smart environments. PLoS ONE 13(12):
e0208168. https://doi.org/10.1371/journal.pone.0208168

[13] Y. Zhen, X. Li, Y. Zhang, L. Zeng, Q. Ou and X. Yin, "Transmission tower protection
system based on Internet of Things in smart grid," 2012 7th International Conference on
Computer Science & Education (ICCSE), 2012, pp. 863-867, doi:
10.1109/ICCSE.2012.6295205.

[14] https://www.google.com/search?q=Iot&tbm=isch&sxsrf=ALiCzsbRLEfr2M-
fHT9eb4XJbyL6CY-
50w:1667197441420&source=lnms&sa=X&ved=2ahUKEwjGn5C66on7AhVjklYBHbo
vCdIQ_AUoAnoECAMQBA#imgrc=BWBcsF8YasFtCM

[15] https://www.kiwi-electronics.com/nl/arduino-uno-rev3-atmega328-729

[16] https://components101.com/sites/default/files/component_pin/ATMega328P-Pinout.png

[17] https://www.indiamart.com/proddetail/acs712-5a-20a-30a-current-sensor-
8826833830.html

Page | 46
[18] https://www.indiamart.com/proddetail/lithium-ion-3-7v-2600mah-batteries-
8858030948.html

[19] https://lastminuteengineers.com/sim800l-gsm-module-arduino-tutorial/

[20] https://components101.com/switches/5v-single-channel-relay-module-pinout-features-
applications-working-datasheet

[21] https://docs.blynk.io/en/blynk.edgent-firmware-api/blynk-protocol

[22] https://www.electrical4u.com/types-of-electrical-protection-relays-or-protective-relays/]

Page | 47
Appendix

Code Used in This Project:

#define vol_pin A1

#define cur_pin A0

#define relay 7

//.............................Blynk defination..............................//

#define BLYNK_TEMPLATE_ID "TMPLkLDI_aDA"

#define BLYNK_DEVICE_NAME "Safety Relay"

#define BLYNK_AUTH_TOKEN "lRff6bP6yfmCN8Ajm_LGsqp9JnlXQ33e"

#define BLYNK_PRINT Serial // Comment this out to disable prints and save space

#include <Blynk.h>

BlynkTimer timer;

#define TINY_GSM_MODEM_SIM800

#include <TinyGsmClient.h>

#include <BlynkSimpleTinyGSM.h>

Page | 48
// Set serial for debug console (to the Serial Monitor, default speed 115200)

#define SerialMon Serial

// Hardware Serial on Mega, Leonardo, Micro

#ifndef __AVR_ATmega328P__

#define SerialAT Serial1

#else

#include <SoftwareSerial.h>

SoftwareSerial SerialAT(3,2); // RX, TX

#endif

const char apn[] = "internet";

const char user[] = "";

const char pass[] = "";

const char auth[] = "lRff6bP6yfmCN8Ajm_LGsqp9JnlXQ33e";

TinyGsm modem(SerialAT);

//define mode

Page | 49
int mode=1;

int state=1;

//.............................Function definations..........................//

float getCurRead();

float adc2curr(float adc);

float adc2vol(float adc);

float adc2temp(float adc);

void updateData();

//...........................

int vol_read,cur_read;

//.............................Safety margin..................................//

float voltage_margin=40;

float current_margin=9;

float td[2];

Page | 50
BLYNK_WRITE(V7) // this command is listening when something is written to V1

int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable

if (pinValue == 1){

Serial.println("On");

state=0;

} else if (pinValue == 0) {

state=1;

Serial.println("Off");

Serial.print("V1 button value is: "); // printing value to serial monitor

Serial.println(pinValue);

void setup(){

pinMode(7,OUTPUT);

// Set console baud rate

SerialMon.begin(9600);

delay(10);

Page | 51
// Set GSM module baud rate

SerialAT.begin(9600);

delay(6000);

// Restart takes quite some time

// To skip it, call init() instead of restart()

SerialMon.println("Initializing modem...");

modem.restart();

String modemInfo = modem.getModemInfo();

SerialMon.print("Modem Info: ");

SerialMon.println(modemInfo);

// Unlock your SIM card with a PIN

//modem.simUnlock("1234");

Blynk.begin(auth, modem, apn, user, pass);

timer.setInterval(1000L,updateData);

pinMode(relay,OUTPUT);

void loop(){

Page | 52
update_vol_car();

float this_vol=adc2vol(vol_read)*5;

float this_cur=adc2curr(cur_read);

//this_cur=cur_read;

//this_vol=0;

//this_cur=20;

//If current is greater than 10A or voltage is less than 2v then transfomer line off

if(this_vol<=voltage_margin||this_cur>current_margin){

mode=0;

else{

mode=1;

if(state==0){

td[0]=0;

Page | 53
td[1]=0;

else{

td[0]=this_vol;

td[1]=this_cur;

Blynk.run();

timer.run();

if(state==1){

digitalWrite(relay,HIGH);

}else{

digitalWrite(relay,LOW);

Page | 54
//..................................Functions......................................//

//ADC value to current

float adc2curr(float adc){

float adcVoltage = (adc / 1024.0) * 5000;

float current = ((adcVoltage - 2500) / 66);

return abs(current-0.3);

//Get current AC ADC reading

void update_vol_car(){

int max_cur=0;

int max_vol=0;

int current_read;

int voltage_read;

for (int x = 0; x < 300; x++){ //Get 300 samples

current_read=analogRead(cur_pin);

voltage_read=analogRead(vol_pin);

Page | 55
max_cur=(max_cur>=current_read)?max_cur:current_read;

max_vol=(max_vol>=voltage_read)?max_vol:voltage_read;

delay(1);

vol_read=max_vol;

cur_read=max_cur;

//ADC to voltage

float adc2vol(float adc){

float res_vol=(adc * (5.0 / 1023))*93.67;

return res_vol;

//.................................................Bylink Data Update...............................//

void updateData(){

Blynk.virtualWrite(V3,td[0]);

Blynk.virtualWrite(V4,td[1]);

Page | 56
if(mode==1){

//#D3435C - Blynk RED

Blynk.setProperty(V9, "color", "#78f542");

Blynk.virtualWrite(V9, 255);

}else{

Blynk.setProperty(V9, "color", "#f55d42");

Blynk.virtualWrite(V9, 255);

Page | 57

You might also like