181 American Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) ISSN (Print) 2313-4410, ISSN (Online) 2313-4402 © Global Society of Scientific Research and Researchers http://asrjetsjournal.org/ An Internet of Things Based Air Conditioning and Lighting Control System for Smart Home Mehmet Taştana*, Hayrettin Gökozanb aDepartments of Electronics and Automation, Manisa Celal Bayar University, Turgutlu, Manisa, 45400, Turkey bDepartments of Electric and Energy, Manisa Celal Bayar University, Turgutlu, Manisa, 45400, Turkey aEmail: mehmet.tastan@cbu.edu.tr bEmail: hayrettin.gokozan@cbu.edu.tr Abstract Today, the internet has become an indispensable part of human life. With our social media, banking transactions, news, shopping, e-government and many more applications, we have reached higher level in our standard of living. This rapid development of technology provides convenience in different areas of our lives every day. Many devices such as TVs, refrigerators, washing machines we use in daily life are able to communicate with each other by becoming smart thanks to the Internet of Things (IoT) and Machine to Machine (M2M) technologies. In recent days we have become more and more aware of the concepts of smart city such as smart home, transportation, health, education, energy and smart environment. One of these concepts, "smart home" applications undoubtedly attracts the most demanded applications individually. In this study, a smart home application including conditioning and lighting controls is implemented using NodeMCU embedded system microcontroller, Arduino Pro Mini and Blynk iOS/Android interface developer. Keywords: IoT; Cloud; Blynk; NodeMCU; Smart home. 1. Introduction Many of the devices we use today, where we live in the age of technology, can be easily monitored and controlled from different distances, especially by smart phones and tablets. With the increasing number of firms producing microcontroller with embedded system, the prices of these products are falling rapidly. In addition, with Android and iOS interface development programs becoming user-friendly, examples of smart applications with IoT are increasing rapidly. ------------------------------------------------------------------------ * Corresponding author. http://asrjetsjournal.org/ American Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) (2018) Volume 50, No 1, pp 181-189 182 IoT is a term first introduced by Kevin Ashton in a presentation he made in 1999. Initially, this concept, which includes devices communicating with each other via radio frequency tags via RFID tags, has reached a much wider vision with evolving technology [1]. This concept includes not only the household items in our homes and traffic lights on the road, as well as machines manufacturing in factories. IoT is a communication network in which physical objects are linked to each other or to larger systems. This network collects billions of data from very diverse devices we use in everyday life and turns them into usable information. According to the research done, there are 500 million devices in the world that interact with each other in 2003, and today it is estimated that it is at 14 billion devices level, and that this figure will go up to 50 billion devices by the year 2020 [2]. This also shows that in the coming years, the cities we live in through IoT will become smart cities that keep pace with the more planned life. This transformation will also present us with many opportunities that will facilitate human life. Today there is a rapid transformation in our homes, in our workplaces and in our surroundings thanks to IoT. For example, many things like turning on your music system with your entrance to home, lighting and control of electrical appliances remotely [3], the heating system functioning by receiving location information from your mobile phone without coming home and automatically changing settings according to regional weather conditions [4], monitoring and controlling energy consumption of appliances such as air conditioners, refrigerators, air conditioners and ovens [5,6], taking into account not only the time of watering your vegetables in your garden but also the soil nourishment [7], getting the weather forecast correctly when you are doing our weekend plan [8], live a reliable life with wearable medical devices for people who have health problems that require continuous follow-up [9-11], smart farming practices [12], smart environment, smart transportation, smart education [13] are at the center of our lives. Smart homes are automated buildings with installed detection and control devices, such as air conditioning and heating, ventilation, lighting, hardware, and security systems. These modern systems, which include switches and sensors that communicate with a central axis, are sometimes called “gateways.” These “gateways” are control systems with a user interface that interacts with a tablet, mobile phone, or computer; the network connectivity of these systems is managed by IoT [14]. As an important component of the IoT, smart homes serve users effectively by communicating with various electrical appliances based on IoT. In the ideal version of a wired future, all electrical appliances in smart homes communicate with one another seamlessly. Smart home technology based on IoT has changed human life by providing connectivity to everyone regardless of time and place [15]. Smart automation systems in smart homes provide comfort to residents, ensure their safety, and allow devices to operate at all times [16]. All these devices are equipped with sensors with different functions and wireless communication tools based on IoT technology . For example, when residents leave their smart homes, the devices inside their homes automatically turn off [17] . Mobile devices are suitable for residents in smart homes, and residents can use these devices instead of a physical key. Smart homes can be controlled using mobile devices or through remote control [18]. In this study, an IoT-based system has been proposed which provides the controls of air conditioning and lighting devices in a smart home. The proposed system allows the user to program and remotely control devices via the android-based user interface. The system provides both heat comfort and energy savings to the households. 2. Materials and Methods For smart home application, the NodeMCU WiFi module with embedded system architecture and the Arduino American Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) (2018) Volume 50, No 1, pp 181-189 183 Pro Mini 328P microcontroller are used. The temperature and humidity information of the medium was taken by DHT22 temperature-humidity sensor. In the case of smart climate control, the communication between the NodeMCU and the Combi / Air Conditioner is provided by the NRFL01 radio frequency (RF) modules and Arduino Pro Mini. 2.1. NodeMCU v1.0 and Arduino Pro Mini Figure 1: Pin structures of NodeMCU and Arduino Pro Mini. NodeMCU has a modular structure with built-in WiFi feature. Its programmable feature makes it possible to implement internet applications of objects at low cost. Digital Input/Output units provide PWM outputs and communication support. The other controller used in smart climate control is the Arduino Pro Mini, which acts as an RF receiver module. The pin structure of these two controllers is shown in Figure 1. NodeMCU is an IoT controller with embedded WiFi module, which is very common. It includes a 32-bit Tensilica LX106 microcontroller running at 160 MHz [19]. In order to program the NodeMCU, there is a programming language commonly called Lua, with different options available. In addition to this, Arduino can also be easily programmed with IDE. Table 1: NodeMCU and Arduino Pro Mini Specifications Specifications NodeMCU v1.0 Arduino Pro Mini MCU 32 bit Tensilica L106 8 bit ATmega328P Frequency 80/160 MHz 16 MHz Input-Output 17xDIO 14xDIO ADC Pin 1x10 bit (1V) 6x10 Bit(3V3) Operating Voltage 3.0∼3.6V 3.0∼3.6V Program Memory 4MB 32kB WiFi IEEE 802.11 b/g/n - The NodeMCU can be programmed directly via the mini USB port, while the Arduino Pro can be programmed American Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) (2018) Volume 50, No 1, pp 181-189 184 by external programmers using the Rx and Tx ends of the Mini. The Arduino Pro Mini is a low cost 8 bit controller with a small footprint [20]. Figure 1 shows the pin structures of the NodeMCU and Arduino Pro Mini, and Table 1 shows the specifications of the controllers. 2.2. DHT22 Temperature-Humidity Sensor The DHT-22 comes in two parts: capacitive humidity and thermistor temperature sensor. The DHT22 temperature and humidity sensor is an advanced sensor unit that provides a calibrated digital signal output. There is an 8 bit microcontroller on it and it has a short response time. It has a precise calibration and the calibration coefficient OTP is stored in some kind of program in memory. Refer to this coefficient stored in the memory during product detection. It makes temperature measurement unit with +/- 0.5°C error between -40 and 80°C, humidity measurement between 0-100% RH with ± 2% RH error. The pins of DHT22 are designated as Vdd supply, DATA and two ground pins. Communication between the MCU on the module and the temperature humidity measuring unit (AM2302) is provided by a 1-line bus [21]. Figure 2: Pin structure of DHT22 Sensor The data transmitted to the MCU consists of 40 bits, 16 bits of relative humidity, 16 bits of temperature and 8 bits of the checksum value. A pull-up resistor is needed between Vcc and the output pin. For this reason you have to use it with a resistance between 4.7K and 10K. Figure 2 shows the pin structure of the DHT22 sensor. 2.3. Arduino IDE The open source Arduino IDE allows you to write code and easily load it to the controllers via USB. The Arduino IDE supports many different controllers, especially Arduino kits (Uno, Mega, Due etc.). This software works on Windows, Mac OS X and Linux. The Arduino IDE is written in the Java language and is based on the language Processing/Wiring. The libraries are written in C and C ++ languages and compiled with AVR-GCC and AVR Libc. The codes for the NodeMCU and Arduino Pro Mini MCUs used in the system have been developed using this interface. 2.4. Blynk iOS and Android Interface Developer Blynk is an IOT platform developed for iOS and Android applications that allows controllers such as Arduino, Rasperry Pi, ESP32, NodeMCU to be controlled over the internet. With this platform, a graphical interface for projects can be developed in a very short time using only Widgets, without having to write any code. Figure 3 American Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) (2018) Volume 50, No 1, pp 181-189 185 shows some Widget Boxes from Blynk. These widgets provide multi-directional flexibility with applications such as timer, display, joystick, gauge, e-mail, twitter, GPS and proximity sensor. Blynk application can use phone or tablet location information via GPS widgets. This feature allows you to calculate the distance between you and your home or workplace, so this information can be transferred to IoT devices when you go home or leave the office. Any IoT device (boiler, alarm, lighting, etc.) can be turned on and off using the distance information. Active-passive states or important warnings about the operation of IoT devices can also be sent as a notification via mobile phone or as a message to an e-mail or twitter account to be defined. Figure 3: Widget Boxes of the Blynk Interface developer Blynk has not been developed for a specific brand or model controller and it is compatible with many different controllers (Arduino, ChipKIT, ESP, Intel, LeMarker, Onion Omega, Rasperry Pi, SparkFun, STM32 ..). These features of the controllers with bluetooth features such as ESP32 enable closed loop communication by consuming low energy on-line by using these features. With all these features, Blynk offers low-cost solutions for IoT developers, and they can also benefit from the cloud service. 3. System Architecture The structure of the system can be seen in Figure 4. The system consists of the NodeMCU controller, which can communicate with the Blynk server via WiFi, Arduino Pro Mini controller, which is on the receiver side in the air conditioning application, RF modules that enable the controllers to communicate wirelessly, output elements (Relay, Transmitter) for controlling the devices via the output pins of the controllers, Blynk "SMART HOME" interface, Blynk server, Cloud and modem respectively. The code that meets the system requirements for NodeMCU and Arduino Pro Mini controllers is written by the Arduino IDE editor. The NodeMCU with embedded WiFi module sends the temperature and humidity values from DHT22 to the Blynk server every 5 seconds. In Blynk application, all digital and analog pins of the selected controllers can be used, as well as a large number of (0-127) virtual pins. In particular, widgets such as display and terminal are realized via virtual pins which can carry 10 bit (0-1023) data. With the SMART HOME application installed on the Android device, numerical information about the Blynk server system is periodically received. American Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) (2018) Volume 50, No 1, pp 181-189 186 Figure 4: Structure of the System The data exchange between the SMART HOME interface and the NodeMCU is bidirectional. With the android interface, the setting parameters such as temperature, humidity, light intensity, weekly program can be displayed and changed on demand. Figure 5 shows the climate (a), weekly program (b) and lighting (c) windows in the Blynk android interface named SMART HOME respectively. (a) (b) (c) Figure 5: Blynk "SMART HOME" user interfaces a) air conditioning b) weekly schedule c) lighting For the application shown in Figure 5 (a), the measured temperature and humidity values are compared with the set values by means of the code written to the controller to control the air conditioning devices. The communication between the NodeMCU and the devices is provided wirelessly by the RF modules. Relay American Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) (2018) Volume 50, No 1, pp 181-189 187 module contacts connected to the digital outputs of the Arduino Pro Mini enable both the on/off control of the air conditioner and the adjustment of the parameters. Figure 6: Daily temperature-humidity change for smart home. With the weekly program feature shown in Figure 5 (b), time can be programmed with 4 different time slots for 7 days a week. If desired, these time settings can be disabled individually. Digital PWM outputs of the NodeMCU are used for lighting control in Fig. 5 (c). The light intensity can be adjusted between 0-100 % by connecting each lighting product to the PWM outputs of the NodeMCU. Figure 6 shows the daily temperature- humidity graph for the home where "Smart Home" application is used. 4. Recommendations In our study, air-conditioning and lighting applications are presented for an IoT-based smart home. Being an appiling issue today, IoT technology, has started to take place in almost every stage of daily life. As a result of increasing interest in smart home applications, home appliances and devices have become available to the internet. In this way, the devices in the home can be monitored and controlled via mobile devices such as mobile phones/tablets. The parameters such as current, voltage, power, temperature and humidity of these devices can be recorded in the cloud and the operating characteristics of the devices can be obtained. By using these data, energy consumption of a household can be reduced by using different methods. In future studies, different solutions will be presented to reduce the energy (electricity, natural gas) costs of households by obtaining energy consumption profiles. 5. Conclusion The number of applications using this infrastructure is constantly increasing as many services are provided via Internet technology. Increasing comfort demand of the people is causing the constant increase in demand for smart and autonomous devices that can do their own work. However, the device cluster, which is formed by these devices communicating with each other over the internet network, rapidly changes our point of view on the internet. Now, the internet is constantly changing our expectations about the future by offering very different possibilities as well as functions like social media tools, e-commerce platform, news source. The concept of IoT, which makes a rapid introduction to our life, is expanding day by day to include different sectors and 0 20 40 60 80 100 20 21 22 23 24 25 26 H um id it y [r H % ] Te m pe ra tu re [ °C ] Time 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 00 American Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) (2018) Volume 50, No 1, pp 181-189 188 applications. In this study, a sample smart home application was implemented using IoT technology and NodeMCU embedded system microcontroller. This system, which can be controlled by the Blynk SMART HOME interface from any environment where the Internet is available, provides a comfortable and smart climate-lighting system. Our achievements in this exemplary application, which is a low cost, fast and reliable solution, will enable us to make new applications in many areas such as industry, health, agriculture, environment, education and energy. References [1] S. Misra, M. Muthucumaru, H. Salman. "System model for the internet of things." Security challenges and approaches in internet of things." Springer, Cham, pp. 5-17, 2017. [2] J. Gubbi, R. Buyya, S. Marusic, M. Palaniswami. "Internet of Things (IoT): A vision, architectural elements, and future directions." Future generation computer systems, vol. 29 (7), pp. 1645-1660, 2013. [3] S. Pirbhulal, H. E. Zhang, M. Alahi, H. Ghayvat, S. Mukhopadhyay, Y. T. Zhang, W. Wu. "A novel secure IoT-based smart home automation system using a wireless sensor network." Sensors, vol. 17(1), 69, 2017. [4] L. Chapman, J. B. Simon. "High-resolution monitoring of weather impacts on infrastructure networks using the Internet of Things." Bulletin of the American Meteorological Society, 2018. [5] L. Pocero, D. Amaxilatis, G. Mylonas, I. Chatzigiannakis, "Open source IoT meter devices for smart and energy-efficient school buildings." HardwareX, vol. 1, pp. 54-67, 2017. [6] R. Morello, C. De Capua, G. Fulco, S. C. Mukhopadhyay. "A Smart Power Meter to Monitor Energy Flow in Smart Grids: The Role of Advanced Sensing and IoT in the Electric Grid of the Future." IEEE Sensors Journal vol. 17.23, pp. 7828-7837, 2017. [7] A. Malhotra, S. Saini, V. V. Kale. “Automated Irrigation System with Weather Forecast Integration” , International Journal of Engineering Technology, Management and Applied Sciences, v. 5 (6), pp. 179- 184, 2017 [8] D. H. Patel, D. Monali. "IOT Compatible Wireless Smart Portable Mini Weather Analyzer." International Research Journal of Engineering and Technology, vol. 4(5), 2017. [9] M. Taştan, "IoT Based Wearable Smart Health Monitoring System", Celal Bayar University Journal of Science, 14(3), pp. 343-350, 2018. [10] S. Ghanavati, H. J. Abawajy, D. Izadi, A. A. Alelaiwi. "Cloud-assisted IoT-based health status monitoring framework." Cluster Computing, vol. 20(2), pp. 1843-1853, 2017. American Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) (2018) Volume 50, No 1, pp 181-189 189 [11] S. Deshkar, R. A. Thanseeh, G. M. Varun. "A Review on IoT based m-Health Systems for Diabetes." International Journal of Computer Science and Telecommunications, vol. 8(1), pp. 13-18, 2017. [12] M. Roopaei, R. Paul, R. C. Kim-Kwang. "Cloud of things in smart agriculture: Intelligent irrigation monitoring by thermal imaging." IEEE Cloud Computing, vol. 4(1), pp. 10-15, 2017. [13] Gökozan, H., Taştan, M., Sarı, A., “Smart Cities and Management Strategies”, II. International Strategic Research Congress, Antalya, Turkey, 2017, pp. 327-331. [14] O. Galinina, K. Mikhaylov, S. Andreev, A. Turlikov, Y. Koucheryavy. "Smart home gateway system over Bluetooth low energy with wireless energy transfer capability." EURASIP Journal on Wireless Communications and Networking, vol. 1, pp. 178, 2015. [15] S. Samuel, I. Sujin. "A review of connectivity challenges in IoT-smart home." Big Data and Smart City (ICBDSC), 2016 3rd MEC International Conference on. IEEE, 2016. [16] B. Alohali, M. Merabti, K. Kifayat. "A secure scheme for a smart house based on Cloud of Things (CoT)." In Computer Science and Electronic Engineering Conference (CEEC), 2014 6th , pp. 115-120, 2014. [17] B. H. Vishwajeet, W. Sanjeev "i-learning IoT: An intelligent self learning system for home automation using IoT." Communications and Signal Processing (ICCSP), 2015 International Conference on. IEEE, 2015. [18] X. Ye, J. Huang."A framework for cloud-based smart home. In Computer science and network technology (ICCSNT), 2011 international conference on, IEEE, vol. 2, pp. 894-897, 2011. [19] http://www.handsontec.com/pdf_learn/esp8266-V10.pdf [20] http://www.atmel.com/Images/Atmel-42735-8-bit-AVR-Microcontroller-ATmega328-328P.pdf [21] https://www.sparkfun.com/datasheets/Sensors/Temperature/DHT22.pdf