Documente Academic
Documente Profesional
Documente Cultură
Prepared by
A report submitted
In fulfilment of the requirements for the degree of
Bachelor of Engineering (Honours) (Computer and Communication Engineering)
Page
TABLE OF CONTENTS i
ABSTRACT iv
ABSTRAK v
ACKNOWLEDGEMENT vi
LIST OF FIGURES ix
LIST OF ABBREVIATIONS x
CHAPTER 1 INTRODUCTION
1.1 Background 1
1.3 Objective 2
CHAPTER 2 METHODOLOGY
i
Page
2.1.1.3 DC Motor 8
2.1.1.5 AC Lamp 9
2.1.2.3 Firebase 11
3.1 Results 16
3.2 Discussion 22
ii
Page
CHAPTER 6 CONCLUSION 28
REFERENCES 29
APPENDICES
iii
ABSTRACT
Recently, there is a case that is happening inside the university campus that is
troubling the establishment. That case is the wastage of electrical energy. This happens
because students are unaware of the importance of saving energy, hence they leave the lecture
rooms without turning off the lights and fans. In order to solve the case, the university can
implement the Automatic Control System for the lecture room. This system is not only
limited to lecture rooms but it could also be implemented at the residential college. The
system consists of a NodeMCU board, an IR sensor module, a DC motor, an AC lamp, a DC
motor driver, a 4-Channel 12V Relay module and it also uses IoT for data storage.
iv
ABSTRAK
Sejak kebelakangan ini, terdapat satu kes yang berlaku di dalam kampus universiti
yang membimbangkan pihak universiti. Kes tersebut adalah pembaziran tenaga elektrik. Hal
ini berlaku kerana pelajar-pelajar universiti tidak menyedari tentang kepentingan menjimat
penggunaan tenaga dan secara tidak langsung mereka meninggalkan bilik kuliah tanpa
mematikan lampu dan kipas. Bagi menyelesaikan kes ini, universiti perlu menggunakan
Sistem Pengawalan Automatik untuk bilik kuliah. Sistem ini juga boleh digunakan di kolej
kediaman. Sistem ini terdiri daripada NodeMCU, modul sensor inframerah, motor berkuasa
DC, lampu berkuasa AC, pemandu motor DC, modul relay 4-Saluran 12V dan IoT untuk
penyimpanan data.
v
ACKNOWLEDGEMENT
First and foremost, we would like to thank Universiti Malaysia Perlis (UniMAP) and
the School of Computer and Communication Engineering (SCCE) for giving us this
opportunity to practice the knowledge we had gained throughout the years of study into a
real-life situation.
Besides that, the greatest gratitude goes to our supervisor, Madam Sabarina Ismail
for the valuable guidance and advice till the day of finishing this project. Under her
supervision and help, we were able to solve the problems occurred when carrying out this
project and at the same time we gained a lot of precious knowledge. We also would like to
thank all of our friends that have been helping us to make this project successful.
Furthermore, many thanks go to all team members for the great teamwork in finishing
this Group Design Project. Last but not least, many thanks go to those who have helped us
out with their abilities directly or indirectly in completing this project.
vi
APPROVAL AND DECLARATION
This project report titled Automatic Control System for Lecture Room was prepared and
submitted by Azizul Elmey Bin Azizul El-Jeffry (171020888), Viknesvaran A/L
Chandrasekaran (161231466), Sharifah Marsya Miza Binti Syed Murtadza (151083410),
Muhammad Mukhzani Bin Azman Shah (171081324) and has been found satisfactory in
terms of scope, quality and presentation as partial fulfilment of the requirement for the
Bachelor of Engineering (Computer and Communication Engineering) in Universiti
Malaysia Perlis (UniMAP).
………………………………….
Project Supervisor
May 2019
vii
LIST OF TABLES
Page
viii
LIST OF FIGURES
Page
Figure 2.12 Flowchart of the Automatic Control System for Lecture Room 14
Figure 3.3 The side view of the prototype with circuit revealed 17
ix
Page
Figure 3.6 AC lamp and DC motor turns on after IN sensor detects input 19
Figure 3.8 AC lamp and DC motor turns off after OUT sensor detects input 20
LIST OF ABBREVIATIONS
IR Infrared
DC Direct Current
AC Alternating Current
x
CHAPTER 1
INTRODUCTION
1.1 Background
Nowadays, electricity is one of the important form of energy in human life. The
usage of electricity is increasing as people does not have the awareness of the importance
of electricity. Thus, this is the reason of increasing cost of managing, conserving and
distributing. This problem also occurs in UniMAP. Students always take things for
granted as they lack the awareness on how important it is for them to reduce the cost and
usage of electricity. The Automatic Control System for lecture hall will be created for
that purpose. From the previous case study, students or lecturers tend to leave the lighting
system and fan on unattended which is a waste of electricity. Based on this problem, this
project will be created by using a NodeMCU board and Android application for its
interface.
This project will be using an infrared sensor module which consists of two IR
sensors, one representing the “IN” sensor and one representing the “OUT” sensor.
Activation of the appliances in this project depends on the IR sensor readings. “IN” sensor
will cause the system to increment its counter while “OUT” sensor will decrement the
counter. The appliances will turn on when the counter value is more than 0. Counter
values in this project signifies the number of people present in the lecture room. The status
of the appliances will be sent to the Android application through the database.
Nowadays, the electricity issue is one of the important aspects that required for
every university. The current system is a manual system where users need to switch the
electrical appliances on when entering the lecture room and off before leaving. By
switching to an automatic system, consumption of energy and costing can be reduced by
50%.
1
The other problem is keeping track of lecture room status. The current system
requires guards to round the whole campus to check if any lecture rooms’ lights and fan
are left on while unattended. Using an application to monitor the lecture rooms remotely
with the use of IoT is the best way to solve this problem.
1.3 Objectives
This automatic control system for lecture room consists of 2 parts. The first part
is hardware development and software development as the second part. The scope of
project for this project are:
i. To develop hardware
- Software system that will be used for this project is an Android application
which is developed by us.
- The Android application will be interfaced with the hardware system
through the Firebase database system.
2
CHAPTER 2
METHODOLOGY
Figure 2.1 shows the block diagram of the Automatic Control System. The system
is controlled by a NodeMCU. The input of the project is the IR sensor module while the
DC Motor and AC lamp are the outputs. The system is displayed on an Android
application which was created using MIT app inventor. The system is connected to the
application through the Firebase database.
IR Sensor DC Motor
Module
AC Lamp
NodeMCU
Firebase Android
database Application
3
2.1.1 Hardware Description
NodeMCU is an eLua based firmware for the ESP8266 WiFi SOC from Espressif.
The firmware is based on the Espressif NON-OS SDK and uses a file system based on
spiffs. The code repository consists of 98.1% C-code. The NodeMCU was created shortly
after the ESP8266 came out. The ESP8266 in the NodeMCU is a self-contained WiFi
networking solution offering as a bridge from existing microcontroller to WiFi and is also
capable of running self-contained applications.
This NodeMCU comes with a built in USB connector and a rich assortment of
pin-outs. The pin definition of the NodeMCU is as shown in Figure 2.2.
4
The specifications of the NodeMCU board are as stated in Table 2.1.
Characteristics Descriptions
Operating voltage 3.3V
WiFi capability Wi-Fi Direct (P2P), soft-AP
Current consumption 10uA~170mA
Flash memory 16MB max (512K normal)
Processor Tensilica L106 32-bit
Processor speed 80~160MHz
RAM 32K + 80K
Number of GPIO 17 (multiplexed with other functions)
Analog to Digital pin 1 input with 1024 step resolution
+19.5dBm output power in 802.11b
Output power
mode
Maximum TCP connection 5
The cheapest way to remotely control a device within a visible range is via Infra-
Red light. Almost all audio and video equipment can be controlled this way nowadays.
IR sensor basically consist of an IR LED and a Photodiode, this pair is generally called
IR pair or Photo coupler. IR sensor work on the principal in which IR LED emits IR
radiation and Photodiode sense that IR radiation. Photodiode resistance changes
according to the amount of IR radiation falling on it, hence the voltage drop across it also
changes and by using the voltage comparator (like LM324), it can sense the voltage
change and generate the output accordingly.
The placing of IR LED and Photodiode can be done in two ways: Direct and
Indirect. In direct incidence, IR LED and photodiode are kept in front of one another, so
that IR radiation can directly falls on photodiode. If we place any object between them,
then it stops the falling of IR light on photodiode. Figure 2.3 shows IR sensor module in
direct incidence way.
5
Figure 2.3: Direct Incidence of IR sensor module
In Indirect Incidence, both the IR LED and Photodiode are placed in parallel (side
by side), facing both in same direction. In that fashion, when an object is kept in front of
the IR pair, the IR light gets reflected by the object and gets absorbed by photodiode. The
object should not be black as it will absorb all of the IR light, instead of reflecting it.
Generally, IR pair is placed in this fashion in IR sensor module. Figure 2.4 shows the
indirect incidence of IR sensor module.
Infrared is just a normal light with a particular colour. Humans cannot see this
colour because of its wavelength of 950nm which is below the visible spectrum. That is
one of the reasons why IR is chosen in this project for controlling purposes, we want to
use it but we are not interested in seeing it.
6
Another reason is because IR LEDs are quite easy to make, and they are very
cheap. IR LED looks like a normal LED and operates like one as well. It consumes 20mA
current and 3volts power. IR LEDs have light emitting angle of approximately 20-60
degree and range of approximately in few centimetres to several feets, it depends on the
type of IR transmitter and the manufacturer. Some transmitters have the range in
kilometres.
7
Figure 2.6: Pin Configuration of LM324
2.1.1.3 DC Motor
Small DC motors are used in tools, toys, and appliances. The universal motor can
operate on direct current but is a lightweight brushed motor used for portable power tools
and appliances. Larger DC motors are currently used in propulsion of electric vehicles,
elevator and hoists, and in drives for steel rolling mills.
In this project, a 3V DC motor is used to represent the fan in the class. Figure 2.7
shows the 3V DC Motor with a propeller attached to it.
8
2.1.1.4 L298N Heavy-Duty Dual H-Bridge Controller
The speed of the DC motor is controlled using the L298N heavy-duty dual H-
bridge controller. The L298N motor driver can be used to drive two DC motors at up to
2A each, with a voltage between 5 and 35V DC or one stepper motor with ease. The
controller has a heatsink to keep the L298N from overheating. It is powered with two AA
size 3.7V Li-on battery. Figure 2.8 shows the L298N Heavy-Duty Dual H-Bridge
Controller.
2.1.1.5 AC Lamp
This project uses a round shaped softone bulb as its light source. The AC lamp
consumes 40W power and 220-240V of voltage. The bulb is using an E27 base, meaning
it has a 27mm base diameter. The material of the AC lamp is made out of aluminium and
it has a frosted glass cover. The size of the bulb is 6cm in length and 10.5cm in height.
Figure 2.9 shows the AC lamp used in this project.
9
2.1.1.5 4 Channel 12V Relay Module
In this project, the AC lamp is connected to the NodeMCU through the 4-channel
relay module. Figure 2.10 shows the 4-channel relay module and Table 2.2 shows the pin
definition of the module.
10
2.1.2 Software Description
The Internet of things (IoT) is the extension of Internet connectivity into physical
devices and everyday objects. Embedded with electronics, Internet connectivity, and
other forms of hardware (such as sensors), these devices can communicate and interact
with others over the Internet, and they can be remotely monitored and controlled.
For this project, IoT is used to control the lamp and fan through the Android
application after the appliances are activated automatically through the sensors. The
system will send the status of the lamp and fan in the lecture room to the database as soon
as they are activated. The number of people in the lecture room is also sent to the database.
The android app will retrieve the information from the database through the Internet.
Arduino IDE is a cross platform application for Windows, Mac OS, Linux that is
written in programming language Java. It is used to compile and upload programs to an
Arduino board. It contains many project in its library that can be a guide for the users. It
supports language C and C++ using special rules of code structuring.
2.1.2.3 Firebase
11
2.2 Operational Circuit Design
Fig. 2.11 shows the circuit diagram of the Automatic Control system. The circuit
consists of two IR sensor modules, a DC motor, 4-channel relay module and an AC lamp.
The NodeMCU is connected to a power supply using a micro-USB cable. The DC motor
is connected to the L298N heavy-duty dual H-bridge controller. The L298N input pins
enA, in1 and in2 are then connected to the NodeMCU on ports D2, D3 and D4
respectively. The AC lamp is connected to the relay which is then connected to port D0.
The IR sensor modules are connected to the LM324 IC on pins 10 and 12. The output
pins 14 and 8 on the LM324 is then connected to the NodeMCU on ports D5 and D6.
Power supply
NodeMCU
12
2.3 Design Flow and Process Flow
There are two part of flowchart. The first part is the overall flowchart for the
program and the second one is the software flowchart. The project is explained through
the flow chart given step by step. The first flowchart shows the flow from initializing the
component until it is sent to the Firebase database. The second flowchart shows the flow
of software before it displays on the Android application.
The flowchart in Fig. 2.12 shows that the system needs to connect to WiFi first.
The system starts by making the IR sensor modules check for input. When the value of
the “IN” sensor is high, it indicates that a person has entered the lecture room. This will
then increment the counter. The system will then check the counter value, when the value
is more than 0, it will turn on the light and fan of the lecture room. When the value of the
“OUT” sensor is high, the system will decrement the counter. This indicates that a person
has left the lecture room. The system will turn off the light and fan when the counter value
is 0. Each time an appliance is turned on or off and there is an update on the counter value,
the system will send the all these statuses to the Firebase database.
13
Figure 2.12 Flowchart of the Automatic Control System for Lecture Room
14
Fig. 2.13 shows how the data of the system is displayed on the Android
application. Firstly, it needs to retrieve the data from cloud then store the data into
Firebase database. Data stored in the Firebase database is then sent to the Android
application to be displayed to its users. The data being displayed are the status of the light
and fan as well as the counter value.
15
CHAPTER 3
3.1 Results
16
Figure 3.3 The side view of the prototype with circuit revealed
Figure 3.1 and Figure 3.2 are the side and top view of the Automatic Control
System for Lecture Room. The IR sensors are placed at the door of the lecture room. The
IN sensor is on the outside of the prototype while the OUT sensor is on the inside of the
lecture room prototype. The AC lamp and fan is placed on one side of the lecture room
prototype. The area below of the prototype is used to keep the circuit as shown in Figure
3.3.
17
Figure 3.4 Circuit of the Automatic Control System
Figure 3.4 shows the complete circuit of the Automatic Control system. The
system uses NodeMCU, IR sensor module, DC Motor, L298N Heavy-Duty Dual H-
Bridge Controller, 4-Channel 12V Relay module and AC lamp.
The NodeMCU will connect to a WiFi network upon system startup. The IR
sensors will then begin scanning for obstacles in front of it. Once the IR sensor detects an
obstacle, it will send a signal to the NodeMCU to increment or decrement the counter.
The IN sensor will make the counter to increment its value when it detects an input while
the OUT sensor will make the counter to decrement its value. When the counter value is
equal to 1 or more, the AC lamp and DC motor will activate. The speed of the DC motor
varies according to the counter value. If the counter value is 0, the DC motor will be
turned off. If the counter value ranges from 1 to 5, the speed of the DC motor will be
LOW. Its speed becomes MEDIUM when the counter reaches the 6 to 10 range. The
speed is HIGH when the counter value is more than 10.
18
Figure 3.5 IN sensor detecting input
19
Figure 3.7 OUT sensor detecting input
20
The system uses Firebase database to store the status of the lamp and fan. The
counter value is also stored in the database as shown in Figure 3.7. The data stored in the
Firebase database is displayed on the Android application as shown in Figure 3.8.
21
3.2 Discussion
During the execution of the project, there are several issues encountered. One of
the issues is the NodeMCU’s 3.3V output is not enough to power up the L298N Heavy-
Duty Dual H-Bridge Controller, making the DC motor unable to turn on when it is
supposed to. The solution of this problem it by using with two AA size 3.7V Li-on battery
as the power supply for the L298N Heavy-Duty Dual H-Bridge Controller.
The original plan of this project was to use a website to display the data. The data
will be stored in the database from MySQL. PhpMyAdmin is used to create the database.
However, a problem occurs as the website could not establish a stable connection with
the hardware. Thus, the data could not be sent to the website that has been created
efficiently. Thus, Firebase database is used as the solution to store the data from the
system as it is much easier to connect to and use. The Android application is used to
display the data stored on the Firebase database.
During the creation of the Android application, the problem encountered is the
application is unable to read more than one type of data in from the database. To solve
this problem, the data stored in the database will be displayed as a string data type in the
application. Only the counter value is an integer data type.
22
CHAPTER 4
The main component of this project is the NodeMCU ESP8266 ESP-12E WiFi
Development board. In terms of safety aspect, the NodeMCU board is labelled with the
FCC and CE logo, as they meet the electromagnetic compatibility standards set in their
respective jurisdictions. NodeMCU ESP8266 ESP-12E WiFi Development board meets
the essential requirements of EU Directive 2001/95/CE General directive on products
safety and Directive 93/68/CE. Therefore, the system is safe and should not be harmful
to the users.
In this project there are several environmental impacts that had been considered,
such as type of sensor to control the usage of lamp and fan. As a conscious consumer, we
consider controlling the system by using a sensor in the lecture hall rather than manually
controlling the switch as it is much more convenient and less energy consumption. Thus,
it creates environmental awareness to the society. As we can see in our daily life, lamps
and fans are usually kept on even when we are not using it which caused energy wastage
and high energy costing. The solution for this problem is by using a sensor which detects
our body heat to control the system. The sensor works as the switch where it detects the
body heat to control the system. Besides that, this system is free from environmental
pollution as there is no usage of chemical in this project.
23
4.3 Cultural and Benefit to the Society
This project is designed to provide a better smart system demands for everything to be
automatically controlled. Installing a sensor to control the system can significantly reduce
lighting costs. The project could also benefit the society as it can help increase awareness
among society to save electrical energy which in turn, saves cost on electrical bills.
Besides that, the automatic control system can enhance the quality of life for the society
as it can be widely used. As the country is growing rapidly, the society also needs a
turning point instead of using a traditional switch system which users need to manually
turn on electrical appliances.
24
CHAPTER 5
PROJECT MANAGEMENT AND COSTING
The project starts at week 2 of this semester. The duration to finish this project is
14 weeks including report correction. The activities and week are divided as in Table 5.1
In producing the project, the total cost of completing the project is emphasized.
Based on the Table 5.2, it is proven that the project is affordable to anyone. Unfortunately,
this project is not suitable for commercialize yet. It needs a few upgrades before being
commercialized such as using a much more proper prototype and adding a temperature
sensor for the fan.
25
Table 5.1 Project Gantt Chart
Week
Activities
1 2 3 4 5 6 7 8 9 10 11 12 13 14
GDP briefing to
all
lecturers and
students
Talks on project
design to all
students
First meeting with
supervisor
Circuit Design
and
Report Writing
First GDP
Assessment
Second GDP
Assessment
GDP Technical
Report
Submission to
supervisors
GDP Presentation
/
Viva
GDP Technical
Report Correction
Final GDP
Technical
Report
Submission
26
Table 5.2 Project Costing
2. 3V DC Motor 1 - RM 2.00
5. 9W Bulb 1 - RM 5.00
27
CHAPTER 6
CONCLUSION
Automatic Control System is a system that provides automation to light and fan
switches. This project allows its users to save energy and costing by switching off all
electrical appliances when there are no people present in a room.
The project consists of two parts which are software and hardware. Software is
used to display the status of the electrical appliances in a lecture room as well as the
number of people present in the room. As for the hardware part, it consists of a NodeMCU
board as the microcontroller, an IR sensor module which consists of 2 sensors, one for IN
and one for OUT, to detect people coming in or going out, a DC motor to represent the
fan, an AC lamp as the light source, a DC motor driver to power the DC motor and a 4-
Channel 12V Relay module to supply power to the AC lamp. The project is successful
for both parts. The data obtained from the sensors are sent to the Firebase database
successfully. The status of the electrical appliances could be displayed on the Android
application successfully.
Future studies will focus on expanding the use of various types of electrical
appliances such as air conditioner or projector. Besides that, the project needs to
improvise on the way of controlling the fan speed. A temperature sensor could be used in
the future work to enhance the system’s automation capabilities.
28
REFERENCES
[3] Hanson Technology, “ESP8266 NodeMCU WiFi Devkit User Manual V1.2”,
2016 [Online]. Available: https://www.handsontec.com/pdf_learn/esp8266-V10.pdf
[Accessed: April 22, 2019]
[8] Constellation Energy Resources, “LED vs CFL Bulbs: Which is More Energy
Efficient?”, 2016 [Online]. Available: https://blog.constellation.com/2016/03/25/led-vs-
cfl-bulbs/ [Accessed: April 16, 2019]
[10] Business Today, “Signify Lights Up Malaysia’s IoT Platforms”, 2018 [Online].
Available: https://www.businesstoday.com.my/2018/11/16/signify-lights-up-malaysias-iot-
platforms/ [Accessed: April 16, 2019]
29
APPENDICES
30
31
32
33
APPENDIX B: Application Block Code
34