Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 55

CAPSTONE PROJECT

REPORT

on

Smart Home Environment Control System Using Embedded


System Design

Project Team Members: EE, 7th SEMESTER

Jatin Raheja - 101404053


Kanishak Sharma- 101404054
Karan Bajaj- 101404055
Yogesh Garg- 101404138

Under the Guidance of

Dr. Shakti Singh


Assistant Professor
EIED, Thapar University

2017

Electrical and Instrumentation Engineering Department


Thapar University, Patiala
(Declared as Deemed-to-be-University u/s 3 of the UGC Act., 1956)
Post Bag No. 32, Patiala – 147004
Punjab (India)

i|Page
DECLARATION
We hereby declare that the project entitled smart home environment control system using
embedded system design is an authentic record of our own work carried out in the Electrical
& Instrumentation Engineering Department, Thapar University, Patiala, under the guidance
of Dr. Shakti Singh during 7th semester (2017).

Date:

Jatin Raheja
101404053

Kanishak Sharma
101404054

Karan Bajaj
101404055

Yogesh Garg
101404138
Faculty Supervisor:

Dr. Shakti Singh


Assistant Professor

ii | P a g e
ACKNOWLEDGEMENT
We take the privilege to offer our deepest sense of gratitude to our faculty supervisor Dr.
Shakti Singh, for his understanding, encouragement and personal attention which have
provided good and smooth basis for our dissertation tenure. This work would not have been
possible without his guidance, support and encouragement. Under his guidance we
successfully overcame many difficulties and learned a lot.
We are also thankful to Dr. Prakash Gopalan, Director of Thapar University, Patiala for
providing the facilities for the completion of project work. We express our deep sense of
gratitude towards Dr. R.S. Kaler, Head of the Department of Electrical & Instrumentation
Engineering, Thapar University, Patiala for constantly encouraging each student to put their
best foot forward in whatever field of work they take up.
We further express our indebtedness to our parents who have constantly helped us keep our
morale high all through the work.

Jatin Raheja
101404053

Kanishak Sharma
101404054

Karan Bajaj
101404055

Yogesh Garg
101404138

iii | P a g e
ABSTRACT
The advancement in technology day by day has made life easier and simpler. In this fast-
moving world people want technologies which are user friendly and always available in their
hand starting from online shopping to controlling huge machineries in mega-factories.
Technology has made life easier and fast paced. With such a bloom in technology, initially
the industries demanded for a system that would be able to control the entire plant from just
one location which brought in the concept of automation. The very first fully automated
spinning mill driven by water was developed in 1771. With the changing scenario automation
is the demand of every household, industry and any sort of commercial building.
The major development of automation in households was the application of remote
controlled switching of appliances. Alongside with the invention of Bluetooth and IoT
technologies the major constraint of remote control i.e. the range was small was removed.
The major goal of this project is to design a voltage regulator circuit. A Bluetooth interface of
Smartphone and sensors for automatic control over appliances.
The circuit for the voltage regulator involves a full bridge rectifier, an Arduino Uno,
Optocoupler, Zero Crossing Detector (ZCD) and a Triac. The rectifier and the ZCD is used to
send signal to the Arduino. The rectifier converts AC to pulsating DC and ZCD senses the
zero point of the voltage pulse. The Arduino provides a pre-decided time delay starting from
the zero-point provided by the ZCD. The optocoupler has two purposes. Firstly, it provides
isolation for the Arduino from the main AC circuit and secondly it provides gating pulse to
triac. The triac is used for voltage cutting.
In this system the entire voltage regulation can be controlled manually using a
Smartphone over Bluetooth or automatically by using sensor inputs to the Arduino. The
sensors are so interfaced that with change in the physical conditions in the room the voltage
of various appliances like fans, lights etc would be changed. Therefore, to conclude the
system is capable of receiving the command from the user to control and regulate the
appliances either manually or automatically.

iv | P a g e
LIST OF FIGURES

Figure No. Caption Page No.


2.1 Voltage regulator circuit 8
2.2 Triac symbol 10
2.3 Working of zero crossing detector 10
3.1 Work packages 14
3.2 Working methodology 17
3.3 Flow chart 18
3.4 Simulation of voltage regulator circuit 19
3.5 Waveform of voltage at first button press 21
3.6 Waveform of voltage at full power 22
3.7 Hardware circuit 22
3.8 Main screen of MIT app inventor 23
3.9 Code blocks 24
4.1 Hardware results 25

v|Page
LIST OF ABBREVIATIONS

Symbol Description

RF Radio Frequency
ZCD Zero Crossing Detector
ADK Accessory Development Kit
GSM Global System for Mobile Communication
GPRS General Packet Radio Service
DTMF Dual Tone Multi-Frequency
GUI Graphical User Interface
IP Internet Protocol
PWM Pulse Width Modulation
IOT Internet Of Things
SSID Service Set Identifier
ADSL Asymmetric Digital Subscriber Line
SSL Secure Socket Layers
PIC Peripheral Interface Controller

vi | P a g e
CONTENTS
Page No.
i. DECLARATION Ii
ii. ACKNOWLEDGEMENT Iii
iii. ABSTRACT iv
iv. LIST OF FIGURES v
v. LIST OF ABBRIVIATIONS Vi

CHAPTER 1: INTRODUCTION
1.1 INTRODUCTION 1
1.2 LITERATURE SURVEY 4
1.3 NEED ANALYSIS 5
1.4 AIM 6
1.5 OBJECTIVES 6
1.6 PROBLEM FORMULATION 7
1.7 EXPECTED DELIVERABLES 7
1.8 NOVELTY OF WORK 7

CHAPTER 2: THEORY, STANDARDS AND CONSTRAINTS


2.1 THEORY (THEORETICAL ANALYSIS, WORKING 8
PRINCIPLES)
2.2 ASSUMPTIONS AND CONSTRAINTS 12
2.3 TECHNICAL STANDARDS USED 12

CHAPTER 3: DESIGN METHODOLOGY


3.1 PROPOSED WORK FLOW/ METHODOLOGY 14
3.2 FLOW CHART 17
3.3 MATHEMATICAL ANALYSIS AND CALCULATIONS 18
3.4 SIMULATION SET UP 19
3.5 HARDWARE DESIGN 21

vii | P a g e
CHAPTER 4: RESULTS AND DISCUSSION
4.1. SIMULATION RESULTS 25
4.2 HARDWARE RESULTS 25
4.3 INFERENCE DRAWN 27
4.4 JUSTIFICATION OF OBJECTIVES ACHIEVED 28

CHAPTER 5: CONCLUSIONS AND FUTURE WORK


5.1. CONCLUSIONS 29
5.2. FUTURE WORK 29

CHAPTER 6: PROJECT METRICS


6.1 CHALLENGES FACED AND TROUBLE SHOOTING 30
6.2 RELEVANT SUBJECTS 30
6.3 INTERDISCIPLINARY ASPECT 31
6.4 COMPONENTS USED 31
6.5 BRIEF ANALYTICAL NOTES 32
6.6 TEAM ASSESSMENT MATRIX 34
6.7 WORK SCHEDULE 35
REFERENCES 36
ANNEXURE (programming code/ data sheets/ standards/ snapshots etc.) 38
PLAGIARISM REPORT

viii | P a g e
CHAPTER-1
INTRODUCTION
1.1 INTRODUCTION

Electronic and Electrical environment with respect to the framework of the project is any
environment which consists of appliances such as fans, television sets, air conditioners,
motors, heater, lighting systems, etc. A remotely accessible environment is an environment in
which each appliance can be remotely accessed and controlled using software as an interface,
which includes an android application and a web application. Such remotely accessible
systems are already available in the market, but have a number of drawbacks as well.
As technology is growing day by day, man is depending upon it heavily. Therefore, he
wants everything at his hand there and then. For example, if someone want to buy something
nowadays, he/she heavily relies on e-commerce websites to buy it. Using a mobile phone if
one can buy stuff why can’t one control the daily interactions with machines via this device.
Modern day’s industries are packed with technology to control the overall processes. In a
modern day plant there are number of machineries that run independently but are controlled
by a main control board which acts as the brain to the entire plant, sensing and analyzing and
processing the data which is provided as feedback by various sensors that are installed
throughout the length and breadth of the plant. On the similar concept all the appliances in
our homes can be made to operate automatically by sensing, analyzing and processing the
data provided by the sensors to the master control of the house.
With growth and advancement in technology, medium to control the appliances is
upgraded from time to time, to increase the efficiency, reliability, speed as well as cost
deduction of the product. Since late 90’s, medium are changed so far from Bluetooth, Global
system for mobile communication (GSM), Zigbee, Radio Frequency module (RF-Module),
WIFI Module, Internet of things and so on.
Bluetooth home automation control via cell phone can be executed using an Arduino BT
board. It works on the basic principle of communication and interaction of Arduino with any
Bluetooth device. In this system the home appliances are connected to the Arduino board at
input output ports using relay and the program of Arduino are based on high level C

1|Page
programming language of microcontroller. A circuit is designed so that one can receive the
command from the Bluetooth device and further convey it to control the working of multiple
devices. [1]
To monitor and control the home appliances the system is designed and implemented
using Zigbee. The device performance is recorded and stored by network coordinators. For
this the Wi-Fi network is used, which uses the four switch port standard wireless Asymmetric
Digital Subscriber Line modern router. The network Service Set Identifier and security Wi-Fi
parameter are preconfigured. The message for security purpose first process by the virtual
home algorithm and when it is declared safe it is re-encrypted and forward to the real
network device of the home. Over Zigbee network, Zigbee controller sends messages to the
end. It handles the safety and security of all messages that are received by the virtual home
algorithm. To reduce the expense of the system and the intrusiveness of respective
installation of the system Zigbee communication is helpful.
The smartphone revolution brought with itself the concept of home automation using
general packet radio service (GPRS), global system for mobile (GSM) messaging and dual
tone multi frequency (DTMF) systems, but these all are classified under GSM controlled
system.
Wi-Fi based home automation system; a central server is created on a Wi-Fi. Now this
server is common to both the smartphone and the microcontroller. The advantage of this
system is that the transmitting and relaying action is quite fast. The only disadvantage is that
this system is used for controlling the appliances from within a building.
As the technology is growing at a fast pace the traditional current switches are being
replaced by centralized system containing radio frequency (RF) controlled switches for
switching. The traditional systems are rather more problematic for handicapped and old age
person. In order to accomplish this, a RF remote is combined to the microcontroller on
transmitter side that sends ON/OFF signals to the receiver where devices are connected.
Nowadays, system uses mobiles or computers to exercise basic home control and
function automatically through internet from anywhere around the world globally. An
automated home is sometimes called a smart home. It is meant to save the electric power and
human energy. The proposed system is a distributed home automation system, consists of
server i.e. Wi-Fi module clubbed with sensors. Server controls and monitors the various

2|Page
sensors, and can be easily configured to handle more hardware interface module (sensors).
The Arduino board, with built in Wi-Fi module acts as web server. Automation System can
be accessed from the web browser of any local PC using server IP, or remotely from any PC
or mobile handheld device connected to the internet with appropriate web browser through
server real IP (internet IP). Wi-Fi technology is selected to be the network infrastructure that
connects server and the sensors. Wi-Fi is chosen to improve system security (by using secure
Wi-Fi connection), and to increase system mobility and scalability.
Home automation using cloud based system focuses on design and implementation of
home gateway to collect data from home appliances and then send to the cloud-based data
server to get stored on the Hadoop distributed file system. It is processed using MapReduce
and it is used to implement a monitoring task to remote user. Presently home Automation
System is persistently developing its resilience by assimilating the current characteristics
which gratify the rising interest of the people. The home automation system being considered
uses cloud computing as a mode of communication between user and the devices. The
system consists of three important units: the first part is cloud server, which handles and
controls the data and information of client and users and the status of devices. The hardware
interface module is the second part which implements the relevant connection to the
actuators and sensing devices which give the physical service. Last part is Home Server,
which constructs the hardware device and gives the user an interface. This system uses cloud
services which is required for security, storage and availability of the data. The system is cost
efficient, reliable and comfortable which also provides a secured home automation system
for entire family. The system is made up of various client modules for various platforms.
1. Cloud server: Cloud Server is a central server aims on implementing services to the other
sub modules. Central server serves as the data respiratory system and brain It implements
three connections to the three sub modules viz home system, web configuration tool and
mobile. The server evaluates the data it takes from the house, send current status to the
mobile device and vice versa. A database is managing by the server and it is status gets
updated as per the changes done at home end.
2. Embedded program for hardware circuit microcontroller, and.
3. Internet client for any desktop or mobile phones.

3|Page
1.2 LITERATURE SURVEY

Sriskanthan et al. [2] in their work have presented an application of Bluetooth


Technology for home automation. The Bluetooth technology which came out in late 1990's is
used for implementing the wireless home automation system. Various appliances such as air
conditioners, home theatres, cellular phones etc., are organized, thus creating a personal area
network in home environment. The communication between several client modules and the
host server takes place through the Bluetooth module. A Home automation protocol has been
formed to enhance communication between the host server and the client modules. The
system also allows integration or removal of devices to the network which makes the system
scalable. The wireless system aims at reducing the cost of home automation. However the
system does not use the trending mobile technology.

Alkar et al. [3] have developed an internet based wireless home automation system for
multifunctional devices. A flexible, low cost, wireless solution to the home automation is
introduced. The home appliances are connected through a server to a central node. The
system is secured from unauthorized users by using secure sockets layer (SSL) algorithm.
During tests, the range of wireless communication was found to be limited to less than 100
meters in a concrete building.

Yavuz et al. [4] have designed and implemented a telephone and peripheral interface
controller (PIC) remote controlled device for controlling the home electrical devices. In this
pin check algorithm has been introduced where it was with cable network and not wireless
communication. The system ensures safety as it cannot be used by unauthorized users as the
system uses pin-check system. The architecture is very complex, but it gives an idea of
remote handling of home automation system.

Hoque et al. [5] presented a GSM based communication and control for home appliances.
Different AT commands (instructions used to control a modem) are sent to the home mobile
for controlling different appliances. The limitation of this system was that a Graphical User
Interface (GUI) was not provided to the user. Different AT commands had to be remembered
by the users to control the connected devices. As nowadays the Smartphone they don’t
support java, this system which is extensively dependent on java seems to lose its credibility.

4|Page
Piyare et al. [6] designed a Bluetooth based home automation system which was cheap,
flexible and provided a wireless solution to home automation. The system used Bluetooth
communication to interact between the user and the electrical appliance. The major drawback
of the system is that, the Bluetooth technology is restricted over a certain range of area.
Therefore this kind of system can only be implemented from within the home premises.

Javale et al. [7] have used Android accessory development kit (ADK) for implementing a
home automation and security system. It presents a system in which the devices are
connected to a Bluetooth sub-controller physically. It does not require internet connectivity.
The Smart phone is used to access and control the devices using built-in Bluetooth
connectivity. Communication is established between the android mobile device and the
ADK, by connecting the appliances to the ADK. However, the system restricts mobility and
can only be controlled within the specified boundary due to limited range of operation
(maximum up to 100 m). Hence the system does not support remotely monitoring and
controlling the appliances.

1.3 NEED ANALYSIS

After analysing needs of different segments of society the society is in a dire need of
technological advancement at the home front. Industries, over the past decade have been
completely modified from using conventional systems to handle the operation of machinery
to a completely self-dependent system to do the same job. Using same concept of
automation, one can bring this technology to homes in confined manner which is efficient
and economical.
The system consists of two main parts: A hardware interface module and a software
communication module. The hardware interface module consists of: Arduino ATmega328
microprocessor, Bluetooth module and relays. The central device is the microprocessor that
connects to the Bluetooth module and receives orders to monitor and control the appliances.
The communication between the application and microprocessor is handled by the server,
thus managing the users and the appliances. The software communication module uses an
Android application as the frontend, which serves as an interface to the user to communicate
with the microprocessor. It presents a list of devices with which the user can interact.

5|Page
The system offers switching functionalities to control the appliances connected to the
system, which includes lights, fans, air-conditioners and various other appliances connected
to the system. In India, the alternating current supplied to our homes is of 230V. Arduino
Board is not capable of withstanding such high Voltages. Thus, Relays are used to convert
this high voltage to low voltage i.e. less than 5V. The relay switches have capability to carry
a maximum load of 10A at 240V.
To enable connectivity with the microcontroller Bluetooth module is used. It provides
Internet connectivity, which allows Internet access and control from the Android Application
effectively and efficiently. The Android application is a user-friendly interface, which
enables the user to view status of appliances at home and control it as per his/her requirement
[8]. This system can also be used for security purposes as one is able to control and monitor
their home appliances through a server. One can check whether their household appliances
are ON/OFF when they are not at home.

1.4 AIM

To develop a home automation prototype which mainly focuses on controlling and


monitoring the different household appliances automatically as well as manually with respect
to environmental conditions through mobile application. The system consists of two main
parts: a hardware interface module and a software communication module.

1.5 OBJECTIVES

The discussed aim is to be achieved by breaking it into following objectives:


 To design and develop automatic room environment control and manual control over
Bluetooth using mobile.
 To control temperature (using a fan), light intensity and humidity level inside a room
automatically using various sensors working in synchronism.
 To provide basic controls of room appliances on to the user’s mobile phone that will
communicate through serial communication.

6|Page
1.6 PROBLEM FORMULATION

With changing trends people tend to prefer technologies which improve their lifestyle. In the
recent era people are preferring ease of access in every aspect of their lives. One such aspect
of their lives are their homes, and the current generation which is fast moving generation
want their homes to be fully automated or such homes which can be controlled at their
fingertips. Thus the market is in a dire need to develop such systems which aid in the
automation of the homes which provides the user the freedom to control the appliances in
their homes anytime and from anywhere in the world.

1.7 EXPECTED DELIVERABLES

A deliverable circuit which is having options to control switching and voltage control
manually and automatically for a system having both resistive and inductive loads. All the
operations are getting controlled using mobile application using Bluetooth communication.
Any household switching device can be attached to the system, whereas for the voltage
control power rating of device used should be less than 100W.

1.8 NOVELTY OF WORK

The novelty of this system is that it’s very compact, easy to maintain and implement. The
traditional systems implemented right now are very costly, but this system developed is quite
economical and low on maintenance when produced at large scale. This system involves the
implementation of Bluetooth technology for interaction which removes the limitations of RF
based and GSM based automation techniques which is slow and costly.

7|Page
CHAPTER 2
THEORY, STANDARDS AND CONSTRAINTS
2.1 THEORY (THEORETICAL ANALYSIS, WORKING PRINCIPLES)

AC voltage regulation is accomplished using triac and zero crossing detectors. The principle
involved in voltage regulation is phase cutting of AC wave which is achieved by firing control of
triac. Zero crossing detector (ZCD) tells the controller whenever the AC wave crosses zero
voltage point and hence set a reference point for the phase angle that is to be provided in the
form of time delay.

Fig. 2.1: Voltage regulator circuit

Following are the major components used to achieve the circuit mentioned in Fig. 2.1:

a) The Triac

An SCR is a unidirectional device as it can perform from anode to cathode only and not from
cathode to anode. A triac can, however, conduct in both the directions. A triac is thus a

8|Page
bidirectional thyristor with three terminals. It is used invariably for the control of power in AC
circuits. Triac is the word derived by adding the capital letters from the words Triode and AC.
When in operation, a triac is corresponding to two SCRs connected in antiparallel. As the triac
can conduct in both the directions, the terms anode and cathode are not valid for triac. Its three
terminals are usually designated as MT1 (main terminal 1), MT2 (main terminal 2) and the gate
by G as in a thyristor [9].

Fig. 2.2 Triac BT136 [10]

With no signal to gate, the triac will block both half cycles of the ac applied voltage in case peak
value of this voltage is less than the break over voltage of the triac. The triac can be turned on in
each half cycle of the applied voltage by applying a positive or negative voltage to the gate with
respect to terminal MT1.

b) Zero Crossing Detector

ZCD is a type of voltage comparator, which is used to sense transition of AC waveform from
positive to negative, i.e. when the input crosses zero voltage condition.

Fig. 2.3 Zero crossing detection

9|Page
In the used methodology, the input AC wave is converted to 100Hz from 50Hz using a bridge
rectifier which is fed to the zero crossing detectors. The output from zero crossing detectors is
being fed to the controller’s interrupt pin which set a reference for the firing angle which will be
fed to triac using another digital pin of controller.

The output from the Arduino is fed to the triac in the form of time delay which helps in
the cutting of phase angle in each and every half cycle. The Arduino senses the commencement
of the half cycle using the ZCD and starts the time delay from thereon, thereby achieving the
goal of phase cutting in each half cycle which in turn regulates the voltage input to appliance.

3) LM35 sensor

The temperature of the environment is measured using temperature sensors. And one such
temperature sensor is the LM35 IC. The LM35 has three terminal a voltage source terminal (5V),
ground and an output terminal. The Integrated circuit (IC) gives an output proportional to the
temperature of the surroundings. The main advantage of using this IC is that it is a
semiconductor based IC which gives it the property that it does not get heated too much
internally in still air. The maximum internal temperature rise is about 0.01 to 0.1. This IC is quite
accurate and precise with its output.

Fig. 2.4: LM35 temperature sensor [11]

Speed control of single phase induction motor

The method used to control Induction motor is voltage control using thyristor/triac. The
thyristors in series with supply mains are used to control the voltage across the stator winding.
With the help of thyristor the supply to the stator winding is switched on only for a sometime and

10 | P a g e
remains off for remaining time in one complete cycle. This switching reduces the magnitude of
the average AC voltage applied to the stator winding and the speed is controlled in this manner.

Since the waveform of voltage applied to the stator winding does not remain a perfect
sinusoid. Due to this there are increased losses in the induction motor and this method is
applicable to small induction motors only [12].

Serial Communication

In telecommunication and computer science, serial communication is the process of sending data
bit by bit, sequentially, over a communication channel or computer bus. This is in contrast to
parallel communication, where several bits are sent as a whole, on a link with several parallel
channels.
Serial communication on pins TX/RX uses TTL logic levels (5V or 3.3V depending on the
board). Serial is used for communication between the Arduino board and a computer or other
devices. All Arduino boards have minimum of one serial port. It communicates on digital pins 0
(RX) and 1 (TX) as well as with the computer via USB according to ANSI/ASHRAE 135
standard [14].

2.2 ASSUMPTIONS AND CONSTRAINTS

Assumptions

 The system developed is the most efficient system developed so far, further
improvements could be made to make it more efficient.(although, this system is not quite
efficient due to the rigorous switching losses that occur during the AC voltage control
action).
 The algorithm developed for executing AC voltage control contains an iterative loop after
every 100 milliseconds, this delay is assumed to be good enough for the triac to
completely execute its previous cycle and get ready to execute its next cycle.

Constraints

 The system is so designed that if it is used properly it can contribute to save power by
switching the appliances at the correct time but in real life such ideal conditions are rarely

11 | P a g e
met. So this circuit is bound to have power losses due high switching frequency of
devices thus losing some of its efficiency.
 The communication between system and mobile phone is restricted by the
communication modules. In order to increase the range the module used can really cost a
lot of money.
 Until now, no security system can be attached onto the existing system.

2.3 TECHNICAL STANDARDS

The following standards have been used in proposed methodology:

IEEE 2700-2014: Given the importance of a temperature sensor’s absolute accuracy as the
ambient environmental temperature reference in a sensor-fused awareness system (not device
temperature), it is very important to fully understand the primary contributors to absolute
temperature error. The following parameters require thorough specification and are intended for
digital sensors only. Note that these parameters should also be applied to temperature sensors
that are integrated into other sensors, are often used for thermal compensation, and are exposed
to the user [13].
 FSR
 Digital bit depth
 Absolute temperature error
 Sensitivity
 Noise
 Current consumption
 Integral non-linearity
 Transition time.

ANSI/ASHRAE Standard (ANSI/ASHRAE 135-2014) The purpose of Standard 135 is to


define data communication services and protocols for computer equipment used for monitoring
and control of HVAC and other building systems and to define, for application interoperability,
an abstract, object-oriented representation of information communicated between such
equipment, thereby facilitating the application and use of digital control technology in buildings
[14].

12 | P a g e
CHAPTER-3
DESIGN METHODOLOGY
3.1 PROPOSED WORK FLOW/ METHODOLOGY
The proposed work flow is given in Fig. 3.1.

Fig. 3.1 Work package

A system that is able to control the temperature, the amount of humidity, smoke amount (if any
or in case of fire) and the lighting intensity or the switching of lights automatically without
actually interacting with any physical buttons which is the main purpose of developing home
environment control. This system would be smart enough to differentiate what the person
demands and what not. For example, if the person demands that the fan should run at full
intensity, however the system/sensor output says that the fan should run at some lower intensity,
the system must be smart enough that it prioritizes the human needs rather than its own logical
functioning based on its computations.

In order to design such a smart system the following steps are to be taken (the model is
confined to the working of a single room):

13 | P a g e
Work Package 1 –

 The system designed uses a communication protocol which enables the interaction
between a mobile phone and the automation control system.
 The mobile application that will be used will provide a flexible control between manual
and automatic (feedback of sensors used) switching of home appliances.
 The communication between mobile and system can be established using HC-05 module
at the receiving end of the system which provides a standard Bluetooth communication
range from within a building. The communication protocols used are as per with the
standard ANSI/ASHRAE 135 standard [14].

The android application will be developed on MIT App Inventor which is an intuitive, visual
programming environment that allows everyone to build fully functional apps for smart phones
and tablets.

Work Package 2 –

Fig. 3.2 Working methodology of project

 Mobile application that is developed for the system provides 2 way control –
1) Manual switching of appliances

14 | P a g e
2) Intensity, speed control of appliances using sensors feedback.
3) The sensor will record the temperature of room in the range (-55°C to 125°C) as
described in section 12.1-21.3 of IEEE standard 2700-2014 [13].
 If the input given is set to manual mode then there is no control over the intensities, speed
of the appliances. This method of switching is similar to the traditional way of turning
ON/OFF a device using a physical switch.

If manual mode is not selected it implicitly positions the system into automatic control mode,
the operation of the automatic control mode is governed by the sensors inputs and the sensors are
located at various locations in the room. In the automatic control mode the sensor inputs are
relayed to the Arduino, further the Arduino controls the intensity/speed of the home appliances
based on the code integrated into it. This control is depicted in fig. 3.2.

Work Package 3 –

 The proposed system has a single Arduino board on which the entire voltage controller
circuitry and the Bluetooth module are mounted. The Bluetooth module uses the TX and
RX pins of Arduino for communication that are used as described in section H.2.1 of
ANSI/ASHRAE 135 standard [14]. The Smartphone application will give the user an
option to choose between manual mode and automatic mode.
 The voltage control operation is carried out using a combination of optocoupler, Triac,
and ZCD.

The voltage varying procedure is carried out by using pushbutton (in earlier stages) and sensors
(in latter stages). On pressing the pushbutton the digital signal sent to the optocoupler is varied.
This optocoupler input produces an equivalent output which is then fed to the gate of the triac
BT136. The major purpose of using an optocoupler is to provide a firing pulse to the gate of the
Triac and also to isolate the main 220V circuitry from the controlling circuitry .The firing pulse
is varied by giving a time delay through the arduino. The major purpose of installing a ZCD is
that it will set a reference point for firing time delay for each and every half cycle of the AC
wave sinusoid and from thereon it will start the time delay and once the time delay has been
completely the triac gets fired. As the triac is connected to the AC supply, varying the firing

15 | P a g e
pulse of the triac implies a variation in the AC input to the appliance, this is how the voltage
given to the appliance is controlled or varied.

3.2 FLOW CHART OF THE SYSTEM

The project works in the following two modes as shown in Fig.3.3:

Mode 1: The Manual Mode

Mode 2: The Automatic Mode

USER INPUT
(Using
Smartphone)

Bluetooth Module
(HC05)

ARDUINO If = MANUAL
If = MANUAL
Speed intensity
control via
Bluetooth App

VOLTAGE
SENSOR INPUTS REGULATOR
If = AUTO CIRCUIT
Automatic control via
sensor inputs

APPLIANCE

Fig. 3.3: Flow chart of the system

16 | P a g e
The mode of operation is decided by the user. The user can select the mode from a smartphone
which has Bluetooth. The command sent by the user is received at the appliance by the Bluetooth
module (HC05) [15]. The operation of the appliance completely depends upon the user but by
default it works on automatic mode. The modes are explained as under:

The Manual Mode: The user can adjust the intensity/speed of light/fan according to his/her
desire. The manual mode does not take the inputs from the sensors and regulate the voltage
according to the embedded code.

The Automatic Mode: The mode in which the appliance works by default. The automatic mode
takes in the inputs from various sensors installed inside the room and regulates the voltage
according to the predefined levels.

Therefore the entire control is in the user's hands and the functioning of the device can easily be
switched over from a bluetooth enabled smartphone.

3.3 MATHEMATICAL ANALYSIS AND CALCULATIONS

Following calculations has been done to formulate the circuit:

 Gate resistor calculations:


Resistor placed here serves two purposes:
1. It limits the current going into the gate of the triac.
2. It causes the voltage to drop when the triac is on.

Its least value can be (for 220V AC),

R= (220∗ √2)/I, where I is peak value of current allowed in optocoupler photo-triac.


[3.1]

R= 220√2/1 = 311 ohms. Since I = 1A

So a resistor of 330 ohms (approximate) is used for the hardware.

 Calculation for resisters to be connected in series with bridge rectifier and 4N25 IC:

17 | P a g e
Since the maximum current that can pass through IC is 10 mA.

Required resistance ≥ V/I = 220V/10mA = 22 𝑘𝛺 (used in circuit = 30k𝛺)

 Calculation for resister to be connected at input side of MOC3021:

The maximum input rated current for MOC3021 = 50 mA, Output voltage from Arduino
= 5V

Required resistance ≥ V/I = 5V/50mA = 100 𝛺 (used in circuit = 220 𝛺)

 Calculation used for code:

The frequency of AC signal is 50Hz, each sinusoid wave thus takes 1000ms/50 = 20ms

There are two peaks in a wave that means after every zero detection there is a 10ms
period available to regulate. If the lamp is ignited at starting of wave, lamp will receive
full power and if it’s done at the end of wave then the lamp receives no power and should
if done at halfway the lamp receives half power.

 Calculation used for Temperature sensor:


Sensor used has a negative temperature coefficient which gives different values of
voltage to analog pin of Arduino, which is converted to discrete values of 0 to 1024
internally.
Sensor gives different values of voltages at difference of 10mV, therefore formula used to
calculate temperature in degree Celsius is:
Temperature = (value / 1024)* 500 [3.2]
{ * represents since it is connected to 5V source }

3.4 SIMULATION SETUP

Software used to simulate above circuit is Proteus 8, the circuit gave different levels of voltages
on pressing of pushbuttons connected to pin 4 and 5 of Arduino UNO.

18 | P a g e
Fig. 3.4: Simulation of voltage regulator circuit

Fig. 3.5: Waveform of voltage across lamp with first button press

19 | P a g e
Fig. 3.6: Waveform of voltage across lamp with complete firing

3.5 HARDWARE DESIGN

The following section describes the hardware and software aspects of project:

Voltage Regulator circuit

Fig. 3.7: Circuit used for voltage regulation

20 | P a g e
The following steps have been used in controlling the voltage:

Step 1: AC supply at 50 Hz is given to the bridge rectifier (as shown in fig. 3.7) which converts it
into pulsating DC at 100Hz frequency.

Step 2: The conversion of AC to pulsating DC will help the ZCD to recognize when the voltage
waveform crosses zero on the falling edge because 4N25 works on the principle of falling edge.

Step 3: whenever the ZCD detects the zero which occurs in every half cycle of AC, it sends a
signal to the interrupt pin of Arduino.

Step 4: Once the Arduino receives the Input from ZCD it starts a timer from that moment up to a
specified delay, after that time interval Arduino gives a signal to MOC3021 IC to fire the triac.

Step 5: The entire half wave of AC signal has been divided into 6 levels. Each level has a pre-
defined time delay which can be introduced using the Application designed.

Step 6: Mobile application communicates with Arduino using Bluetooth module (HC-05) using
serial communication protocol.

Software designed on MIT App Inventor:

 Interface design and coding of application was completed using MIT App Inventor which
provides code blocks that allow easy app development.

21 | P a g e
Fig. 3.8: Main screen of MIT App Inventor

 Buttons, textbox, images etc are added into main screen from the palette which is coded
in code blocks of app (as shown in Fig. 3.8).
 Text for label 1: This shows the status of bluetooth connectivity, in case bluetooth is
connected it shows status as “Bluetooth connected” and when the bluetooth is
disconnected then it shows status as “Bluetooth not connected”.
 Bluetooth Icon used here is used as a button to select device to which one wants to
connect.
 First strip of horizontal numbers from 1 to 6 gives the choice to select intensity of light
bulb and second strip of horizontal numbers give choice to vary speed of fan.
 A button is provided to switch between automatic and manual mode of working, in
automatic mode of working, temperature sensor is used to detect temperature and
accordingly decide speed of fan and the bulb is set to maximum intensity. In case of
manual mode of operation above shown screen appears which gives choice to send
intensity as required.

22 | P a g e
The functions used in the code blocks are as shown in Fig.3.9:

 Call Bluetooth client – it calls the Bluetooth of mobile to get ready to send any command
required to the connected Bluetooth module.
 Set button – it can be used to set the button’s visibility mode to true or false.
 Set label – it can be used to set text of inserted label.
 Set list picker – it can be used to select any image or button as a function of hidden
hardware used such as Bluetooth.

23 | P a g e
Fig. 3.9: Code Blocks

24 | P a g e
CHAPTER 4
RESULTS AND DISCUSSIONS

4.1 SIMULATION RESULTS


The procedure and the circuit of simulation is shown in art.[3.4] and art.[3.5]. The
simulation was carried out and realised on proteus software. On the execution of the circuit
and the program attached it was found that the intensity of the bulb is controlled. By pressing
the push buttons once (UP or DOWN), the intensity at which the bulb glows increase or
decreases by one step.
On further evaluation it was found out that the intensity can be increased and decreased
in 12 single press of the push button (This is just to simulate how the sensors would work
once implemented. The process is same but the input signal in this case was given by push
buttons and in the case of sensors it would be fed by the sensors.)

4.2 HARDWARE RESULTS


On realization of the circuit designed and simulated on the proteus software the intensity at
which the bulb glowed was changing by a simple push button click, control obtained was
smooth and without any flickering observed.

Fig. 4.1: Bulb intensity variation

25 | P a g e
The following results were drawn:
1) No button clicks (Zero intensity)
2) First UP button clicks (8.37% intensity)
3) Second UP button click (16.7% intensity)
4) Third UP button click (25.03% intensity)
5) Fourth UP button click (33.36 intensity)
6) Fifth UP button click (41.69% intensity)
7) Sixth UP button click (50% intensity)
8) Seventh UP button click (58.35% intensity)
9) Eighth UP button click (66.68% intensity)
10) Ninth UP button click (75.01% intensity)
11) Tenth UP button click (83.34% intensity)
12) Eleventh UP button click (91.67% intensity)
13) Twelfth UP button click (100% intensity or full intensity)
Using the same regulator circuit with motor gave satisfactory results by changing the speed of
motor as voltage was decreased by the steps designed. Using the six-step regulation for induction
motor results were obtained as shown in Fig.4.2 using results of Table 4.1:

250

200

150

Voltage
100

50

0
Step 1 Step 2 Step 3 Step 4 Step 5 Step 6

Fig. 4.2: Variation of voltage with number of steps

26 | P a g e
Table 4.1: Variation of Voltage with number of steps given
Step number Voltage (V)
1 233
2 228
3 212
4 150
5 80
6 4

4.3 INFERENCE DRAWN

The voltage level control for motor is done by varying rms value by varying firing angle
between 0 to 180 degrees. It was observed as expected from characteristics of induction motor
that its speed does not varies linearly with the change in voltage level. Speed of motor is
proportional to square of voltage but after reaching 80% of rated voltage nearly rated speed is
achieved, therefore on decreasing voltage to 80% value the change in speed is not significant but
after the voltage is decreased to less than 50% value, little decrease in voltage results in greater
change in speed of motor.
The sensitivity of sensor used was found to be very high, even with range of temperature from
-55 degree to 150 degree Celsius, accurate results were obtained. When tested on serial monitor
of PC sensor gave accurate values up to two decimal places. Despite the advantages of good
sensitivity it had a limitation that it is a dry bulb sensor, it does not take humidity into account
which plays a key role in determining real feel temperature.

4.4 JUSTIFICATION OF OBJECTIVE ACHIEVED

One of the objectives of the project was to achieve voltage regulation so that the voltage
supplied to the appliance is able to vary its intensity. This objective has been achieved as is
evident by the hardware design and results. The second objective was to achieve a way to vary
the voltage in a controlled manner. This objective was achieved by the use of microcontroller
and pushbuttons. In this case the intensity of voltage can be varied in 12 (one sided) pushbutton
clicks as described and shown in Fig. 4.1.

27 | P a g e
CHAPTER-5
CONCLUSIONS AND FUTURE WORK
5.1 CONCLUSIONS

After implementing proposed circuit design physically it was found that the intensity at which
the appliances work can be varied using a simple triac circuitry synched with a microcontroller.
System developed thus far is simple and reliable. The system currently works on application
designed on MIT app inventor which is providing operations of switching as well as speed
control of fan.

5.2 FUTURE WORKS

1) IOT IMPLEMENTATION: The connection is currently being done via Bluetooth module and
is not available via internet using Wi-Fi, without using Wi-Fi concept of IOT cannot be
implemented.

2) APPLICATION DEVELOPMENT: Current app is very basic and not very much suitable for
commercial production, it requires improvements in terms of interface and possibility of addition
of appliances in the system.

3) POWER EFFICIENCY IMPROVEMENT: The system developed so far induces a lot of


switching losses due to the triac-ZCD voltage controller. Developing a power efficient system is
an utmost necessity. Thus in future developing a power efficient model of the system is
necessary.

28 | P a g e
CHAPTER-6
PROJECT METRICS

6.1 CHALLENGES FACED AND TROUBLE SHOOTING

In early process of code development, method which was being tried was by letting an arduino
just open the triac for a number of microseconds, but it had a problem that it was unpredictable
during what part of sine wave the triac opens and therefore the dimming level was unpredictable.

During later stages of development, PWM pins of Arduino were used to fire gate of triac using
an IC having inbuilt zero crossing detector, but that also had limitation as it didn’t cut the wave
in its negative cycle and hence gave flickering of bulb.

To solve the problem of reference point for firing time an external zero crossing detector IC
4N25 was used which gave input to Arduino to set reference point to firing time.

To solve flickering issue a bridge rectifier was used which allowed phase cutting during
negative half cycle as well by converting it into a positive cycle. Since 4N25 IC used could
detect zero crossing on falling edge.

6.2 RELEVANT SUBJECTS

Table 6.1 shows the subjects which helped while executing and designing the complete project.

Table 6.1: Relevant subject in our curriculum

SUBJECT PORTION OF WORK USED


Analog Electronic Devices and TRIAC, optocoupler
Circuits(UEI201)
Power Electronics(UEE504) Voltage controller circuit
(TRIACs), ZCD
Microprocessor(UEI504)/ Arduino
Microcontroller(UEI845)
Switchgear And Protection(UEE603) Relaying operation

29 | P a g e
6.3 INTERDISCIPLINARY ASPECT

Portions of work that are linked with disciplines are as follows:

 Basic knowledge of micro-controllers and their interfacing (especially Arduino UNO


adopted from Electronics and communication branch
 Knowledge of electronic devices like ZCD, Optocoupler derived from Electrical and
Instrumentation branch.
 App development sourced from Computer department.

6.4 COMPONENTS USED

List of hardware components used:

1. Arduino UNO
2. IC MOC3021M (optocoupler)
3. IC 4N25 (ZCD)
4. 2KBP06 IC (Bridge Rectifier)
5. TRIAC BT136
6. HC05- Bluetooth Module
7. SPDT Relay
8. Resistors
9. Lamp load
10. Motor load

List of software’s used:

 Proteus 8
 Arduino IDE
 MIT App developer

30 | P a g e
6.5 BRIEF ANALYTICAL ASPECTS

 What sources of information did your group explore to arrive at the list of problems
which could be taken as the project?

On analysing the trends of the market, it was found that the needs of the consumers have
progressed from manually driven systems to semi automated or fully automated systems. The
industries nowadays depend completely upon automated systems and these industries completely
rely on the firms which provide them with such solutions. The trend of using automated systems
is now coming to the regular households but it comes a healthy cost. After considering the
trends, IEEE journals were taken into consideration and it was seen that there was a significant
rise in Automation Solution providers like Siemens, Schneider Electric etc.

 What analytical, computational and/or experimental methods did your project group
use to obtain solutions to the problems in the project?

After designing the circuit it was then transferred and executed upon Proteus software. The code
was developed on Arduino IDE. The circuit and the code were then combined on Proteus and
executed simultaneously and it worked perfectly.

On the hardware the same circuitry was installed and the Arduino was fed with the code. In the
beginning on testing the circuit it was found out that there were some glitches in the circuit. The
testing was carried out using multi- meter.

 Did the project demand demonstration of knowledge of fundamentals, scientific and/or


engineering principles? If yes, & when did you apply?

The project demanded a good amount of principles studied during the Engineering Course. It
required a basic knowledge of Power Electronics and Analog Electronics and Devices in order to
generate a phase cut AC waveform which was fed to the electrical appliances to make it work a
varying intensity. It used the basic knowledge of Microcontroller and Coding the Arduino for
making the AC wave of varying intensity possible.

 How did your group shares responsibility and communicate the information of
schedule with others in team to coordinate design and manufacturing dependencies?

31 | P a g e
The group comprised of four members from within the Electrical Batch (2014-2018). The group
members were conveyed their responsibilities either using phone calls or through the internet.
The group held meeting on regular basis to fix the agenda for the week and to estimate to what
content the work had been accomplished. The group even consulted their mentor in case of any
discrepancy in the project, any difficulty or even if some part of the project was executed
perfectly.

 What resources did you use to learn new materials not taught in class for the course of
the project?

The major resource that was used was the internet. The group got accommodated with the
Proteus software used for simulation. The group got familiar with the coding of Arduino using
tutorials available on the web regarding the syntax and the flow of code for arduino. Majority of
the subjects utilised were learnt during the normal academic curriculum for Electrical
Engineering course.

 Does the project make you appreciate the need to solve problems in real life using
engineering?

Engineering is field which has been dealing with problems of mankind and solving it with ease
starting from the development of the wheel to the development of the smartphone technology,
engineering has always provided solutions for the betterment of mankind. During the project the
group analysed the demand of the society of a completely automated household. The project
revolved around the automation system which could vary the intensity at which home appliances
work so as to form an ambient room environment depending upon the environment conditions
inside the room itself.

32 | P a g e
6.6 TEAM ASSESSMENT MATRIX

Evaluation of
Kanishak Karan Bajaj Yogesh Garg Jatin Raheja
Sharma
Evaluation Kanishak Sharma 5 4 4 3
By Karan Bajaj 4 5 3 3
Yogesh Garg 5 4 5 4
Jatin Raheja 5 5 5 5

6.7 WORK SCHEDULE

2-Feb-17 24-Mar-1713-May-17 2-Jul-17 21-Aug-17 10-Oct-17 29-Nov-17


Schematic Design

Code of Voltage Regulator

Reports & Presentation

Voltage Regulator Hardware Products

Voltage Regulator Hardware Implementation

Sensor Hardware Components

App Development and Communication Products

Final Testing

33 | P a g e
6.8 STUDENT OUTCOME (A- K) MAPPING:
Table 6.9: A-K Mapping
A2. Demonstrate and apply knowledge of This project illustrates the use of firing
fundamentals, scientific and/or engineering circuit, microcontroller and rectifiers
principles towards solving engineering and basic electrical components.
problems.
B3. Analyze and validate experimental results The results expected from theory of
using appropriate techniques. motors for speed control is verified
using obtained results.
D1. Share responsibility and information schedule Work has been divided into various
with others in team. segments everyone has done their part
and healthy discussion about each work
is accomplished timely.
E1. Classify information to identify engineering We have acknowledged the practical
problems. problems and their corresponding
solution in the need analysis of project
E3. Use analytical, computational and/or Analytically we have designed different
experimental methods to obtain solutions. part of the circuit.
G1. Prepare and present variety of documents such Our team has presented the idea and
as project or laboratory reports and inspection report has been prepared.
reports with discipline specific standards.
H1. Aware of societal and global changes due to Automation is the most fast paced
engineering innovations. industry and its application on personal
level is the future. It will make lives of
people simple.
I1. Able to use resources to adopt new We have used Proteus and Arduino IDE
technologies not included in curriculum. software for simulation and coding
respectively.
J2. Recognize the impact of engineering decisions Using home automation system enables
on energy resources and environment. to save energy because the devices can
be turned off from anywhere thereby
reducing energy consumption. Energy
saved is energy generated thereby
reducing the stress on thermal power
plants to generate more electricity.
K3. Able to analyse engineering problems using The simulation model has been
software tools. developed and results have been
compared.

34 | P a g e
REFERENCES
1. S. Palinappan, N. Hariharan and N. T. Kesh, “Home automation systems-A study”,
International Journal of Computer Applications, vol. 116, no. 11, pp. 130-145, April 2015.

2. N. Sriskanthan and T. Karand, “Bluetooth Based home automation System”, Journal of


Microprocessors and Microsystems, vol. 26, pp. 281-289, June 2002.

3. A. Z. Alkar and U. Buhur, “An internet based wireless home automation system for
multifunctional devices”, IEEE Transactions on Consumer Electronics, vol. 51, pp. 1169-1174,
September 2005.

4. E. Yavuz, B. Hasan, I. Serkan and K. Duygu. “Safe and Secure PIC Based Remote Control
Application for Intelligent Home”, International Journal of Computer Science and Network
Security, vol. 7, no. 5, May 2007.

5. R. Shahriyar, E. Hoque, S. Sohan, I. Naim, M. M. Akbar, and M. K. Khan, “Remote


controlling of home appliances using mobile telephony”, International Journal of Smart Home,
vol. 2 pp. 37-54, May 2008.

6. R. Piyare and M. Tazil,“Bluetooth based home automation system using cell phone”, in Proc.
IEEE 15th International Symposium Consumer Electronics (ISCE), California USA, pp. 192-
195, June 2011.

7. D. Javale, Md. Mohsin, S. Nandanwar, and M. Shingate, “home automation and Security
System Using Android ADK”. International Journal of Electronics Communication and
Computer Technology, vol. 3, pp. 382-385, July 2013.

8. B. Pandya, M. Mehta and N. Jain, “Android Based home automation System Using Bluetooth
& Voice Command”, International Research Journal of Engineering and Technology, vol. 03,
Mar. 2016.

9. P. S. Bhimbra, “Power Electronics”, Khanna publications, New Delhi, Fifth Edition, 2014.

10. BT136 Series E, June 2001 – REVISED JULY 2009, Phillips semiconductor, [Online]
Available: http://www.circuitstoday.com/wp-content/uploads/2009/03/bt-136.pdf

11. LM35 Precision Centigrade Temperature Sensor, SNIS159G –AUGUST 1999 –REVISED
AUGUST 2016 [Online], Available: http://www.ti.com/lit/ds/symlink/lm35.pdf.

12. P.S. Bhimbra “Generalized Theory of Electrical Machines”, Khanna Publications, New
Delhi, Fifth Edition, 2014.

13. “IEEE standard for sensor performance parameter definitions” in IEEE Std 2700-2014,
pp.42-46, June 2014.

35 | P a g e
14. ANSI/ASHRAE Standard (ANSI/ASHRAE 135), December 30 2014 [Online], “A data
communication protocol for building automation and control networks” Available at
https://www.ashrae.org.

15. HC-05 Bluetooth to serial port module, Itead studio, June 2010 [Online], Available:
http://www.electronicaestudio.com/docs/istd016A.pdf.

36 | P a g e
ANNEXURES
Code used:
#include <TimerOne.h>
#define PINS 2
volatile int pinCount[PINS]; // make volatile to make available in interrupt
volatile boolean zero_cross=0; // Boolean to store a "switch" to tell us if we have crossed zero
int AC_pins[] = {11,12}; // Setup the pin numbers
int AC_dim[PINS]; // Holds Dimming levels (0-128) 0 = on, 128 = 0ff
int freqStep = 78; // Set the delay for the frequency of power (65 for 60Hz, 78 for 50Hz) per step (using 128
steps)
char Received=0; // freqStep may need some adjustment depending on your power the formula
// you need to us is (500000/AC_freq)/NumSteps = freqStep
int mode = 0; //to set automatic or manual mode
int lm35 = A0;

void setup() {
for(int a=0; a < PINS; a++) { //set the pins to output
pinMode(AC_pins[a],OUTPUT);
pinCount[a] = 0; // keeps track of the time in the cycle
AC_dim[a] = 0; // dimming level set to zero
}
attachInterrupt(0, zero_cross_detect, FALLING); // Attach Interrupt to Pin 2 (interrupt 0) for Zero Cross Detection
Serial.begin(9600);
Timer1.initialize(freqStep); // Initialize TimerOne library for the freq we need
Timer1.attachInterrupt(dim_check, freqStep); // Use the TimerOne Library to attach an interrupt
// to the function we use to check to see if it is
// the right time to fire the triac. This function
// will now run every freqStep in microseconds.
}
void zero_cross_detect() { // function to be fired at the zero crossing
zero_cross = 1; // set flag to tell dimming function zero cross has occured
} // End zero_cross_detect

void dim_check() { // Function will fire the triac at the proper time
if(zero_cross == 1) { // First check to make sure the zero-cross has happened else do nothing
for(int a=0; a < PINS; a++) {

37 | P a g e
if(pinCount[a] >= AC_dim[a]) { // Check and see if i has reached the dimming value we want
digitalWrite(AC_pins[a], HIGH); // Fire the Triac
delayMicroseconds(5); // Pause briefly to ensure the triac turned on
digitalWrite(AC_pins[a], LOW); // Turn off the Triac gate (Triac will turn off at the next zero cross)
pinCount[a] = 0; // Reset the accumulator
zero_cross = 0; // Reset the zero_cross so it may be turned on again at the next zero_cross_detect
} else {
pinCount[a]++; // If the dimming value has not been reached, increment the counter
}
}
}
}
void loop() {
if (Serial.available() > 0)
{
Received = Serial.read();

switch (Received)
{
case 'Y': mode = 1;
break;
case 'Z': mode = 0;
break;
}

if (mode ==0)
{ if(Received == 'A' ||Received == 'B' ||Received == 'C' ||Received == 'D' ||Received == 'E' ||Received == 'F')
switch(Received)
{
case 'A': AC_dim[0] = 0;
break;
case 'B': AC_dim[0] = 25;
break;
case 'C': AC_dim[0] = 50;
break;
case 'D': AC_dim[0] = 75;
break;

38 | P a g e
case 'E': AC_dim[0] = 100;
break;
case 'F': AC_dim[0] = 127;
break;
}
else if(Received == 'G' ||Received == 'H' ||Received == 'I' ||Received == 'J' ||Received == 'K' ||Received == 'L' )
switch(Received)
{
case 'G': AC_dim[1] = 0;
break;
case 'H': AC_dim[1] = 30;
break;
case 'I': AC_dim[1] = 35;
break;
case 'J': AC_dim[1] = 50;
break;
case 'K': AC_dim[1] = 80;
break;
case 'L': AC_dim[1] = 127;
break;
}
}
else if(mode == 1)
{
AC_dim[0]=127;
int analogvalue;
float temperature;
analogvalue = analogRead(lm35);
temperature = float(analogvalue)/1023;
temperature = temperature*500;
if(temperature > 35)
{ AC_dim[1]=127;
delay(1000);
}
else if(temperature >28)
{ AC_dim[1]=80;
delay(1000);

39 | P a g e
}
else if(temperature >24)
{ AC_dim[1]=50;
delay(1000);
}
else if(temperature >20)
{ AC_dim[1]=35;
delay(1000);
}
else if(temperature <20)
{ AC_dim[1]=0;
delay(1000);
}
}
}
}

40 | P a g e
Specification Sheets
1. Songle Relay

Coil Data chart ( at 20 degree celcius)

Contact ratings

41 | P a g e
2. LM35 Precision Centigrade Temperature Sensors

Absolute Maximum Ratings

Recommended operating conditions

42 | P a g e
3. MQ-2 Semiconductor based smoke detector

43 | P a g e
4. MOC3021M 6 Pin Triac Driver output optocoupler IC

Absolute maximum ratings :

44 | P a g e
5. BT136 – triac

45 | P a g e
6. 4N25 IC

46 | P a g e
47 | P a g e

You might also like