[BACK]
Intelligent Automation & Soft Computing
DOI:10.32604/iasc.2022.024664
images
Article

Smart Lamp Using Google Firebase as Realtime Database

Wen-Tsai Sung1, Ihzany Vilia Devi1 and Sung-Jung Hsiao2,*

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: sungjung@gs.takming.edu.tw
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

1  Introduction

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 [1]. 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 [4]. 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 [5]. 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 [6]. 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 [7]. 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 [8]. 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 [11]. 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 [12].

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 [13]. 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. [14] 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. [14] 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 [1517]. 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) [18]. 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 [19]. 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 [20].

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.

images

Figure 1: System architecture

3.2 Hardware

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 [21]. 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.

images

Figure 2: NodeMCU 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 [22]. Fig. 3 presents the relay module.

images

Figure 3: 4 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 [23]. DS1302 in this study is used in determining the time on the auto option. Fig. 4 shows the structure of the DS1302.

images

Figure 4: RTC 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 [24]. 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.

images

Figure 5: LED light bulbs

3.3 Software

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.

images

Figure 6: System smart lamp flowchart

images

Figure 7: System function block diagram

4  Experiments

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.

images

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.

images

5  Results

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.

images

Figure 8: App splash screen and options. (a) App open the homepage (b) Operation mode selection (c) Various room settings

images

Figure 9: App automatic settings and options. (a) Home page in automatic mode (b) Various settings in the living room (c) Time setting display

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.

images

Figure 10: App manual setting and testing (a) Setting options in manual mode (b) Turn on the smart lamp

images

Figure 11: Respond control in Firebase

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.

images

Figure 12: App automatic selection and testing. (a) Execution situation in automatic mode (b) Turn on smart lamp situation

images

Figure 13: Another respond control in firebase

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.

images

Figure 14: Case 1 and case 2 compare power consumption

images

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.

images

Figure 15: Comparison of power consumption between using smart lamp and not using smart lamp

images

Figure 16: Monthly usage time of space in each home

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.

b=(ni=1nxiyii=1nxii=1nyi)/(ni=1nxi2(i=1nxi)2) (1)

a=(i=1nyibi=1nxi)/n (2)

This Eq. (3) is Linear regression equation:

y^=bx+a (3)

The y^ 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).

R2=SSRSST=SSTSSESST=1SSESST (4)

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.

images

Figure 17: The trend regression line of case 1

images

Figure 18: The trend regression line of case 2

6  Conclusions

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.

References

  1. M. Mahoor, F. R. Salmasi and T. A. Najafabadi, “A hierarchical smart street lighting system with brute-force energy optimization,” IEEE Sensors Journal, vol. 17, no. 9, pp. 2871–2879, 2017.
  2. R. Lohote, T. Bhogle, V. Patel and V. Shelke, “Smart street light lamps,” in Proc. 2018 Int. Conf. on Smart City and Emerging Technology (ICSCET), Mumbai, India, pp. 1–5, 2018.
  3. G. Jia, G. Han, A. Li and J. Du, “SSL: Smart street lamp based on fog computing for smarter cities,” IEEE Transactions on Industrial Informatics, vol. 14, no. 11, pp. 4995–5004, 2018.
  4. P. Sethi and S. R. Sarangi, “Internet of things: Architectures, protocols, and applications,” Journal of Electrical and Computer Engineering, vol. 2017, no. 1, pp. 1–25, 2017.
  5. W. Li, C. Yen, Y. Lin, S. Tung and S. Huang, “JustIoT internet of things based on the firebase real-time database,” in Proc. 2018 IEEE Int. Conf. on Smart Manufacturing, Industrial & Logistics Engineering (SMILE), Hsinchu, Taiwan, pp. 43–47, 2018.
  6. K. M. Hlaing and D. E. Nyaung, “Electricity billing system using ethereum and firebase,” in Proc. 2019 Int. Conf. on Advanced Information Technologies (ICAIT), Yangon, Myanmar, pp. 217–221, 2019.
  7. J. Yanhong, “Design and research of music internet of things,” in Proc. 2021 IEEE 2nd Int. Conf. on Big Data, Artificial Intelligence and Internet of Things Engineering (ICBAIE), Nanchang, China, pp. 1050–1053, 2021.
  8. C. Lee and A. Fumagalli, “Internet of things security - Multilayered method for end to end data communications over cellular networks,” in Proc. 2019 IEEE 5th World Forum on Internet of Things (WF-IoT), Limerick, Ireland, pp. 24–28, 2019.
  9. J. Leng, Z. Lin and P. Wang, “Poster abstract: An implementation of an internet of things system for smart hospitals,” in Proc. 2020 IEEE/ACM Fifth Int. Conf. on Internet-of-Things Design and Implementation (IoTDI), Sydney, NSW, Australia, pp. 254–255, 2020.
  10. C. Zhang, “Intelligent internet of things service based on artificial intelligence technology,” in Proc. 2021 IEEE 2nd Int. Conf. on Big Data, Artificial Intelligence and Internet of Things Engineering (ICBAIE), Nanchang, China, pp. 731–734, 2021.
  11. P. Salunke and J. Kate, “Advanced smart sensor interface in internet of things for water quality monitoring,” in Proc. 2017 Int. Conf. on Data Management, Analytics and Innovation (ICDMAI), Pune, India, pp. 298–302, 2017.
  12. G. Han, H. Wang, X. Miao, L. Liu, J. Jiang et al., “A dynamic multipath scheme for protecting source-location privacy using multiple sinks in WSNs intended for IIoT,” IEEE Transactions on Industrial Informatics, vol. 16, no. 8, pp. 5527–5538, 2020.
  13. R. Prasad, “Energy efficient smart street lighting system in Nagpur smart city using IoT-A case study,” in Proc. 2020 Fifth Int. Conf. on Fog and Mobile Edge Computing (FMEC), Paris, France, pp. 100–103, 2020.
  14. A. A. H. A. Balushi, S. I. A. Kazmi, J. Pandey, A. V. Singh and A. Rana, “The intelligent control of street light system in Oman through internet of things technology,” in Proc. 2020 8th Int. Conf. on Reliability, Infocom Technologies and Optimization (Trends and Future Directions) (ICRITO), Noida, India, pp. 694–698, 2020.
  15. N. Saokaew, N. Kitsatit, T. Yongkunawut, P. N. N. Ayudhya, E. Mujjalinvimut et al., “Smart street lamp system using LoRaWAN and artificial intelligence PART I,” in Proc. 2021 9th Int. Electrical Engineering Congress (iEECON), Pattaya, Thailand, pp. 189–192, 2021.
  16. A. N. Cihan and G. N. Güğül, “An indoor smart lamp for environments illuminated day time,” in Proc. 2020 IEEE East-West Design & Test Symposium (EWDTS), Varna, Bulgaria, pp. 1–5, 2020.
  17. S. Li and J. Liu, “Research on smart city lighting system based on conduction angle communication,” in Proc. 2020 19th Int. Sym. on Distributed Computing and Applications for Business Engineering and Science (DCABES), Xuzhou, China, pp. 162–165, 2020.
  18. K. M. Hlaing and D. E. Nyaung, “Electricity billing system using ethereum and firebase,” in Proc. 2019 Int. Conf. on Advanced Information Technologies (ICAIT), Yangon, Myanmar, pp. 217–221, 2019.
  19. L. Goswami and P. Agrawal, “IOT based diagnosing of fault detection in power line transmission through GOOGLE firebase database,” in Proc. 2020 4th Int. Conf. on Trends in Electronics and Informatics (ICOEITirunelveli, India, pp. 415–420, 2020.
  20. M. A. Mokar, S. O. Fageeri and S. E. Fattoh, “Using firebase cloud messaging to control mobile applications,” in Proc. 2019 Int. Conf. on Computer, Control, Electrical, and Electronics Engineering (ICCCEEE), Khartoum, Sudan, pp. 1–5, 2019.
  21. S. S. Prayogo, Y. Mukhlis and B. K. Yakti, “The use and performance of MQTT and CoAP as internet of things application protocol using NodeMCU ESP8266,” in Proc. 2019 Fourth Int. Conf. on Informatics and Computing (ICIC), Semarang, Indonesia, pp. 1–5, 2019.
  22. T. H. Nasution, M. A. Muchtar, I. Siregar, U. Andayani, E. Christian et al., “Electrical appliances control prototype by using GSM module and Arduino,” in Proc. 2017 4th Int. Conf. on Industrial Engineering and Applications (ICIEA), Nagoya, Japan, pp. 355–358, 2017.
  23. C. Hsu and K. Wen, “Monolithic integration of digital MEMS thermometer and temperature compensated RTC on 1P6M ASIC compatible CMOS MEMS process,” in Proc. 2018 IEEE Int. Conf. on Semiconductor Electronics (ICSE), Kuala Lumpur, Malaysia, pp. 45–48, 2018.
  24. F. Zhao, G. Dong, G. Yang, Y. Zeng, B. Shieh et al., “Study on light emitting surface temperature of LEDs,” in Proc. 2020 21st Int. Conf. on Electronic Packaging Technology (ICEPT), Guangzhou, China, pp. 1–5, 2020.
images 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.