IoT Home Automation With HMI
IoT Home Automation With HMI
HMI
This paper has been submitted to the department of Electrical &
Electronic Engineering of European University of Bangladesh in partial
fulfillment of the requirement for the degree of Bachelor of Science in
Electrical and Electronic Engineering.
SUBMITTED BY:
SUPERVISED BY:
To
The Supervisor
Department of EEE
European University of Bangladesh
Mirpur-2, Dhaka-1216.
Dear Sir,
Please find enclosed the project report entitled IoT Based Home
Automation with HMI. The study has been carried out in partial fulfillment
of the requirements for the degree of Bachelor of Science in Electrical &
Electronic Engineering.
In carrying out the study, I/we have followed supervisor’s advice and
collected required information from several text books, reference books, web
sites and other sources. I/we think you will find it useful and informative.
I/we would be glad to furnish you further explanations or clarifications if
required.
Sincerely yours,
______________
Nayan Kumar Pal
I.D: 180116456
______________
Md Monir Bepari
I.D: 180116471
______________
Tanmoy Barai
I.D: 170216541
______________
Milon Malakae
I.D: 180116462
Declaration
ii
We do hereby solemnly declare that the work presented in this report entitled
IoT Based Home Automation with HMI has been carried out by me/us and
has not been previously submitted to any other university, college or
organization for an academic qualification, certificate or diploma/degree.
I/We hereby warrant that the work that has been presented here does not
breach any existing copyright. I/We further undertake to indemnify the
university against any loss or damage arising from breach of the foregoing
obligations.
Author/s
______________
Nayan Kumar Pal
I.D: 180116456
______________
Md Monir Bepari
I.D: 180116471
______________
Tanmoy Barai
I.D: 170216541
______________
Milon Malakae
I.D: 180116462
iii
This is to certify that the report entitled IoT Based Home Automation with
HMI is the valid record of the work done by _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ for partial fulfillment of the requirement of the degree
of B.Sc. in Electrical and Electronic Engineering (EEE) from European
University of Bangladesh.
This work has been carried out under my guidance and is a bonafide record
of valid works carried out successfully.
Faculty Guide
___________________
Ashrafun Nushara Oishi
Lecturer
Department of Electrical and Electronic Engineering
Acknowledgement
iv
I/We would like to express my/our greatest gratitude to the people who helped and
supported me/us throughout this work. First and foremost I/we would like to thank my/our
honorable supervisor, Ashrafun Nushara Oishi, Lecturer, Department of EEE, for giving
me/us enormous support, advices and valued guidance concerning this thesis.
I/We am/are grateful to A. O. M. Abdul Ahad, honorable Chairman, Department of EEE,
Faculty of Engineering, European University of Bangladesh (EUB) for his comments,
encouragement and support.
I/We am/are grateful to my/our respected coordinator Sourav Barua, Lecturer,
Department of EEE, Faculty of Engineering, European University of Bangladesh (EUB)
for kindly agreeing to examine my thesis.
Next, I/We would like to thank my/our family and friends for their valuable support to
complete this thesis.
Finally, I/we would like to express my/our heartiest gratefulness to Almighty Allah for His
heavenly blessings. Without his blessings it would not possible to complete my/our work
successfully.
Executive Summary
v
Home automation needs to make use of modern technologies to reduce human efforts as
well as save energy. This paper focuses on the development of an embedded system for
home automation system that use standard remote controller, temperature, humidity and
touch screen as a user input device. The inconvenience in controlling the home devices has
been solved by this home automation system. In this proposed home automation system
different attractive features are combined together which is not found very often in other
home automation system. This offers a low cost, complete and efficient system for remote
operation of a room. Furthermore, this system can be applied to control all kinds of
appliances automatically installed within buildings, companies, schools, hospitals and so
on.
Table of Contents
Letter of Transmittal II
Declaration III
Certificate IV
vi
Acknowledgement V
Executive Summary VI
List of Figures X
List of Tables XI
1.1 Introduction 1
1.2 Historical Background 1
1.3 Home Automation 3
1.4 IoT Based Home Automation 4
1.5 Objectives 4
1.6 Literature Review 4
1.7 Project Book Outline 5
2.1 Intoduction 7
2.2 Working Procedure of IoT 7
2.3 Advantages of IoT 8
2.4 Application of IoT 10
2.5 Summary 11
3
3.1 Introduction 13
3.2 Required Components 13
3.3 Arduino Uno 13
3.3.1 Features 13
3.3.2 Pin Configuration 14
3.4 Esp8266 15
3.4.1 Features 16
3.4.2 Pin Configuration 16
3.5 3.5 Inch Touch Screen Display 17
3.5.1 Features 18
3.5.2 Pin Configuration 19
3.6 4 Channel Relay Module 20
3.6.1 Features 20
3.6.2 Pin Configuration 21
3.7 12V Power Supply 21
3.8 Arduino IDE 22
3.9 Blynk App 23
vii
4.1 Introduction 25
4.2 Block Diagram 25
4.3 Flowchart 26
4.4 Circuit Diagram 27
5
5.1 Introduction 29
5.2 Result 29
5.3 Project Outlook 29
5.4 Advantages 29
5.7 Cost Analysis 30
6
6.1 Discussion 32
6.2 Future Work 32
6.3 Conclusions 32
References 33-33
Appendix I 34-38
Appendix II 39-50
viii
LIST OF FIGURES
ix
LIST OF TABLES
x
Chapter 01
Introduction
1
1.1 Introduction
Nowadays home automation system is being widely used to control devices around the
home. A variety of home devices can be controlled with the help of a home automation
system. All kinds of home appliances like doors, lights, fan, electric heater, surveillance
systems, and consumer electronics belong to the home automation system devices [1].
Home automation system is adopted by using the technology available for the purpose of
controlling the devices as well as the systems used in the home automatically. The system
used for improving the quality of resident’s life is regarded as home automation system.
Actually home automation system is a house or living environment. To support the elderly
and the disabled people; remote and local control are useful to ease human effort [2]. For
making the home automation easy, the control of all the devices should be brought in one
place. To do this several works have been done. But there are some obstacles to be
overcome for making the home automation system easier and popular; these are high cost
of ownership, inflexibility, poor manageability, and difficulty in achieving security [3].In
Java based home automation system, a complex and costly installation and is needed. The
requirement of a high end PC makes the system expensive. In this system, remote control
of the devices is provided through integration with a personal computer (PC) based web
server, in which with all the devices an embedded board is physically connected. For this
individual connection the system becomes intrusive although it provides a safe solution
[4]. In a Bluetooth based home automation system, a primary controller and a number of
Bluetooth sub-controllers are used. The physical connection is needed between the local
Bluetooth and sub-controller. The devices to be controlled make their communication
with sub controller via a wired media. The problem of this system is the time delay,
because of the sharing a single Bluetooth module by many devices to be controlled [5]. In
a phone based remote controller for home and office automation, the system suffers from
the problem of flexibility. Because users have to remember an access code. In a control
network, using hand gestures, the controller uses a glove to relay hand gestures to the
system. The problem of this kind of system is the lack of security. In the 21st century the
use of the remote controller has been increased in a wide range because of the convenience
and easiness of its use. The use of remote controller has been started to most of all the
devices in the home or in the industrial devices. In addition, for home automation such as
lighting and temperature control, door management, and security, remote controllers have
been developed. The convenience of controlling the home devices without remote
controller cannot be imagined. So here in this paper we designed and implemented a
remote controlled home automation system with different features [6]. In this paper, we
present a home automation system which is remote controlled as well as touch screen
controlled. Besides normal load on/off, regulation of the load, control of temperature and
humidity are the major concerns of our work. For saving the energy, automatic load off is
done by sensing the presence of personal. Through this system, we could open and close
the door automatically. Overall, the system is able to overcome the usual four obstacles in
the home automation system.
Home automation is building mechanization for a home, called a smart home. It includes
the control and computerization of lighting, warming, (for example, brilliant indoor
regulators), ventilation, aerating and cooling (HVAC), and security, and also home
machines, for example, washer/dryers, stoves or fridges/coolers. Wi-Fi is regularly utilized
2
for remote checking and control. Home devices, when remotely observed and controlled
through the Internet, are an essential constituent of the Internet of Things. Smart homes
constitute a branch of ubiquitous computing that involves incorporating smartness into
dwellings for comfort, healthcare, safety, security, and energy conservation. Early home
automation began with labour-saving machines. Self-contained electric or gaspowered
home appliances became viable in the 1900s with the introduction of electric power
distribution [1] and led to the introduction of washing machines (1904), water heaters
(1889), refrigerators, sewing machines, dishwashers, and clothes dryers. In 1975, the main
broadly useful home computerization arrange innovation, X10, was created. X10 is a
communication protocol for electronic devices. It basically utilizes electric power
transmission wiring for flagging and control, where the signs include brief radio
recurrence blasts of advanced information, and remains the most broadly available. [2] By
1978, X10 items incorporated a 16channel charge support, a light module, and an
apparatus module. Not long after came the divider switch module and the primary X10
clock. By 2012, in the United States, as indicated by ABI Research, 1.5 million home
mechanization frameworks were installed. [3] As per Li et al. (2016) there are three
generations of home automation: [4] First generation: remote innovation with intermediary
server, e.g. ZigBee robotization. Second generation: artificial brainpower controls
electrical devices, e.g. Amazon Echo; Third generation: robot buddy who associates with
human, e.g. Robot Rovio, Roomba. Smart homes enhance traditional security and safety
mechanisms by using intelligent monitoring and access control. According to the World
Health Organization (WHO), 650 million people live with disabilities around the world
[5]. It is not possible or logical to support all of these patients in medical centre or nursing
homes for an uncertain period of time. The solution is to accommodate healthcare services
and assistive technologies in patients’ home environment. This paper is a survey on smart
home projects, which are arranged according to their intended services. It also discusses
the significance and limitations of smart home components and the various technologies
used in home automation. It explains the current trends of smart home research and future
challenges that must be overcome to design a feasible smart home.
Home automation or domotics is building automation for a home, called a smart home or
smart house. A home automation system will monitor and/or control home attributes such
as lighting, climate, entertainment systems, and appliances. It may also include home
security such as access control and alarm systems.
3
1.4 IoT Based Home Automation
The IoT devices in Home Automation have the maximum applications in energy. The
home heating devices are able to control the temperature with the devices like laptops,
tablets or smart phones and all of these appliances, systems, and devices contain sensors
that connect them to a network.
1.5 Objective
The main objective of this Paper is to design and implement a control and monitor system
for smart house. Smart house system consists of many systems that controlled by Lab
VIEW software as the main controlling system in this paper. Also, the smart house system
was supported by remote control system as a sub controlling system. The system also is
connected to the internet to monitor and control the house equipment’s from anywhere in
the world using Lab VIEW.
In IoT based home automation with HMI system the home appliances are connected to the
Arduino board at input output ports using relay. The program of Arduino board is based
on high level interactive C language of microcontrollers; the connection is made via Wi-Fi
using Wi-Fi Module. The password protection is provided so only authorized user is
allowed to access the appliances. The Bluetooth connection is established between
Arduino board and phone for wireless communication. One circuit is designed and
implemented for receiving the feedback from the phone, which indicate the status of the
device.
4
1.7 Project Book Outline
Chapter 1:
Gives a brief discussion of the project introduction, project objectives, project motivation
and history.
Chapter 2:
Focuses on the technology we used.
Chapter 3:
Focuses on hardware we used, their theoretical background and applications. Each
hardware’s detail. How the hardware works. How the hardware can be implementation.
Chapter 5:
Focuses on experimental result. How we gave our best result from our project that
described in this chapter. Also we showed all the results visual here.
Chapter 6:
Concludes overall the project. And advantages of this project. How this project will give
it’s best in our daily life.
5
Chapter 02
IoT Technology
6
2.1 Introduction
Presently there is a globally growing demand across all industries for small and portable
electronic devices which feature Internet connectivity. This is largely due to their ease of
use provided by robust interoperability and feasibility in almost any scenario. Internet of
Things (IoT) can be a great tool to achieve this goal of connecting people and devices
everywhere all the time. IoT is a network of various types of devices connected together to
seamlessly data transfer without any computer or human interaction. IoT can be defined as
a network consisting of many small sensor nodes whose main purpose is to collect data
from surrounding environment and then forward to the base station.
7
2.3 Advantages of IoT
Let’s look at several ways SMBs can leverage the future of the Internet of Things and its
cutting-edge technology to improve critical aspects of business.
1. Cost reduction: The more businesses use IoT devices to streamline operations and
increase profitability, the more Internet of Things technologies will be tailored to
help those businesses succeed. From cybersecurity to workplace efficiency, IoT
devices are already making an impact on companies’ bottom lines. Maintenance
costs can be positively impacted when IoT devices are used with sensors to keep
business equipment running at peak efficiency. On-the-fly troubleshooting of
office equipment catches problems before they impact staff and employees, saving
the hassle and costs of large repairs. This minimizes costly extended downtime for
repairs—just one of the benefits the Internet of Things brings to your operations
and maintenance workflow. As you can imagine, this technology is extremely
useful to businesses in the manufacturing, logistics, and food and beverage sectors
to name a few. There are also numerous ways to use IoT technology to favorably
impact your bottom line through streamlining common working processes, a top
driver of IoT investment for many companies. What the stats say about cost
reduction Cost reduction as a result of Internet of Things implementation is most
prevalent in certain industries, particularly manufacturing. For example, a study by
Deloitte found that predictive maintenance (PdM) can reduce the time required to
plan maintenance by 20–50%, increase equipment uptime and availability by 10–
20%, and reduce overall maintenance costs by 5–10%. Naturally, for a
manufacturer, cutting costs in this manner is exceptionally beneficial, and while
these types of industries are benefitting the most from IoT adoption, there are also
clear benefits for the vast majority of SMBs, regardless of industry. This is often
the case when it comes to reducing labor costs by improving process efficiencies.
83% of organizations that have introduced IoT technology have improved their
efficiency by doing so, reducing their expenditures and bettering output from
employees. McKinsey estimates that activity monitoring can improve productivity
by 10-12%, essentially meaning more bang for the business’ buck. Number of
Internet of Things devices worldwide in billions.
2. Efficiency & productivity: Efficiency is the basis for the kind of improved
productivity that boosts revenue for SMBs. One way to leverage the power of IoT
to increase company efficiency is to use it to cut down on repetitive or time-
consuming tasks. An example IoT function for this strategy would be an automated
PDF conversion and creation tool that removes the obstacles to PDF editing and
archiving, increasing communication and documentation speeds. These IoT tools
increase the kind of inter/intra-office communication that results in better
productivity. In fact, according to a survey conducted by Harvard Business
Review, 58% of companies are seeing increased collaboration through the use of
IoT devices. In the work environment, IoT can be used to optimize an office floor
plan and mobilize company resources—like copiers, printers, and WiFi bandwidth
—for a better workflow and a more streamlined and effective approach to
management. Finally, using big data analytics through IoT can provide an
overview of employee productivity and help determine what tasks are improving
the function of your business—and which are impairing it. Big data can also be
8
instrumental in tracking efficiency for manufacturing supply chains. You can
follow delivery systems and monitor products and inventory to stay ahead of
demand. Related Post: Supply Chain Disruption: Mitigating Threats Effectively
with Analysis Additionally, you ensure that your hardware and software are
appropriately connected to provide service without lag time to employees and
customers. What the stats say about efficiency As we previously mentioned, many
of the benefits IoT implementation delivers has knock-on effects—improving your
workforce’s productivity means reducing overall labor costs. A study by Aruba
found that 46% of businesses that adopted IoT strategies experienced efficiency
gains, despite the fact that only 29% expected such gains in the first place. While
those figures may seem low, it’s worth noting that many of these businesses may
not have anticipated the efficiency gains they reported, and their initial intentions
for implementation were more aligned with general modernization of their
processes rather than a specific focus on improving the efficiency of a particular
task. In other words, the efficiency benefits gained can be unintended
consequences of upgrading organizational processes, but are very welcome
nonetheless. 78% say the introduction of IoT in the workplace has improved the
effectiveness of their IT team, and 75% find it has increased profitability. IoT is
widely adopted and beneficial
4. Customer experience: While IoT technology has so far mostly influenced back-end
processes because of its relatively new presence, today’s IoT has meant that omni-
channel strategies have completely upended the way consumers approach their
relationships with businesses. Front-end customer engagement has become a
priority for organizations as they look to engage better with their audiences,
usually through IoT devices. Customers in 2020 have an expectation towards
businesses that must be met; namely that they want to be able to interact with you
through their phone, whether that’s using an automated chatbot or dedicated app.
40% of consumers do not care whether a chatbot or a real human helps them, as
long as they are getting the help they need. Because of this, forward-thinking
businesses are using new technology and combining it with the IoT to better serve
their customers.
9
2.4 Applications of IoT
3. Traffic monitoring. The Internet of things can be very useful in the management of
vehicular traffic in large cities, contributing to the concept of smart cities. When
we use our mobile phones as sensors, which collect and share data from our
vehicles through applications such as Waze or Google Maps, we are using the
Internet of Things to inform us and at the same time contribute to traffic
monitoring, showing the conditions of the different routes, and feeding and
improving the information on the different routes to the same destination, distance,
estimated time of arrival.
5. Agriculture. Smart farms are a fact. The quality of soil is crucial to produce good
crops, and the Internet of Things offers farmers the possibility to access detailed
knowledge and valuable information of their soil condition. Through the
implementation of IoT sensors, a significant amount of data can be obtained on the
state and stages of the soil. Information such as soil moisture, level of acidity, the
10
presence of certain nutrients, temperature and many other chemical characteristics,
helps farmers control irrigation, make water use more efficient, specify the best
times to start sowing, and even discover the presence of diseases in plants and soil.
2.5 Summary
11
Chapter 03
Hardware
And
Software
12
3.1 Introduction
In this chapter we are going to describe our all equipment. Which we have used in our
project.
1. Arduino Uno
2. ESP 8266
3. 3.5 Inch TFT Display with Touch Screen
4. 4 Channel Relay Module
5. 12V Power Supply
13
Microcontroller ATmega328P – 8 bit AVR family
microcontroller
Operating Voltage 5V
SRAM 2 KB
EEPROM 1 KB
14
microcontroller and other
components on the board.
3.3V: 3.3V supply
generated by on-board
voltage regulator.
Maximum current draw is
50mA.
GND: ground pins.
Reset Reset Resets the
microcontroller.
Analog Pins A0 – A5 Used to provide analog
input in the range of 0-5V
Input/Output Pins Digital Pins 0 - 13 Can be used as input or
output pins.
Serial 0(Rx), 1(Tx) Used to receive and
transmit TTL serial data.
External Interrupts 2, 3 To trigger an interrupt.
PWM 3, 5, 6, 9, 11 Provides 8-bit PWM
output.
SPI 10 (SS), 11 (MOSI), 12 Used for SPI
(MISO) and 13 (SCK) communication.
Inbuilt LED 13 To turn on the inbuilt
LED.
TWI A4 (SDA), A5 (SCA) Used for TWI
communication.
AREF AREF To provide reference
voltage for input voltage.
ESP8266 is a low-cost open source IoT platform. It initially included firmware which runs
on the ESP8266 Wi-Fi SoC from Espressif Systems, and hardware which was based on
the ESP-12 module. Later, support for the ESP32 32-bit MCU was added.
15
Figure 3.2: ESP 8266
16
Analog Pin A0 Used to measure
analog voltage in the
range of 0-3.3V
GPIO Pins GPIO1 to GPIO16 NodeMCU has 16
general purpose input-
output pins on its
board
SPI Pins SD1, CMD, SD0, CLK NodeMCU has four
pins available for SPI
communication.
UART Pins TXD0, RXD0, TXD2, NodeMCU has two
RXD2 UART interfaces,
UART0 (RXD0 &
TXD0) and UART1
(RXD1 & TXD1).
UART1 is used to
upload the
firmware/program.
I2C Pins NodeMCU has I2C
functionality support
but due to the internal
functionality of these
pins, you have to find
which pin is I2C.
A 3.5” TFT LCD module consists of a bright backlight (4 white LEDs) and a colourful
480X320 pixels display. It also features individual RGB pixel control giving a much better
resolution than the black and white displays. A resistive touch screen comes pre-installed
with the module as a bonus and hence you can easily detect your finger presses anywhere
on the screen.
17
Figure 3.3: 3.5 Inch Display
3.5.1 Features
Name Parameter
SKU MAR3501
Type TFT
Driver IC ILI9486
18
Storage Temperature -40℃~70℃
19
20 SD_SCK SD card SPI bus clock signal
The four-channel relay module contains four 5V relays and the associated switching and
isolating components, which makes interfacing with a microcontroller or sensor easy with
minimum components and connections. The contacts on each relay are specified for
250VAC and 30VDC and 10A in each case, as marked on the body of the relays.
3.6.1 Features
12V power supplies (or 12VDC power supplies) are one of the most common power
supplies in use today. Linear regulated 12VDC power supplies regulate the output using a
dissipative regulating circuit. They are extremely stable, have very low ripple, and have no
switching frequencies to produce EMI.
21
Fig. 2.14: 12VDC Power Supply
22
At the moment the Arduino wasn’t connected to the PC. If we now choose “Port”, under
the field “Tool”, we will already see one or more ports here (COM1/ COM2/ COM3…).
The quantity of the shown ports doesn't depend on the quantity of the USB ports on the
computer. When the board gets connected to the computer, we will find one more port.
23
Figure 3.3: Blynk App Interface
Chapter 04
System Design
24
4.1 Introduction
In This chapter we are going to describe how we designed our project. And also showing
or diagrams like circuit diagram, flow chart, block diagram.
Figure 4.1: Block Diagram of IoT Based Home Automation With HMI
25
4.3 Flow Chart
Figure 4.2: Flow Chart of IoT Based Home Automation with HMI
26
4.4 Circuit Diagram
Figure 4.2: Circuit Diagram of IoT Based Home Automation with HMI
27
Chapter 05
Final Result
28
5.1 Introduction
In this chapter we are going to show our final result of this project and advantages of our
project and cost analysis of our project.
5.2 Result
Our final result is now we are able to control any electrical load through our mobile phone
over internet from anywhere. Also at the same time if we want then we can control them
using HMI (Human Machine Interface). HMI is basically a touch screen display.
5.4 Advantages
29
1. Smart Home
2. Save Electricity
3. Safety from electrical shock
4. Protection from any electrical accident
5. Save time.
6. Save electric bill.
30
Chapter 06
Discussion
And
Conclusions
31
6.1 Discussion
Home Automation System (HAS) gains popularity due to communication technology
advancement. Smart home is one of the Internet of Things (IoT) applications that
facilitates the control of home appliances over the Internet using automation system. This
paper proposes a low-cost Wi-Fi based automation system for Smart Home (SH) in order
to monitor and control home appliances remotely using Android-based application. An
Arduino Uno microcontroller provided with Wi-Fi module is utilized to build the
automation system. A relay board is exploited to connect the HAS with home under
controlled appliances. The proposed automation system, can easily and efficiently control
the electrical appliances via touch screen and Wi-Fi and Blynk mobile application.
6.3 Conclusion
This research project has proposed, designed and fabricated a low cost Wi-Fi based
Automation System for Smart Home prototype using Arduino and Android smartphone
and HMI. It enables the control all the electrical appliances such as the bulb and fan at
home easily and efficiently via Wi-Fi. The sensor can monitor the motion, humidity and
temperature of the house. Buzzer will be ON when there is a motion detected in the house.
The Smart Home Automation System provide a comfortable, intelligence, good security
and improve the quality of life. By using this smart home system, electric bill can be
reduced because the user can control the electrical appliances anytime without using
human energy. The next step of our research will be enabling the remote control of the
developed system based on IoT concept so that the user can control it using webserver
even when they are not around their house. We are going to increase the number and
variety of sensors for more safety and security in addition to provide option for the fully-
automated of home appliances. We will implement a gateway to connect all sensors to an
IoT platform and we may replace some sensors with a wireless sensor to overcome some
wiring problems. Our final product should be a compact box which is easy to be integrated
to an existing switching board of real houses appliances via relay board and provide safer
control.
32
Reference
[1] W. A. Jabbar, M. Ismail, and R. Nordin, "Evaluation of energy consumption in
multipath OLSR routing in Smart City applications," in Communications (MICC), 2013
IEEE Malaysia International Conference on, 2013, pp. 401-406.
[2] K.-M. Lee, W.-G. Teng, and T.-W. Hou, "Point-n-Press: An Intelligent Universal
Remote Control System for Home Appliances," IEEE Transactions on automation science
and engineering, vol. 13, pp. 1308-1317, 2016.
[3] P. P. Gaikwad, J. P. Gabhane, and S. S. Golait, "A survey based on Smart Homes
system using Internet-of-Things," in Computation of Power, Energy Information and
Commuincation (ICCPEIC), 2015 International Conference on, 2015, pp. 0330-0335.
[5] T. Song, R. Li, B. Mei, J. Yu, X. Xing, and X. Cheng, "A privacy preserving
communication protocol for IoT applications in smart homes," IEEE Internet of Things
Journal, vol. 4, pp. 1844-1852, 2017.
[6] D. Acharjya, M. K. Geetha, and S. Sanyal, Internet of Things: novel advances and
envisioned applications vol. 25: Springer, 2017.
[7] R. Piyare and M. Tazil, "Bluetooth based home automation system using cell phone,"
in Consumer Electronics (ISCE), 2011 IEEE 15th International Symposium on, 2011, pp.
192-195.
[8] W. A. Jabbar, M. Ismail, R. Nordin, and S. Arif, "Power-efficient routing schemes for
MANETs: a survey and open issues," Wireless Networks, pp. 1-36, 2016.
[10] O. T. Algoiare, "Design and implementation of intelligent home using gsm network,"
2014.
33
[11] R. Kazi and G. Tiwari, "IoT based Interactive Industrial Home wireless system,
Energy management system and embedded data acquisition system to display on web page
using GPRS, SMS & E-mail alert," in Energy Systems and Applications, 2015
International Conference on, 2015, pp. 290-295.
Appendix I
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Blynk.h>
#include <Ticker.h>
#define r1 16
#define r2 14
#define r3 12
#define r4 13
Ticker rtc;
void setup() {
Serial.begin(9600);
rtc.attach(1.0, oneSec);
pinMode(r1, OUTPUT);
pinMode(r2, OUTPUT);
pinMode(r3, OUTPUT);
pinMode(r4, OUTPUT);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println((String)"\nConnected To " + ssid);
Blynk.config(auth);
34
Blynk.connect(3333);
}
void oneSec() {
if (timerMode == 1) {
timer1++; timer2++;
timer3++; timer4++;
if (timer1 == setTimer1) {
timer1 = 0;
rly1 = !rly1;
digitalWrite(r1, rly1);
Blynk.virtualWrite(V4, rly1);
Serial.print("R1=");
Serial.println(rly1);
}
if (timer2 == setTimer2) {
timer2 = 0;
rly2 = !rly2;
digitalWrite(r2, rly2);
Blynk.virtualWrite(V5, rly2);
Serial.print("R2=");
Serial.println(rly2);
}
if (timer3 == setTimer3) {
timer3 = 0;
rly3 = !rly3;
digitalWrite(r3, rly3);
Blynk.virtualWrite(V6, rly3);
Serial.print("R3=");
Serial.println(rly3);
}
if (timer4 == setTimer4) {
timer4 = 0;
rly4 = !rly4;
digitalWrite(r4, rly4);
Blynk.virtualWrite(V7, rly4);
Serial.print("R4=");
Serial.println(rly4);
}
}
}
void loop() {
Blynk.run();
if (Serial.available() > 0) {
String cmd = Serial.readString();
if (cmd.startsWith("TM")) {
35
cmd.remove(0, 3);
timerMode = cmd.toInt();
Blynk.virtualWrite(V8, timerMode);
}
if (cmd.startsWith("T1")) {
cmd.remove(0, 3);
setTimer1 = cmd.toInt();
Blynk.virtualWrite(V0, setTimer1, 0, "Europe/Kiev", "1");
}
if (cmd.startsWith("T2")) {
cmd.remove(0, 3);
setTimer2 = cmd.toInt();
Blynk.virtualWrite(V1, setTimer2, 0, "Europe/Kiev", "1");
}
if (cmd.startsWith("T3")) {
cmd.remove(0, 3);
setTimer3 = cmd.toInt();
Blynk.virtualWrite(V2, setTimer3, 0, "Europe/Kiev", "1");
}
if (cmd.startsWith("T4")) {
cmd.remove(0, 3);
setTimer4 = cmd.toInt();
Blynk.virtualWrite(V3, setTimer4, 0, "Europe/Kiev", "1");
}
if (timerMode == 0) {
if (cmd.startsWith("V4")) {
cmd.remove(0, 3);
rly1 = cmd.toInt();
digitalWrite(r1, rly1);
Blynk.virtualWrite(V4, rly1);
}
else if (cmd.startsWith("V5")) {
cmd.remove(0, 3);
rly2 = cmd.toInt();
digitalWrite(r2, rly2);
Blynk.virtualWrite(V5, rly2);
}
else if (cmd.startsWith("V6")) {
cmd.remove(0, 3);
rly3 = cmd.toInt();
digitalWrite(r3, rly3);
Blynk.virtualWrite(V6, rly3);
}
else if (cmd.startsWith("V7")) {
cmd.remove(0, 3);
36
rly4 = cmd.toInt();
digitalWrite(r4, rly4);
Blynk.virtualWrite(V7, rly4);
}
}
}
}
BLYNK_CONNECTED() {
if (firstRun == 0) {
Blynk.syncAll();
firstRun = 1;
}
}
BLYNK_WRITE(V0) {
if (param[0].asLong() != setTimer1) {
setTimer1 = param[0].asLong();
Serial.print("T1=");
Serial.println(setTimer1);
}
}
BLYNK_WRITE(V1) {
if (param[0].asLong() != setTimer2) {
setTimer2 = param[0].asLong();
Serial.print("T2=");
Serial.println(setTimer2);
}
}
BLYNK_WRITE(V2) {
if (param[0].asLong() != setTimer3) {
setTimer3 = param[0].asLong();
Serial.print("T3=");
Serial.println(setTimer3);
}
}
BLYNK_WRITE(V3) {
if (param[0].asLong() != setTimer4) {
setTimer4 = param[0].asLong();
Serial.print("T4=");
Serial.println(setTimer4);
}
}
BLYNK_WRITE(V4) {
if (param.asInt() != rly1 && timerMode == 0) {
rly1 = param.asInt();
37
digitalWrite(r1, rly1);
Serial.print("R1=");
Serial.println(rly1);
}
}
BLYNK_WRITE(V5) {
if (param.asInt() != rly2 && timerMode == 0) {
rly2 = param.asInt();
digitalWrite(r2, rly2);
Serial.print("R2=");
Serial.println(rly2);
}
}
BLYNK_WRITE(V6) {
if (param.asInt() != rly3 && timerMode == 0) {
rly3 = param.asInt();
digitalWrite(r3, rly3);
Serial.print("R3=");
Serial.println(rly3);
}
}
BLYNK_WRITE(V7) {
if (param.asInt() != rly4 && timerMode == 0) {
rly4 = param.asInt();
digitalWrite(r4, rly4);
Serial.print("R4=");
Serial.println(rly4);
}
}
BLYNK_WRITE(V8) {
if (param.asInt() != timerMode) {
timerMode = param.asInt();
Serial.print("TM=");
Serial.println(timerMode);
}
}
38
Appendix II
#include <SoftwareSerial.h>
#include <TouchScreen.h> //touch library
#include <LCDWIKI_GUI.h> //Core graphics library
#include <LCDWIKI_KBV.h> //Hardware-specific library
#define STATUS_X 10
#define STATUS_Y 65
#define MINPRESSURE 10
#define MAXPRESSURE 1000
39
#define YP A3
#define XM A2
#define YM 9
#define XP 8
button_info phone_button[12] = {
"1", 4, BLACK, CYAN, EDG_X + BUTTON_R - 1, my_lcd.Get_Display_Height() -
EDG_Y - 4 * BUTTON_SPACING_Y - 9 * BUTTON_R - 1,
"2", 4, BLACK, CYAN, EDG_X + 3 * BUTTON_R + BUTTON_SPACING_X - 1,
my_lcd.Get_Display_Height() - EDG_Y - 4 * BUTTON_SPACING_Y - 9 * BUTTON_R
- 1,
"3", 4, BLACK, CYAN, EDG_X + 5 * BUTTON_R + 2 * BUTTON_SPACING_X - 1,
my_lcd.Get_Display_Height() - EDG_Y - 4 * BUTTON_SPACING_Y - 9 * BUTTON_R
- 1,
"4", 4, BLACK, CYAN, EDG_X + BUTTON_R - 1, my_lcd.Get_Display_Height() -
EDG_Y - 3 * BUTTON_SPACING_Y - 7 * BUTTON_R - 1,
"5", 4, BLACK, CYAN, EDG_X + 3 * BUTTON_R + BUTTON_SPACING_X - 1,
my_lcd.Get_Display_Height() - EDG_Y - 3 * BUTTON_SPACING_Y - 7 * BUTTON_R
- 1,
"6", 4, BLACK, CYAN, EDG_X + 5 * BUTTON_R + 2 * BUTTON_SPACING_X - 1,
my_lcd.Get_Display_Height() - EDG_Y - 3 * BUTTON_SPACING_Y - 7 * BUTTON_R
- 1,
"7", 4, BLACK, CYAN, EDG_X + BUTTON_R - 1, my_lcd.Get_Display_Height() -
EDG_Y - 2 * BUTTON_SPACING_Y - 5 * BUTTON_R - 1,
40
"8", 4, BLACK, CYAN, EDG_X + 3 * BUTTON_R + BUTTON_SPACING_X - 1,
my_lcd.Get_Display_Height() - EDG_Y - 2 * BUTTON_SPACING_Y - 5 * BUTTON_R
- 1,
"9", 4, BLACK, CYAN, EDG_X + 5 * BUTTON_R + 2 * BUTTON_SPACING_X - 1,
my_lcd.Get_Display_Height() - EDG_Y - 2 * BUTTON_SPACING_Y - 5 * BUTTON_R
- 1,
"<<", 3, WHITE, RED, EDG_X + BUTTON_R - 1, my_lcd.Get_Display_Height() -
EDG_Y - BUTTON_SPACING_Y - 3 * BUTTON_R - 1,
"0", 4, BLACK, CYAN, EDG_X + 3 * BUTTON_R + BUTTON_SPACING_X - 1,
my_lcd.Get_Display_Height() - EDG_Y - BUTTON_SPACING_Y - 3 * BUTTON_R - 1,
"SET", 3, BLACK, GREEN, EDG_X + 5 * BUTTON_R + 2 * BUTTON_SPACING_X
- 1, my_lcd.Get_Display_Height() - EDG_Y - BUTTON_SPACING_Y - 3 * BUTTON_R
- 1,
};
void setup() {
Serial.begin(9600);
esp.begin(9600);
my_lcd.Init_LCD();
delay(2000);
homeScreen();
}
void loop() {
checkTouch();
if (esp.available() > 0) {
String cmd = esp.readString();
if (cmd.startsWith("R1=1")) {
rly1 = 1;
updateUI(1);
}
else if (cmd.startsWith("R1=0")) {
rly1 = 0;
updateUI(1);
}
else if (cmd.startsWith("R2=1")) {
rly2 = 1;
updateUI(2);
}
else if (cmd.startsWith("R2=0")) {
rly2 = 0;
updateUI(2);
41
}
else if (cmd.startsWith("R3=1")) {
rly3 = 1;
updateUI(3);
}
else if (cmd.startsWith("R3=0")) {
rly3 = 0;
updateUI(3);
}
else if (cmd.startsWith("R4=1")) {
rly4 = 1;
updateUI(4);
}
else if (cmd.startsWith("R4=0")) {
rly4 = 0;
updateUI(4);
}
else if (cmd.startsWith("TM=1")) {
mode = 1;
updateUI(5);
}
else if (cmd.startsWith("TM=0")) {
mode = 0;
updateUI(5);
}
else if (cmd.startsWith("T1")) {
cmd.remove(0, 3);
timer1 = cmd.toInt();
hh1 = timer1 / 3600;
mm1 = ((timer1 / 3600.0) - hh1) * 60;
updateUI(6);
}
else if (cmd.startsWith("T2")) {
cmd.remove(0, 3);
timer2 = cmd.toInt();
hh2 = timer2 / 3600;
mm2 = ((timer2 / 3600.0) - hh2) * 60;
updateUI(7);
}
else if (cmd.startsWith("T3")) {
cmd.remove(0, 3);
timer3 = cmd.toInt();
hh3 = timer3 / 3600;
mm3 = ((timer3 / 3600.0) - hh3) * 60;
42
updateUI(8);
}
else if (cmd.startsWith("T4")) {
cmd.remove(0, 3);
timer4 = cmd.toInt();
hh4 = timer4 / 3600;
mm4 = ((timer4 / 3600.0) - hh4) * 60;
updateUI(9);
}
}
}
void homeScreen() {
my_lcd.Fill_Screen(BLACK);
my_lcd.Set_Draw_color(DARKGREY);
my_lcd.Fill_Rectangle(0, 455, 320, 480);
// borders
my_lcd.Set_Draw_color(GREEN);
my_lcd.Draw_Rectangle(10, 20, 155, 130);
my_lcd.Draw_Rectangle(165, 20, 310, 130);
my_lcd.Draw_Rectangle(10, 145, 155, 260);
my_lcd.Draw_Rectangle(165, 145, 310, 260);
// timer span
my_lcd.Set_Draw_color(ORANGE);
my_lcd.Fill_Rectangle(20, 55, 75, 120);
my_lcd.Fill_Rectangle(90, 55, 145, 120);
// texts
print("TIMER 1", 15, 30, 2, WHITE, BLACK);
print("TIMER 2", 170, 30, 2, WHITE, BLACK);
43
print("TIMER 3", 15, 155, 2, WHITE, BLACK);
print("TIMER 4", 170, 155, 2, WHITE, BLACK);
// timer span
print(str(hh1).c_str(), 30, 75, 3, BLACK, ORANGE);
print(":", 75, 75, 3, WHITE, BLACK);
print(str(mm1).c_str(), 100, 75, 3, BLACK, ORANGE);
void showKeypad() {
uint16_t i;
text_x = 7, text_y = 10;
text_x_add = 6 * phone_button[0].button_name_size;
text_y_add = 8 * phone_button[0].button_name_size;
n = 0;
my_lcd.Fill_Screen(BLUE);
for (i = 0; i < sizeof(phone_button) / sizeof(button_info); i++) {
my_lcd.Set_Draw_color(phone_button[i].button_colour);
my_lcd.Fill_Circle(phone_button[i].button_x, phone_button[i].button_y, BUTTON_R);
print(phone_button[i].button_name, phone_button[i].button_x -
strlen(phone_button[i].button_name)*phone_button[i].button_name_size * 6 / 2 +
phone_button[i].button_name_size / 2 + 1, phone_button[i].button_y -
phone_button[i].button_name_size * 8 / 2 + phone_button[i].button_name_size / 2 + 1,
phone_button[i].button_name_size, phone_button[i].button_name_colour, BLACK);
}
my_lcd.Set_Draw_color(BLACK);
my_lcd.Fill_Rectangle(1, 1, my_lcd.Get_Display_Width() - 2, 3);
my_lcd.Fill_Rectangle(1, 45, my_lcd.Get_Display_Width() - 2, 47);
my_lcd.Fill_Rectangle(1, 1, 3, 47);
my_lcd.Fill_Rectangle(my_lcd.Get_Display_Width() - 4, 1,
my_lcd.Get_Display_Width() - 2, 47);
44
}
void print(uint8_t *str, int16_t x, int16_t y, uint8_t csize, uint16_t fc, uint16_t bc) {
my_lcd.Set_Text_Mode(1);
my_lcd.Set_Text_Size(csize);
my_lcd.Set_Text_colour(fc);
my_lcd.Set_Text_Back_colour(bc);
my_lcd.Print_String(str, x, y);
}
void checkTouch() {
digitalWrite(13, HIGH);
TSPoint p = ts.getPoint();
digitalWrite(13, LOW);
pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);
if (p.z > MINPRESSURE && p.z < MAXPRESSURE) {
p.x = map(p.x, TS_MINX, TS_MAXX, my_lcd.Get_Display_Width(), 0);
p.y = map(p.y, TS_MINY, TS_MAXY, my_lcd.Get_Display_Height(), 0);
if (inKeypadScreen == 1) {
uint8_t val[2];
for (int i = 0; i < sizeof(phone_button) / sizeof(button_info); i++) {
if (isPressed(phone_button[i].button_x - BUTTON_R, phone_button[i].button_y -
BUTTON_R, phone_button[i].button_x + BUTTON_R, phone_button[i].button_y +
BUTTON_R, p.x, p.y)) {
my_lcd.Set_Draw_color(DARKGREY);
my_lcd.Fill_Circle(phone_button[i].button_x, phone_button[i].button_y,
BUTTON_R);
print(phone_button[i].button_name, phone_button[i].button_x -
strlen(phone_button[i].button_name)*phone_button[i].button_name_size * 6 / 2 +
phone_button[i].button_name_size / 2 + 1, phone_button[i].button_y -
phone_button[i].button_name_size * 8 / 2 + phone_button[i].button_name_size / 2 + 1,
phone_button[i].button_name_size, WHITE, BLACK);
delay(100);
my_lcd.Set_Draw_color(phone_button[i].button_colour);
my_lcd.Fill_Circle(phone_button[i].button_x, phone_button[i].button_y,
BUTTON_R);
print(phone_button[i].button_name, phone_button[i].button_x -
strlen(phone_button[i].button_name)*phone_button[i].button_name_size * 6 / 2 +
phone_button[i].button_name_size / 2 + 1, phone_button[i].button_y -
phone_button[i].button_name_size * 8 / 2 + phone_button[i].button_name_size / 2 + 1,
phone_button[i].button_name_size, phone_button[i].button_name_colour, BLACK);
if (n < 2 && i != 9 && i != 11) {
45
print(phone_button[i].button_name, text_x, text_y,
phone_button[i].button_name_size, GREENYELLOW, BLACK);
text_x += text_x_add - 1;
val[n] = phone_button[i].button_name[0];
n++;
}
else if (i == 11) { // SET
inKeypadScreen = 0;
switch (updater) {
case 1:
hh1 = (val[0] - 48) * 10 + (val[1] - 48);
timer1 = hh1 * 3600 + mm1 * 60;
Serial.println((String)"T1=" + timer1);
break;
case 2:
mm1 = (val[0] - 48) * 10 + (val[1] - 48);
timer1 = hh1 * 3600 + mm1 * 60;
esp.println((String)"T1=" + timer1);
break;
case 3:
hh2 = (val[0] - 48) * 10 + (val[1] - 48);
timer2 = hh2 * 3600 + mm2 * 60;
esp.println((String)"T2=" + timer2);
break;
case 4:
mm2 = (val[0] - 48) * 10 + (val[1] - 48);
timer2 = hh2 * 3600 + mm2 * 60;
esp.println((String)"T2=" + timer2);
break;
case 5:
hh3 = (val[0] - 48) * 10 + (val[1] - 48);
timer3 = hh3 * 3600 + mm3 * 60;
esp.println((String)"T3=" + timer3);
break;
case 6:
mm3 = (val[0] - 48) * 10 + (val[1] - 48);
timer3 = hh3 * 3600 + mm3 * 60;
esp.println((String)"T3=" + timer3);
break;
case 7:
hh4 = (val[0] - 48) * 10 + (val[1] - 48);
timer4 = hh4 * 3600 + mm4 * 60;
esp.println((String)"T4=" + timer4);
break;
case 8:
mm4 = (val[0] - 48) * 10 + (val[1] - 48);
timer4 = hh4 * 3600 + mm4 * 60;
esp.println((String)"T4=" + timer4);
break;
}
46
homeScreen();
}
else if (i == 9) { //del
if (n > 0) {
my_lcd.Set_Draw_color(BLUE);
text_x -= (text_x_add - 1);
my_lcd.Fill_Rectangle(text_x, text_y, text_x + text_x_add - 1, text_y +
text_y_add - 2);
val[n] = 0;
n--;
}
}
}
}
}
else {
if (isPressed(20, 55, 75, 120, p.x, p.y)) { // hh1
updater = 1;
inKeypadScreen = 1;
showKeypad();
}
else if (isPressed(90, 55, 145, 120, p.x, p.y)) { // mm1
updater = 2;
inKeypadScreen = 1;
showKeypad();
}
else if (isPressed(175, 55, 230, 120, p.x, p.y)) { // hh2
updater = 3;
inKeypadScreen = 1;
showKeypad();
}
else if (isPressed(245, 55, 300, 120, p.x, p.y)) { // mm2
updater = 4;
inKeypadScreen = 1;
showKeypad();
}
else if (isPressed(20, 180, 75, 250, p.x, p.y)) { // hh3
updater = 5;
inKeypadScreen = 1;
showKeypad();
}
else if (isPressed(90, 180, 145, 250, p.x, p.y)) { // mm3
updater = 6;
inKeypadScreen = 1;
showKeypad();
}
else if (isPressed(175, 180, 230, 250, p.x, p.y)) { // hh4
updater = 7;
inKeypadScreen = 1;
showKeypad();
47
}
else if (isPressed(245, 180, 300, 250, p.x, p.y)) { // mm4
updater = 8;
inKeypadScreen = 1;
showKeypad();
}
else if (isPressed(10, 275, 80, 385, p.x, p.y)) { // rly1
rly1 = !rly1;
updateUI(1);
}
else if (isPressed(85, 275, 155, 385, p.x, p.y)) { // rly2
rly2 = !rly2;
updateUI(2);
}
else if (isPressed(160, 275, 230, 385, p.x, p.y)) { // rly3
rly3 = !rly3;
updateUI(3);
}
else if (isPressed(235, 275, 305, 385, p.x, p.y)) { // rly4
rly4 = !rly4;
updateUI(4);
}
else if (isPressed(10, 400, 310, 440, p.x, p.y)) { // mode
mode = !mode;
updateUI(5);
}
}
}
}
48
if (rly2 == 1) {
my_lcd.Set_Draw_color(GREEN);
my_lcd.Fill_Rectangle(85, 275, 155, 385);
print("R2", 110, 320, 2, BLACK, GREEN);
esp.println("V5=1");
delay(200);
}
else {
my_lcd.Set_Draw_color(BLACK);
my_lcd.Fill_Rectangle(85, 275, 155, 385);
my_lcd.Set_Draw_color(GREEN);
my_lcd.Draw_Rectangle(85, 275, 155, 385);
print("R2", 110, 320, 2, WHITE, BLACK);
esp.println("V5=0");
delay(200);
}
}
else if (which == 3) {
if (rly3 == 1) {
my_lcd.Set_Draw_color(GREEN);
my_lcd.Fill_Rectangle(160, 275, 230, 385);
print("R3", 185, 320, 2, BLACK, GREEN);
esp.println("V6=1");
delay(200);
}
else {
my_lcd.Set_Draw_color(BLACK);
my_lcd.Fill_Rectangle(160, 275, 230, 385);
my_lcd.Set_Draw_color(GREEN);
my_lcd.Draw_Rectangle(160, 275, 230, 385);
print("R3", 185, 320, 2, WHITE, BLACK);
esp.println("V6=0");
delay(200);
}
}
else if (which == 4) {
if (rly4 == 1) {
my_lcd.Set_Draw_color(GREEN);
my_lcd.Fill_Rectangle(235, 275, 305, 385);
print("R4", 260, 320, 2, BLACK, GREEN);
esp.println("V7=1");
delay(200);
}
else {
my_lcd.Set_Draw_color(BLACK);
my_lcd.Fill_Rectangle(235, 275, 305, 385);
my_lcd.Set_Draw_color(GREEN);
my_lcd.Draw_Rectangle(235, 275, 305, 385);
print("R4", 260, 320, 2, WHITE, BLACK);
esp.println("V7=0");
49
delay(200);
}
}
else if (which == 5) {
if (mode == 1) {
my_lcd.Set_Draw_color(ORANGE);
my_lcd.Fill_Rectangle(10, 400, 310, 440);
print("MODE: TIMER", 90, 415, 2, BLACK, ORANGE);
esp.println("TM=1");
delay(200);
}
else {
my_lcd.Set_Draw_color(ORANGE);
my_lcd.Fill_Rectangle(10, 400, 310, 440);
print("MODE: BUTTON", 90, 415, 2, BLACK, ORANGE);
esp.println("TM=0");
delay(200);
}
}
else if (which == 6) {
my_lcd.Set_Draw_color(ORANGE);
my_lcd.Fill_Rectangle(20, 55, 75, 120);
my_lcd.Fill_Rectangle(90, 55, 145, 120);
print(str(hh1).c_str(), 30, 75, 3, BLACK, ORANGE);
print(":", 75, 75, 3, WHITE, BLACK);
print(str(mm1).c_str(), 100, 75, 3, BLACK, ORANGE);
}
else if (which == 7) {
my_lcd.Set_Draw_color(ORANGE);
my_lcd.Fill_Rectangle(175, 55, 230, 120);
my_lcd.Fill_Rectangle(245, 55, 300, 120);
print(str(hh2).c_str(), 185, 75, 3, BLACK, ORANGE);
print(":", 230, 75, 3, WHITE, BLACK);
print(str(mm2).c_str(), 255, 75, 3, BLACK, ORANGE);
}
else if (which == 8) {
my_lcd.Set_Draw_color(ORANGE);
my_lcd.Fill_Rectangle(20, 180, 75, 250);
my_lcd.Fill_Rectangle(90, 180, 145, 250);
print(str(hh3).c_str(), 30, 200, 3, BLACK, ORANGE);
print(":", 75, 200, 3, WHITE, BLACK);
print(str(mm3).c_str(), 100, 200, 3, BLACK, ORANGE);
}
else if (which == 9) {
my_lcd.Set_Draw_color(ORANGE);
my_lcd.Fill_Rectangle(175, 180, 230, 250);
my_lcd.Fill_Rectangle(245, 180, 300, 250);
print(str(hh4).c_str(), 185, 200, 3, BLACK, ORANGE);
print(":", 230, 200, 3, WHITE, BLACK);
print(str(mm4).c_str(), 255, 200, 3, BLACK, ORANGE);
50
}
}
boolean isPressed(int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t px, int16_t py) {
if ((px > x1 && px < x2) && (py > y1 && py < y2)) return true;
else return false;
}
51