Design of an IoT-Based Automatic Switching System Using Blynk Software

ABSTRACT


INTRODUCTION
Electricity is a fundamental necessity in modern society, powering a wide range of daily activities and technologies [1], [2].The generation of electrical energy involves various sources, such as hydroelectric, thermal, nuclear, and fossil fuel-based power generation.Excessive electricity consumption poses a significant challenge, especially when reliant on non-renewable sources like fossil fuels, as their depletion is inevitable and detrimental to the environment.To ensure the sustainable use of resources, it is imperative to optimize the utilization of electrical energy, preserving the Earth's ecological balance and finite natural resources [3].
However, the current consumption of electrical energy is often inefficient due to the pervasive overuse of electronic appliances.Users frequently overlook the importance of responsible electricity use.Virtually all electronic devices rely on electricity for their operation, with one of the most energy-consuming devices being lighting systems.Lighting serves the essential purpose of illuminating spaces, particularly during nighttime or in dark environments.Yet, a common issue is the misuse of lighting equipment, with lights often left on unnecessarily, even when unattended or not in use.This rampant energy wastage is a significant concern and calls for immediate action.One practical solution is implementing an automatic lighting control system, capable of activating and deactivating lights at predetermined intervals, thereby promoting energy efficiency and conservation [4], [5].
The issue addressed in this research is related to the inefficient use of electrical devices.For example, the activation technology of electrical devices, such as lamps, still relies on switches attached to the wall, which is less efficient.This inefficiency leads to increased energy costs if occupants are negligent in turning off the lights through conventional switches.This impedes progress towards sustainable energy practices.To address this issue, the research aims to develop and implement a control system for electrical devices applicable to lighting through wireless devices.This system is designed to optimize electricity usage by responding to userdefined settings, ensuring that electrical devices are only active when needed, and can be wirelessly controlled via mobile devices.Several studies on the use of Blynk to activate switches have already been conducted, demonstrating the significant potential of this technology inefficiently and remotely controlling electronic devices.Blynk, as an Internet of Things (IoT) application development platform, has proven to provide a flexible and user-friendly solution for integrating physical devices with smartphone applications.Just like Sirojul et al., research has been conducted on the control of home lights using voice commands with the assistance of Google Assistant to recognize sentences spoken by residents, along with the support of Blynk.They utilized the Internet of Things (IoT) method and achieved success [6].Then, other research also uses Blynk for monitoring energy consumption [7].Blynk is an IoT-based application that is beneficial and userfriendly [8].Based on the previous research, the author also uses the Blynk application to control the electronic switching component.
The primary aim of this research is to develop and implement an automatic lighting control system, designed to optimize electricity use by controlling lighting conditions in response to user-defined settings.This system automatically turns lights on and off according to a predefined schedule, ensuring that lights remain illuminated only when needed.In doing so, it reduces energy waste, prevents excessive current supply to lighting fixtures, and promotes responsible electronic appliance usage.By addressing these issues, the automatic lighting control system not only enhances energy efficiency but also aligns with government initiatives for sustainable energy use and environmental conservation.This paper delves into the design, development, and practical applications of this system, shedding light on its technical aspects and the tangible benefits it offers for users and the environment alike.
This article consists of several sections.The introduction provides a comprehensive overview, setting the stage for the study by introducing the research topic, emphasizing its significance, and outlining specific objectives.Subsequently, the methods section explains the research design and methodology, as well as the tools and materials used.The results section presents the factual outcomes of the research in a clear and organized manner.The discussion section interprets the results of the conducted research.Finally, the conclusion synthesizes the findings obtained based on the objectives of this research.

METHOD
In the research journal, the methodology involves utilizing various components to create an automated control system.The block diagram system is shown in Fig. 1.This system is built wirelessly for user convenience.The wireless system consists of a transmitter system (Tx) and a receiver system (Rx) [9].Several components develop the system.The components are: 1. ESP8266 Microcontroller: The ESP8266 microcontroller serves as the core component of the system.It is a powerful and versatile microcontroller that provides the brains for the automation.The ESP8266 enables wireless communication and control, making it an ideal choice for IoT applications [4], [5], [10].2. Micro USB Data Cable: A micro USB data cable is used for programming and powering the ESP8266 microcontroller.It facilitates the connection between the microcontroller and a computer, allowing for programming and data transfer.3. Single 1CH 10A 220VAC Relay: The single-channel relay is employed as the switch for controlling the 220VAC electrical circuit.It allows the system to interrupt or complete the electrical circuit as needed, enabling remote control of devices such as lighting or power outlets [5], [11].4. Arduino IDE Software: The Arduino Integrated Development Environment (IDE) software is used for programming the ESP8266 microcontroller.It provides a user-friendly platform for writing and uploading code to the microcontroller, enabling the customization of automation logic [12]. 5. WiFi Modem: A WiFi modem is used to establish a wireless internet connection, enabling the ESP8266 to communicate with the Blynk application and other remote devices.This connection is crucial for remote control and monitoring [13].
6. Blynk Application on Smartphone: The Blynk application is installed on a smartphone and serves as the user interface for controlling and scheduling the automated system.Users can set schedules, manually control devices, and monitor the status of the system through this user-friendly mobile app [5], [14], [15].

Figure 1. The Block Diagram System
The code is used for a program written in the Arduino IDE programming language to control a device using the Blynk platform and an ESP8266 microcontroller.Each part of the code is as follows: 1. #define BLYNK_DEVICE_NAME "LINUS" and #define BLYNK_AUTH_TOKEN "8eNviIQPBXSgpZxEgvt5ibBF6Xhxbk2h: In this section, you define the device name (BLYNK_DEVICE_NAME) and the authentication token (BLYNK_AUTH_TOKEN) used to connect the device to the Blynk server.The authentication token is the key that allows the device to connect to our Blynk account.2. #define BLYNK_PRINT Serial: Defines the use of serial output for debugging.This allows you to view debug messages in the Serial Monitor in the Arduino IDE. 3. #include <ESP8266WiFi.h>and #include <BlynkSimpleEsp8266.h>:These are directives that include libraries required to connect the ESP8266 device to the WiFi network and the Blynk server.4. char auth[] = BLYNK_AUTH_TOKEN: This is a variable used to store the Blynk authentication token. 5. char ssid[] = "WeBareBears"; and char pass[] = "*******": These are variables that store the name and password of the WiFi network to be used by the ESP8266 device.6. BlynkTimer timer: This is a timer object used to run functions periodically.7. boolean flag = true: You define a boolean variable "flag" initialized with the value "true."8. void sendFlagToServer(): This is a function that will be called repeatedly by the timer.This function sends the value "0" or "1" to the Blynk server based on the "flag" variable, which will be used to control the device in the Blynk application.9. BLYNK_WRITE(V1): This is a function that will be called when there is a change on virtual pin V1 in the Blynk application.However, in the provided code, there is no actual implementation in this function.10. void setup(): This function is executed once when the device is first powered on.Inside it, you set up the WiFi and Blynk server connections and initialize the timer.11. void loop(): This function runs continuously.Inside it, you run Blynk.run() to process communication with the Blynk server and timer.run() to execute the "sendFlagToServer" function periodically.
The code is essentially used to connect the ESP8266 device to the Blynk server, set up the WiFi connection, and send data (either "0" or "1") to the Blynk server.However, in the provided code, there is no actual implementation for device control or data processing.You need to add specific logic in the BLYNK_WRITE(V1) and sendFlagToServer functions to control the device or process data as needed.

RESULTS AND DISCUSSION
In this part, the system design will be explored, along with performance evaluations and practical implications of the system.The research results include an analysis of various aspects of the system design, including the system's response to different inputs.The system design encompasses the selection of components, sensor choices, and parameter settings to achieve specific goals.Additionally, programming is required to execute microcontroller operations.Performance evaluations involve testing the system under different conditions to understand how well it meets the desired needs and expectations.The practical implications of the research results will be discussed, including the potential for further development, realworld applications, and its impact on related fields.This chapter aims to provide a comprehensive understanding of the research findings, linking them to practical implications and potential advancements in the designed system.A simple circuit successfully designed and built is shown in Figure 2. The main circuit consists of two components: a microcontroller and a relay.A relay is linked to a NodeMCU ESP8266 to manage and interrupt a 220V electrical circuit.Control of the NodeMCU ESP8266 is facilitated through the Blynk application, employing two key widgets: the button and Eventor.The Eventor widget serves the purpose of scheduling when a connected component should be powered on or off.Additionally, a manual button control is available for immediate relay control.Generally, relays come equipped with three input terminals, but in most cases, only two are used: one for the power source and the other connected to the target electronic device.
This system comprises a NodeMCU ESP8266 and a relay, where the relay essentially acts as a switch for a variety of 220V electronic devices.The relay operates using two distinct states: 1 (indicating no current flow) and 0 (signifying the passage of current).The relay's status is visually conveyed by a red indicator light when it's in the off state and a green light when it's turned on.The transitions between these states are perceptible through a distinct "click" sound.

Figure 2. The system electronic circuit
The relay is intricately connected to the NodeMCU ESP8266 for centralized control, with the NodeMCU being seamlessly managed through the Blynk application.Blynk stands as a ubiquitous platform for developing Internet of Things (IoT) applications, enabling remote oversight and control of various devices.It's important to note that relay performance may exhibit differences compared to other components when transitioning between the 0 and 1 states.Figure 3.The system electronic circuit It's crucial to emphasize that the relay operates on a 5V power supply, while the NodeMCU is limited to a 5V output.To achieve optimal relay performance, an additional step-up component is required.Within the Blynk application, two pivotal widgets, namely Eventor and Button shown in Figure 3, are utilized for relay control.The Button widget is utilized for manual relay control, whereas the Eventor widget serves to schedule relay operations based on specific days (Monday to Sunday) and allows for setting precise on/off times that correspond to the user's local time zone.
The emphasis on the 5V power supply for the relay and the NodeMCU's 5V output highlights a potential limitation in the hardware compatibility.The inclusion of an additional step-up component is a practical solution to address this limitation, ensuring the relay operates optimally within the system.The integration of two key Blynk widgets, namely the Button and Eventor, demonstrates a strategic approach to relay control within the application.The Button widget offers users manual control over the relay, providing a the NodeMCU ESP8266 The relay (ON) straightforward and immediate way to activate or deactivate it with a single touch.This manual control feature enhances user convenience and flexibility in managing the relay's status.On the other hand, the utilization of the Eventor widget introduces an automated scheduling aspect to relay operations.This scheduling functionality based on specific days of the week, coupled with the ability to set precise on/off times corresponding to the user's local time zone, enhances the system's versatility.Users can program the relay to operate automatically according to their preferred schedule, contributing to energy efficiency and user customization.The combination of manual and automated control options within the Blynk application caters to different user preferences and scenarios.This dual-control strategy allows for real-time adjustments through manual control while providing the convenience of hands-free, scheduled operations.It aligns with the broader trend of smart home applications that prioritize user-friendly interfaces and customizable automation features.
The use of the Blynk application can be further developed by adding existing features.For example, integration with additional sensors to monitor environmental conditions or the addition of setting modules to optimize energy efficiency.Furthermore, development could involve enhancing the user interface to be more intuitive and responsive.By continually expanding the functionality of the application, users can have a richer experience and access more control over connected systems.Thus, considering feature enhancements in the Blynk application opens up opportunities to improve usability and reliability in scenarios of relay control and broader IoT applications.This will be tested in the next research.

CONCLUSION AND SUGGESTION
The implementation of a scheduled automatic switch offers significant advantages to users, eliminating the need for manual control of lighting systems and thereby reducing electricity wastage.This system can be constructed using simple components, and the use of Blynk as a free and universal IoT platform makes it accessible to a wide range of users.
Furthermore, this automatic switch is not limited to controlling lights but can also be extended to other applications within the home, such as controlling power outlets, for example, for charging mobile phones.However, it is important to note that the relay used in this system has a capacity of 10A, and therefore it is not recommended for high-current electronic devices.
Here are some suggestions for the implementation of the scheduled automatic switch system: • First and foremost, it is essential to prioritize safety when setting up this system.Users should ensure that all electrical components are installed in a manner that complies with local electrical safety standards.Safety is paramount to prevent any electrical hazards and ensure the well-being of individuals and property.• Additionally, users can explore the system's potential for automating other electrical devices and appliances within their homes.As long as these devices fall within the relay's amperage capacity, this system can be extended to offer even greater convenience and energy savings.• Regular maintenance of the system is advisable, just as with any electrical setup.Periodic checks and maintenance routines are necessary to ensure that all components are functioning correctly and safely.This practice can prolong the system's lifespan and maintain its reliability.• To further promote the adoption of such energy-efficient technologies, educational outreach is recommended.Raising awareness about the benefits of using automated systems for energy conservation can encourage a broader audience to embrace these technologies, ultimately leading to reduced energy consumption and a more sustainable lifestyle.
• Lastly, for users with high-current devices, the consideration of relays with higher amperage capacity is worth exploring.This enhancement can expand the system's applicability to accommodate a broader range of electrical appliances, providing users with even more control over their energy usage.