|Intelligent Automation & Soft Computing |
Smart Lamp Using Google Firebase as Realtime Database
1Department of Electrical Engineering, National Chin-Yi University of Technology, Taichung, 411030, Taiwan
2Department of Information Technology, Takming University of Science and Technology, Taipei City, 11451, Taiwan
*Corresponding Author: Sung-Jung Hsiao. Email: email@example.com
Received: 26 October 2021; Accepted: 26 November 2021
Abstract: Along with modernization in Indonesia, electricity users often do not realize that electrical energy is still used from electronic devices left on and unused. Much electrical energy is wasted due to unwise use. Modernization requires creative automation. This significantly minimizes the amount of human labor needed to complete the job. Energy efficiency is critical due to environmental concerns and limited research on alternative renewable energy sources. When evaluating the impact of technology on the environment, energy is an essential factor to consider. Most big cities and provinces in Indonesia still use conventional lighting systems where electricity users manually turn on and off lights. Current lighting systems combine compact fluorescent lamps (CFLs) with integrated high-pressure sodium lamps to provide illumination. However, average utilization generates high demand, and more than 40% of the total energy generates waste electricity. That’s why the smart lamp is one of the technologies that people are looking for to innovate on existing technology to realize the innovative home concept in the smart living era. In this report, the author will discuss the manufacture of smart lamps dedicated to the 315 laboratories as learning materials for the future. In designing this smart lamp, the author uses firebase by google as the network layer. Many researchers use other types of cloud bases, but this time the author tends to prefer firebase because of the advantages of the cloud system by Google.
Keywords: IoT; smart lamp; firebase; realtime database
Along with modernization in Indonesia, electricity users often do not realize that electrical energy is still used from electronic devices left on and unused. As a result, a lot of electrical energy is wasted due to unwise use. Modernization requires creative automation. This significantly minimizes the amount of human labor needed to complete the job. Energy efficiency is critical due to environmental concerns and limited research on alternative renewable energy sources. When evaluating the impact of technology on the environment, energy is an essential factor to consider. Most big cities and provinces in Indonesia still use conventional lighting systems where electricity users manually turn on and off lights . Current lighting systems combine compact fluorescent lamps (CFLs) with integrated high-pressure sodium lamps to provide illumination. However, the average utilization generates high demand, and more than 40% of the total energy generates waste electricity [2,3]. Nowadays, the Internet has spread to almost every corner of the world and unprecedentedly affects people’s lives. Without us realizing it, we live in the era of the “Internet of Things” (IoT for short). Internet of Things (IoT) is a paradigm in which items with sensors, actuators, and processors communicate to achieve specific goals. Then many terms appear smart home, smart city, to smart office . For this reason, smart lights are one of the technologies that people are looking for to innovate on existing technology to realize the concept of an innovative home in the smart living era. This paper discusses the design of smart lamps dedicated to 315 laboratories as learning materials for the future. In designing this smart lamp, the author uses Firebase by Google as the network layer. Firebase is a cloud service that combines many of Google’s cloud services, such as instant messaging, user authentication, real-time databases, storage, and hosting . Many researchers use other types of cloud bases, but this time the author tends to prefer Firebase because of the advantages of the cloud system by Google. The firebase real-time database Emulator is part of the Local Emulator Suite that allows applications to interact with the configuration and content of the emulated database and optionally with emulated project resources (functions, other databases, and security rules) as Android studio . In this system, the firebase real-time database is used as a storage mechanism to store information on the power usage of the smart lamp.
2 Literature Review
2.1 Internet of Things
From 1969 until now, the internet has become one of the most critical foundations in technological progress globally. One of the renewable technologies that use the internet as its focus is IoT (Internet of Things). The Internet of Things idea and accompanying technologies provide the physical foundation and assurance for the interconnectedness of all things . With the rapid adoption of Internet of Things (IoT) solutions, there is a growing concern about security vulnerabilities arising from connected devices. So that in the research of C. Lee and A. Fumagalli, IoT has become a technology with excellent security . With the accelerated development of smart devices and the Internet of Things (IoT) technology, some traditional business sectors embrace new possibilities [9,10]. Communication technologies, which enable all devices to connect, communicate, and exchange data, are a critical component in the development of IoT systems. As a result, the system can monitor, collect, exchange, and analyze data, providing valuable services that enable industry businesses to make more accurate and timely decisions . The perception, network, and application layers are the three main layers of integrated IoT. Although it is only three layers, it can be elevated if necessary .
2.2 Smart Light
Because of the relationship between smart light and everyday life, it is particularly essential in research. In Prasad’s research, smart lighting is used on street lights . Defines street lighting as a crucial aspect in promoting city safety and providing a sense of security in inhabitants’ minds. Prasad’s research focuses more on energy-efficient so that we can control while saving power. Balushi et al.  identify Intelligent Street Lights System based on LED lights as one of the essential concepts in today’s life by using smart lighting in street lights. Also, the street lights, which are turned on automatically all night, consume a lot of electricity. Ultrasonic sensors are used by Balushi et al.  to control street lights so that they only turn on when a car passes by. And many more studies that apply smart lamp in indoor and outdoor such as studies [15–17]. In this study, the authors focus more on smart homes using smart lights that can adjust lights manually or automatically through an application on a smartphone.
2.3 Firebase Realtime Database
Firebase is a database based on NoSQL (not SQL) . In recent years, Firebase has become widely known and used by developers, including in Indonesia. Cloud Messaging with Firebase It is an effective technique for sending notifications to mobile applications via data messages, influencing mobile applications behavior on smartphones. The system is built to handle multiple Firebase applications simultaneously and communicate data messages that the programmer has prepared, either manually or by obtaining data from another environment. Google firebase is better than other databases because real-time value updates are faster than other databases. If other databases take up to 15 seconds, then google firebase takes only one second . The purpose of this system was to store the information for applications that require control and data. Information from messages can be stored in the local system database .
3 Proposed System
3.1 System Architecture
Fig. 1 shows the system architecture of this study. The internet of things architecture includes the physical, network, and application layers of the architecture. In the physical layer, there are some things connected to the network layer that has NodeMCU. App users can control the lamp using the Firebase Realtime Database, and all data is stored in the app.
3.2.1 NodeMCU ESP8266
NodeMCU is a Lua-based open-source firmware and development board explicitly designed for IoT-based applications. It includes firmware that works on Espressif Systems’ ESP8266 Wi-Fi SoC and hardware based on the ESP-12 module. NodeMCU is an Internet of Things device that can serve as both a publisher and a subscriber. The publisher will send data to the server, and the subscriber will view it and compare the error and time required for all of the data . The ESP-12E module on the NodeMCU ESP8266 development board contains the ESP8266 chip with Tensilica Xtensa 32-bit LX106 RISC microprocessor. This microprocessor runs on a configurable clock frequency of 80 MHz to 160 MHz and supports RTOS. The NodeMCU contains 128 kB of RAM and 4 MB of Flash memory to store data and programs. It is perfect for IoT projects due to its high processing power, built-in Wi-Fi/Bluetooth, and Deep Sleep Operating capabilities. Fig. 2 shows the structure of the ESP8266.
3.2.2 Relay Module
The four-channel relay module has four 5 V relays and the accompanying switching and isolating components, allowing for simple interfacing with a microcontroller or sensor with the fewest possible components and connections. Each relay’s contacts are rated for 250 VAC, 30 VDC, and 10 A in each case, as indicated on the body of the relays. This module turns on and off other electronic equipment powered by 240 VAC electrical AC or DC high-voltage devices (up to 28 VDC), such as high-power DC motors. Each channel of the device has a maximum current of 7 Ampere . Fig. 3 presents the relay module.
3.2.3 RTC DS1302
The DS1302 uses a simple serial interface to communicate with the CPU. Real-time clock/calendar showing seconds, minutes, hours, day, date, month, and year. For months with fewer than 31 days, the month’s end date is automatically changed, including leap year corrections. The clock has an AM/PM indicator and works 24 hours or 12-hour mode . DS1302 in this study is used in determining the time on the auto option. Fig. 4 shows the structure of the DS1302.
3.2.4 LED Light Bulbs
Today’s most energy-efficient and rapidly-developing lighting technology is the light-emitting diode (LED). Quality LED light bulbs last longer, are more durable, and provide light quality comparable to or better than other types of lighting . The author chose this type of LED lamp because LED is a lighting technology that is very energy efficient and can fundamentally change the future of lighting. Residential LEDs use at least 75% less energy and last up to 25 times longer than incandescent bulbs. Fig. 5 presents LED light bulbs.
Fig. 6 shows this flowchart of the working system. There are two system settings on this smart lamp, the first auto and the second manually. On auto, we can set the start time and end time so that the lights will turn on automatically according to a predetermined time, and this setting is maximized up to three settings on each lamp. Then in the manual, the lights can be turned on and off remotely through an application connected to the internet. After inputting data, the RTC modules will send values to NodeMCU. After that, data will be transmitted to Firebase’s cloud management platform for further processing. Fig. 7 shows the system function block diagram.
The Smart Lamp experiment uses two cases to compare the benefits of using Smart Lamps. Case I (using smart lamp) A house has four rooms where each room has a lamp, where the room is divided into the living room, kitchen, bedroom one, and bedroom two. Because case 1 uses smart lamps, so the lights have been set using a timer. Then the living room only turns on the lights 2 h every night, the kitchen 2 h every night, Bedroom 1 is turned on from 6 PM to 10 PM, and bedroom 2 from 6 PM to 12 PM. Then in case II (not using smart lamps), a house has four rooms where each room has a lamp. Where without a smart lamp, users sometimes forget to turn off the lights until morning. So, the lights in the living room are turned on from 6 PM to 7 AM, kitchen from 6 PM to 10 PM, Bedroom 1 from 7 PM to 6 AM, and Bedroom 2 from 7 PM to 6 AM. For these two cases, we assume one month equals 30 days, the light bulb uses 11 W of power.
4.1 Power Consumption
The calculation results of the two cases can be seen in Tab. 1. The total power consumption in Case 1 is only 4.62 kWh/Mo, whereas Case 2, which does not use a smart lamp, can consume 9.64 kWh/Mo of power. Therefore, if every house uses a smart lamp, each home can save energy by 8.25 kWh/Mo. It is important to note that the more electrical energy stored, the more electricity that can be diverted to more critical uses so that no electricity is wasted.
4.2 Cost Analysis
In essence, in analyzing the usability and efficiency of a smart lamp and testing power consumption, cost analysis is also needed in analyzing a smart lamp. In this cost comparison, the authors use kWh data from three different currencies, namely IDR from Indonesian Rupiah, US Dollar, and New Taiwan Dollar. All this data is obtained from the latest government information. There is a very significant difference (can be seen in Tab. 2). In case 1, it can be seen that if the smart lamp is used in Indonesia, the user only needs to pay Rp. 1940 /month. Whereas if the user does not use a smart lamp, then the user will pay Rp. 5405/month and cost analysis in cases one and two in Washington DC and Taiwan. Therefore, if the user uses a smart lamp, the user will save up to 90% more lamp costs than not using a smart lamp. Further explanation in the use of cases 1 and 2 in the real world will be explained in the results section.
The results of this study are in the form of applications and prototypes of smart lamps. This application is called smart lamps, and the function of this application is as a controller of the prototype smart lamps. Fig. 8a shows the splash screen design that reads the smart lamp and the background of the house as the icon. See Fig. 8b, the home page for the smart lamp application where there are two settings, namely auto, and manual which can be pressed and connected to the next page. If the user presses the manual button, the user will enter the manual page, as shown in Fig. 8c, where on this page there is an on/off for each option. Then when the user presses the auto to see a button for Fig. 9a, there will be four icons that say living room, kitchen, bedroom one, and bedroom two. The user can press each icon on this page, and if one icon is pressed, it will open the control time for the lamp page. We assume that we pressed the living room button. It will be opened to the living room control page as shown in Fig. 9b, then to set the time, the user presses enter time, and the timer will automatically open. The user needs to set the time as shown in Fig. 9c, and if the user sets the time, the user can click the ok button, and the data will automatically be sent to the firebase.
It can be seen from Fig. 10 shows the result in testing the success of the manual option. In the manual test, the user repeatedly turns the lights on and off through the smart lamp control application to see the response and resistance of the smart lamp. See Fig. 10a. The user shows that the user presses the Kitchen button to turn on the particular light for the kitchen. When the light turns on, shown in Fig. 10b, the response from the control in the Firebase can be seen in Fig. 11. Where switch 2, namely the kitchen, is changed to “ON” in less than 1 s.
It can be seen from Fig. 12 shows the result in testing the success of the auto option. In the auto test, the user sets the timer at different times simultaneously through the smart lamp control application repeatedly to see the response and resistance of the smart lamp. For example, see Fig. 12a, and the user shows that the user set the time at 03.25. Then, the light is turned on, shown in Fig. 12b. And the response from the control in Firebase is shown in Fig. 13, where setLR1start 3:25 and setLR1end 3:41. Therefore. As a result, we can conclude that the light will turn on automatically at a time range of 3:25 to 3:41. Data sent from NodeMCU to Firebase takes less than 1 s.
Fig. 14 shows the comparison and analysis diagram of the power consumption of case 1 and case 2 based on the content of Tab. 1. Case1 is the case of using smart lights. And case 2 is an electric lamp using traditional general control. In terms of power consumption, the power consumption of Case 1 is relatively low, which is relatively power saving. Although all the compared space sites are different, the trend of all-electric power consumption is proportional to the use time.
The following experiment of this research uses ten common spaces in the home to analyze power consumption. The ten spaces are the bathroom, living room, kitchen, dining room, parent’s room, elder room, son room, daughter room, maid room, and storeroom. Please refer to Tab. 3 for detailed data. This experiment compares the power consumption of using a smart lamp and not using the smart lamps. Please refer to Fig. 15. It is clear from Fig. 15 that using smart lamps consumes less energy. Fig. 16 illustrates the time situation of using smart lamps in different spaces of these ten homes. The following experiment uses a regression algorithm to predict the power consumption of using and not using a smart lamp.
The linear regression equation can be obtained by substituting the collected data into Eqs. (1) and (2) to obtain the intercepts called a and slope b. Here x is the power consumption data of each place, and y is the time used in each place every one month.
This Eq. (3) is Linear regression equation:
The represents the predicted value of the trend curve and can predict the power consumption and use time. If the “regression variation” is getting closer to the “total variation”, it means that the variation of the dependent variable can be explained by the regression model, which means that the regression model is very suitable. The ratio of “regression variation” to “total variation” is called the coefficient of determination, and the table is R2(0 ≤ R2 ≤ 1), please see the Eq. (3).
SSE: Sum of Squares Error
SSR: Sum of Squares Regression
SST: Sum of Squares Total
According to the analysis results of Figs. 17 and 18, the power consumption prediction line using smart lamp performs better.
Technological developments do not rule out the possibility of many new problems that arise, as is often faced by society in general, one of which is the waste of electrical power, laziness and forgetfulness are often a factor in the amount of energy being wasted. Therefore, the authors researched smart lamps that aim to overcome the above problems. Although many other studies have discussed smart lamps, the results of our research are different from other studies. Because this research uses Google Firebase as a database where Google Firebase uses JSON, is directly connected to Android Studio, and is more user friendly than others. So that system makers can more easily monitor and solve problems in the system. Then this study also uses cost analysis and power consumption as a guide in determining the quality of smart lamps. That’s why our approach can be proven that this research produces an application as a control in smart lights. The application makes it easy for users to control lights remotely just by using the internet. After being tested using cost analysis and power consumption, it turns out that this smart lamp saves power by 8.25 kWh/Mo and saves electricity costs for lamps by up to 90%. As a result, unused power can be put to better use. This research is expected to be developed in the future.
Acknowledgement: This research was supported by the Department of Electrical Engineering, National Chin-Yi University of Technology. The authors would like to thank the National Chin-Yi University of Technology, Takming University of Science and Technology, Taiwan, for financially supporting this research.
Funding Statement: The authors received no specific funding for this study.
Conflicts of Interest: The authors declare that they have no conflicts of interest to report regarding the present study.
|This work is licensed under a Creative Commons Attribution 4.0 International License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.|