PV-driven Smart Islanded Microgrid: Intelligent I2C Arduino-based Demand Energy Management Dmytro Zubov1,∗,†, Ayman Aljarbouh1,†, Andrey Kupin2,† and Gainikamal Batayeva1 1 University of Central Asia, 125/1 Toktogul Street, Bishkek, 720001, Kyrgyzstan 2 Kryvyi Rih National University, 11 Vitaly Matusevich, Kryvyi Rih, 50027, Ukraine Abstract This study aims to develop a PV-driven smart islanded microgrid capable of managing both critical (such as heating inside the electric panel in cold climates) and shiftable (such as LED light bulbs) loads. The main advantage of the proposed prototype is its affordability as it utilizes two Arduino Uno microcontrollers that are available worldwide, along with a photoresistor for measuring light intensity and two relays for connecting/disconnecting the shiftable load and minimizing the time without the power supply of the critical demand. The control algorithm is based on three-input hysteresis with the counter of loops in Arduino sketch with high intensity of light (over 1002 – direct sun rays; the counter is incremented if the load has a power supply on the solar charge controller) and the correcting variable that doubles once per 24h if the load is OFF on the solar charge controller: the shiftable load is ON while the counter is positive during the night time; the value of correcting variable is subtracted from the counter. Arduino Uno microcontrollers transmit data via I2C protocol. Experimental results conducted at the Naryn campus of the University of Central Asia in Kyrgyzstan have shown that the proposed microgrid prototype minimizes the time when the critical load is OFF and allows limited power supply to the shiftable load. Keywords Microgrid, critical demand, shiftable load, adaptive control, Arduino Uno, I2C protocol 1 1. Introduction The islanded microgrid (µG) driven by photovoltaic (PV) energy [1, 2] is one of the fundamental components of the local smart power grid. Existing market solutions with different µG loads, such as critical, curtailable, and shiftable, operate using various control algorithms and soft- /hardware [3, 4]. With respect to the criterion of cost minimization throughout all stages of the system design, from planning to maintenance and support, the best solution today is the IoT (Internet of Things) Arduino-based open-source electronic prototyping platform [4, 5]. In this study, a μG prototype is developed using the 100 W 12 V monocrystalline solar panel, PWM (pulse width modulation) solar charge controller W88-C 30A / 12V / 24V, four 12V / 9.0Ah lead- ICyberPhyS-2024: 1st International Workshop on Intelligent & CyberPhysical Systems, June 28, 2024, Khmelnytskyi, Ukraine ∗ Corresponding author. † These authors contributed equally. dzubov@ieee.org (D. Zubov); ayman.aljarbouh@ucentralasia.org (A. Aljarbouh); kupin@knu.edu.ua (A. Kupin); bataevagajnikamal@gmail.com (G. Batayeva) 0000-0002-5601-7827 (D. Zubov); 0000-0002-3909-2227 (A. Aljarbouh); 0000-0001-7569-1721 (A. Kupin); 0009- 0006-7439-7145 (G. Batayeva) © 2023 Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0). CEUR ceur-ws.org Workshop ISSN 1613-0073 Proceedings acid batteries connected in parallel, two Arduino Uno microcontrollers with a photoresistor, two relays, DC-DC step down converter, portable 5 V heater, 128 MB microSD card, and a microSD card Arduino module. The total cost is approximately USD 100 on the Kyrgyz market, excluding restored batteries installed as energy storage. Numerous commercial products and prototypes, such as the West Virginia Super-Circuit project with multiagent system architecture [1] and the energy management system for office buildings using a neuro-fuzzy forecasting model [2], use various virtual power plant (VPP) [4] techniques in µGs. These techniques can be classified based on their cost function, constraints, soft-/hardware, centralized / decentralized architecture, and deterministic / probabilistic control methods [3]. Some papers use simulation tools like Matlab / Simulink [6], while others emphasize specific soft-/hardware for the implementation of appropriate algorithms, e.g., [4, 7]. Most µGs are usually built upon existing infrastructure and equipment to meet customer needs. However, literature review, such as presented in [8, 9], and analysis of existing case studies show that reasonably priced systems with worldwide available equipment, such as the Arduino- based open-source electronic prototyping platform, and various load types [10, 11] are not sufficiently discussed. This study presents the ad hoc project, the solar electric system with two power lines at the Naryn campus of the University of Central Asia in Kyrgyzstan. The Naryn region is well-known for its low ambient temperatures (sometimes -400C) during the cold season, and hence the outdoor installation of the µG control equipment requires the internal heating of the electric panel. Therefore, two power lines must be installed: one for the heater, which is critical, and the other for the shiftable load, which in this prototype is a 12 V / 10 W light-emitting diode (LED) light bulb. The shiftable load is turned on if there is enough power generated by the solar panel and the photoresistor value is below the predetermined threshold value; it is turned off otherwise, i.e., the demand side energy management [12] should be implemented. The hysteresis switching adaptive control algorithm uses three inputs to manage the shiftable load with the Arduino relay [13, 14]: the current light intensity from the photoresistor, the counter of loops in the Arduino sketch with high intensity of light (direct sun rays) measured by the photoresistor, and the solar controller discharge stop voltage. Two Arduino Uno microcontrollers communicate via the Inter-Integrated Circuit (I2C) protocol [15, 16]. The architecture of the proposed PV-driven smart islanded µG is shown in Figure 1: Arduino Uno microcontrollers use 5 V relays to connect / disconnect power lines; the emergency power supply, which is not discussed in this study, is an independent source of electrical power that supports the critical load (the heater in this study) on the loss of normal power supply from the solar charge controller; other equipment is discussed throughout the paper. The main contribution of this study is the development of an affordable solar electric system with two power lines, for the critical demand (the portable heater in this study) and the shiftable load (the LED light bulb in this study), adapted to the environment with low ambient temperatures like the Naryn region. Analysis of existing commercial products shows that the presented low-priced prototype of µG with the adaptive control algorithm and the hardware based on the 100 W solar panel, 30 A solar charge controller, and two Arduino Uno boards connected via the I2C protocol to manage critical and shiftable loads does not have analogs under USD 100 on the market. Two Arduino Uno Photoresistor Microcontrollers Solar Charge Solar Panel Shiftable Load Controller Emergency Power Battery Critical Load Supply Figure 1: The architecture of a proposed PV-driven smart islanded µG. 2. Related Works The number of Web of Science papers related to µGs has significantly increased from 2010 to 2021 [10]. Many papers, such as [6, 12], discuss the design and analysis of µGs employing simulation tools like Matlab / Simulink. However, this study focuses on the physical implementation of μG, with the goal of improving the power supply system for critical loads and minimizing power loss while providing electric energy to the shiftable demand. This approach emphasizes the use of IoT soft-/hardware and control algorithms. The open-source Arduino-based soft-/hardware, such as Arduino Uno [9, 11] / Mega [5, 11] / Nano and NodeMCU ESP8266 [5, 13] / ESP32 [13, 15], can be programmed in the Arduino integrated development environment (IDE) and are widely used for the µG automation due to their reliability, affordability, and availability around the world. Additionally, Raspberry Pi small single-board computers [9] are employed for high- performance operations and networking in various IoT projects, including power management. In [2, 3, 15], control techniques are classified as follows: 1. Topology: centralized, decentralized, distributed. 2. Notable advancements in control and supervision: intelligent energy management system, advanced management of energy storage system, grid-forming inverter control, demand response integration, and cyber-physical security. 3. Functionality: multi-agent system deployment, model predictive control. 4. Optimization methods: deterministic, probabilistic. Analysis of previous studies shows that µG is built according to the existing infrastructure, customer needs, and various load types, and hence it should be capable of operating under varying power grid conditions. Therefore, there is no fixed cost and / or structure for µGs, but the minimization of expenses is the priority for customers. 3. Methods 3.1. µG prototype architecture Relays (HW-482 in this study) [10, 13] are commonly used to connect / disconnect DC and AC power lines, regardless of the type of control technique. The relay 2 (see Figure 2) position, whether ON or OFF, depends on the control algorithm, which is based on a three-input hysteresis system in the µG prototype: 1. If the photoresistor value, i.e., the light intensity, is less than 300, then the normally closed pin is ON. If the photoresistor value is greater than 350, then the normally closed pin is OFF. 2. If the counter of the photoresistor values over 1002 (direct sun rays) is positive, then the normally closed pin is ON; otherwise, it is OFF. 3. If the lead-acid battery voltage is less than 10.7 V (the discharge stop voltage measured by the solar charge controller), then the normally closed pin is OFF; otherwise, it is ON. The third condition is implemented without the DC voltage sensor since it consumes additional power using the voltage divider technology. When the battery voltage drops to 10.7 V, the loads are disconnected, and as a result, the Arduino Uno microcontroller (I2C peripheral receiver) connected to the solar charge controller does not have the power supply required to operate. Because of that, another Arduino Uno microcontroller (I2C controller writer) is unable to send data. This setup allows the I2C controller writer to detect whether the loads have a power supply or not. Additionally, the Arduino I2C peripheral receiver is used as a terminal to access the data on the Arduino I2C controller writer: if the power supply is OFF or the serial monitor starts in Arduino IDE, then the sketch is reloaded on Arduino Uno microcontroller. After analyzing the related works and considering the prototype requirements, the proposed bare µG wiring is presented in Figure 2. Figure 2 shows that the solar charge controller receives the power from the 100 W monocrystalline solar panel and then distributes it between the battery and the load. The discharge stop voltage is 10.7 V, the discharge reconnect voltage is around 11.5 V (experiments showed that it varies between 11.2 V and 11.5 V for the controller W88-C), and the equalization voltage is 14.4 V as four lead-acid batteries are employed in the prototype. The Arduino I2C controller writer is powered by a 12 V power supply from the batteries, which means it is always ON. It is connected to the Arduino I2C peripheral receiver through pins SCL (a serial clock pin), SDA (a serial data pin), and GND (ground). The Arduino I2C peripheral receiver is powered by a 5 V power supply from the solar charge controller USB port and is only ON when the load has a power supply on the solar charge controller. The relays are powered by the Arduino I2C peripheral receiver, and hence they are disconnected if the load is OFF on the solar charge controller. Relay 1 input is the digital pin 8 on the Arduino I2C peripheral receiver. Relay 2 input is the digital pin 7 on the Arduino I2C controller writer. The shiftable load is the 12 V / 10 W LED light bulb. The critical load is the portable 5 V heater. The photoresistor connected to the analog pin A0 on the Arduino I2C controller writer measures the light intensity: the value over 1002 represents the direct sun rays. MicroSD card module is employed to save the data used in calculations; its pins CS (Chip Select), MOSI (Master Out Slave In), MISO (Master In Slave Out), and SCK (Serial Clock) are respectively connected to digital pins D4, D11, D12, and D13 on the Arduino I2C controller writer. Solar Panel Solar Charge Controller Batteries USB Load 5V 12 V Load 12 V 12 V D8, 5 V, Relay 1 GND Arduino Arduino I2C I2C Controller SCL, SDA, GND Peripheral Writer Receiver D7 5 V, D4, D11, D12, GND A0, 5 V, GND D13, 5 V, GND Wire Splice Connector Relay 2 DC-DC Step Down Photoresistor Power Converter MicroSD card 5V module Shiftable Load (LED Light Bulb) Critical Load (Portable 5 V Heater) Figure 2: Bare wiring of proposed µG. The research question is what heater power is needed to keep the temperature above 0 0C inside the electric panel. The assumption is that 0 0C is the normal temperature for the prototype hardware and that the electric panel is winterized (i.e., heat insulation is added internally and/or externally) and has dimensions 0.5 m×0.5 m×0.3 m=0.075 m3. In general, 1000 W is suitable for heating a space of 25 m3, and hence 4 W, the power provided by the portable 5 V / 3.5 W heater and the hardware inside the panel, should be enough for 0.1 m3 which is larger than the discussed volume of the electric panel (0.075 m3). Table 1 presents the approximate power consumption of 4.3 W for two Arduino Uno microcontrollers (measured by the USB charger tester) and other equipment inside the electric panel in the presented prototype. Table 1 Power Consumption of the Equipment Inside the Electric Panel Equipment Approximate power consumption, W Arduino I2C controller writer 0.005 Arduino I2C peripheral receiver 0.501 DC-DC step down power converter (95 % 0.175 efficiency) Portable heater 3.500 Solar charge controller 0.120 3.2. Control of the µG shiftable load with hysteresis In the presence of critical and shiftable loads, the specified amount of total energy is expanded [17], which is characterized by the following relations on each day: 𝑑𝑑𝑑𝑑,𝑠𝑠ℎ𝑖𝑖𝑖𝑖𝑖𝑖 � �𝐸𝐸𝑡𝑡𝑑𝑑𝑑𝑑,𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 + (1 − 𝑋𝑋𝑡𝑡𝐷𝐷𝐷𝐷 )𝐸𝐸𝑡𝑡 𝑠𝑠𝑠𝑠 � ≤ � 𝐸𝐸𝑡𝑡 ≤ 𝐸𝐸𝑚𝑚𝑚𝑚𝑚𝑚 , (1) 𝑡𝑡≤24ℎ 𝑡𝑡≤24ℎ where E is the electric power energy, sp and dm stand for the supply and demand, t denotes the time step around 1.8 s at the Arduino sketch loop function resolution, critic and shift represent the critical and shiftable loads, 𝑋𝑋𝑡𝑡𝐷𝐷𝐷𝐷 = {0,1} is the decision of engagement, DR stands for the demand response, and 𝐸𝐸𝑚𝑚𝑚𝑚𝑚𝑚 is the maximum power energy that can be generated for 24h. 𝑋𝑋𝑡𝑡𝐷𝐷𝐷𝐷 depends on the amount of power energy received from the solar panel: 𝑠𝑠𝑠𝑠 0, 𝐶𝐶 > 0; (2) 𝑋𝑋𝑡𝑡𝐷𝐷𝐷𝐷 = � 24 1, 𝑜𝑜𝑜𝑜ℎ𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒, 𝑠𝑠𝑠𝑠 where 𝐶𝐶24 is the counter of loops in Arduino sketch with high intensity of light (over 1002 – direct sun rays; the counter is incremented if the load has a power supply on the solar charge controller) measured by the photoresistor. The flowchart for the µG shiftable load management (i.e., relay 2 is ON or OFF) using the hysteresis with three inputs is shown in Figure 3. 𝐶𝐶 𝑑𝑑𝑑𝑑 is the correcting variable that doubles 𝑠𝑠𝑠𝑠 once per 24h if the load is OFF on the solar charge controller. 𝐶𝐶 𝑑𝑑𝑑𝑑 and 𝐶𝐶24 are two inputs for the flowchart in Figure 3, which are calculated out of the presented algorithm. 4. Experiment Figure 4 illustrates the experimental setup of the µG prototype along with measurement tools – the USB charger tester and the digital multimeter QHTITEC 830Plus. Two Arduino Uno boards in enclosures were prepared for the outdoor installation. In future, the equipment is going to be installed outdoors inside the electric panel, and it will work with two 330 W solar panels (see Figure 5; the photo was taken at the Naryn campus of the University of Central Asia in Kyrgyzstan on December 12, 2023). These solar panels will be reinstalled to change their position on the roof of the summerhouse because they get covered with snow during snowfall. Start Relay 2 is OFF No The photoresistor value is less than 300 Yes Relay 2 ON No 𝑠𝑠𝑠𝑠 𝐶𝐶24 >0 𝑠𝑠𝑠𝑠 𝐶𝐶24 OFF Yes Relay 2 Load does not The load has a power have a power No supply on the solar ON supply on the solar Load has a power supply on charge controller the solar charge controller charge controller Yes OFF Relay 2 No The photoresistor value is less than 350 ON Photoresistor Yes 300 350 OFF Relay 2 is ON 𝑠𝑠𝑠𝑠 𝑠𝑠𝑠𝑠 𝐶𝐶24 = 𝐶𝐶24 − 𝐶𝐶 𝑑𝑑𝑑𝑑 Figure 3: Flowchart for the µG shiftable load management with three comments to three respective decision elements on the right. 5. Results Figure 6 presents the experimental results of the µG prototype: Solar panel Photoresistor Two Arduino Uno boards in enclosures Portable 5 V heater (critical demand) LED light bulb (shiftable load) Relay 2 DC-AC 220V inverter (not used in this project) MicroSD card module Arduino I2C USB charger tester controller writer Arduino I2C peripheral receiver Four lead-acid batteries Solar charge controller Relay 1 Wire splice connector DC-DC step down power converter Digital multimeter Figure 4: The µG prototype testbed. 1. The horizontal axis represents the dates of the experiment: days 1-14 correspond with March 6-8 and 11-21, 2024, respectively. 2. The right vertical axis represents the maximum number per day (blue line) of photoresistor values that are larger than 1002 (i.e., the direct sun rays). 3. The left vertical axis represents the battery voltage (green line), the ON (1) / OFF (0) status of the load on the solar charge controller (red line), and the value of the correcting variable 𝐶𝐶 𝑑𝑑𝑑𝑑 (black line). The measurements were taken hourly. 4. The experimental results show that the proposed control method with hysteresis and correcting variable 𝐶𝐶 𝑑𝑑𝑑𝑑 effectively minimizes the time when the critical load (red line) is OFF and allows for the power supply of the shiftable load. The energy produced by this prototype is sufficient to power floodlights with a passive infrared (PIR) sensor. Electric panel Solar panels Figure 5: Electric panel with two solar panels: the summerhouse is the planned place for the outdoor installation of the µG prototype. 7000 16,0 Counter of photoresistor values 6000 14,0 12,0 5000 larger than 1002 10,0 4000 8,0 3000 6,0 2000 4,0 2,0 1000 0,0 0 1 1 2 2 2 3 3 4 4 4 5 5 6 6 7 7 7 8 8 9 9 9 101011111212121313141414 Days Figure 6: Experimental results of the µG prototype testing. 6. Discussion In this study, a new µG prototype has been proposed for managing the critical and shiftable loads. The control algorithm is based on hysteresis with three inputs and adaptive adjustment of the correcting variable. Experimental results demonstrate that the approach proposed in this study is operable. However, the selection of hardware components, software, and control algorithms used in the prototype are empirical and, therefore, open to discussion. In particular, two concerns were discussed in the Department of Computer Science at the University of Central Asia: 1. How the correcting variable 𝐶𝐶 𝑑𝑑𝑑𝑑 is changed. 𝑠𝑠𝑠𝑠 2. How the amount of the solar power energy is assessed using the counter of loops 𝐶𝐶24 in Arduino sketch with high intensity of light measured by the photoresistor. 7. Conclusions A new PV-driven smart islanded µG is proposed in this study for managing critical and shiftable loads. The control algorithm employs a three-input hysteresis, I2C communication between Arduino Uno microcontrollers, analysis of solar energy using a photoresistor, and adaptive additive adjustment of the correcting variable. This system is shown to be operable under different weather conditions, such as cloudy or sunny. The main advantage of the developed prototype is an affordable solar electric system with two power lines, one for the heater (critical load) and the other for the shiftable demand, adapted to low ambient temperatures. Analysis of existing commercial products shows that the presented low-priced prototype of µG, equipped with a 100 W solar panel, 30 A solar charge controller, and two Arduino Uno microcontrollers, has no analogs under USD 100. Experimental results from the Naryn campus of the University of Central Asia in Kyrgyzstan have shown that the proposed µG prototype minimizes the time when the critical load is OFF and allows limited power supply to the shiftable load. In this soft-/hardware configuration, the prototype can provide power to floodlights, equipped with a PIR sensor, which serves as the shiftable load. The most likely prospect in developing this study is to design a box solution that is ready for outdoor installation. References [1] O.N. Onsomu and B. Yeşilata, Review of Microgrid Energy Management Techniques on Virtual Power Plant System, Journal of Optimization & Decision-Making 2.2 (2023) 381- 388. [2] L. Ahmethodžić, M. Musić and S. Huseinbegović, Microgrid Energy Management: Classification, Review and Challenges, CSEE Journal of Power and Energy Systems 9.4 (2023) 1425-1438. doi: 10.17775/CSEEJPES.2021.09150. [3] S. Parhizi, H. Lotfi, A. Khodaei and S. Bahramirad, State of the Art in Research on Microgrids: A Review, IEEE Access 3 (2015) 890-925. doi: 10.1109/ACCESS.2015.2443119. [4] D. Zubov, An IoT Concept of the Small Virtual Power Plant Based on Arduino Platform and MQTT Protocol, in: Proceedings of the International Conference on Applied Internet and Information Technologies, Ohrid, Macedonia, 2016, pp. 95-103. doi: 10.20544/AIIT2016.13. [5] M.T. Adkhar and H. Afanti, Monitoring System of Parallel Loads Electricity Consumption Based on IoT, Journal of Electrical Engineering and Computer Sciences 8.1 (2023) 63-70. doi: 10.54732/jeecs.v8i1.8. [6] A. Kermani, A.M. Jamshidi, Z. Mahdavi, A. ali Dashtaki, M. Zand, M.A. Nasab, T. Samavat, P. Sanjeevikumar and B. Khan, Energy Management System for Smart Grid in the Presence of Energy Storage and Photovoltaic Systems, International Journal of Photoenergy 5749756 (2023). doi: 10.1155/2023/5749756. [7] T. Hovorushchenko, S. Aleksov, S. Talapchuk, O. Shpylyuk and V. Magdin, Overview of the Methods and Tools for Situation Identification and Decision-Making Support in the Cyberphysical System «Smart House», Computer Systems and Information Technologies 4 (2022) 20-26. doi: 10.31891/csit-2022-4-3. [8] M.M. Zadeh, Z. Afshar, G. Farahani and S.M.T. Bathaee, An Adaptive Robust Optimization Model for Microgrids Operation Using Convexified AC Power Flow Equations, International Transactions on Electrical Energy Systems 6483030 (2023). doi: 0.1155/2023/6483030. [9] J. Khan, Design of Smart Energy Management System Using Arduino, International Research Journal of Modernization in Engineering Technology and Science 5.10 (2023) 1650-1654. [10] M. Uddin, H. Moa, D. Dong, S. Elsawah, J. Zhu and J.M. Guerrero, Microgrids: A Review, Outstanding Issues and Future Trends, Energy Strategy Reviews 49.101127 (2023). doi: 10.1016/j.esr.2023.101127. [11] O. Amusan, B. Olorunfemi and A. Fagboyo, Design and Construction of an Arduino-based Load-shedding Management System for Improving Electricity Consumption in a Medium- sized Creative Office Building, Journal of Digital Food, Energy & Water Systems 4.2 (2023) 141-158. [12] J. Dahiya and P. Bajpai, Design and Development of IoT Based Demand Side Management Using Arduino and MATLAB, International Research Journal of Modernization in Engineering Technology and Science 5.5 (2023) 475-479. [13] Y. Yulianto, Relay Driver Based on Arduino UNO to Bridge the Gap of The Digital Output Voltage of the Node MCU ESP32, Journal of Engineering, Mathematics and Computer Science 5.3 (2023) 129-135. doi: 10.21512/emacsjournal.v5i3.9697. [14] A.M. Jasim, B.H. Jasim, S. Mohseni and A.C. Brent, Energy Internet-based Load Shifting in Smart Microgrids: An Experimental Study, Energies 16.4957 (2023). doi: 10.3390/en16134957. [15] D. Benavides, P. Arévalo, A.C. Ortega, F. Sánchez-Sutil and E. Villa-Ávila, Energy Management Model for a Remote Microgrid Based on Demand-Side Energy Control, Energies 17.170 (2024). doi: 10.3390/en17010170. [16] G. Shravani, S. Chandrakantha, J. Akshayraj and V. Palodiya, Implementation of I2C Protocol Interfacing Temperature Sensor on FPGA using VHDL, International Journal of All Research Education and Scientific Methods 11.1 (2023) 701-709. [17] M. Jin, W. Feng, P. Liu, C. Marnay and C. Spanos, MOD-DR: Microgrid Optimal Dispatch with Demand Response, Applied Energy 187 (2017) 758-776. doi: 10.1016/j.apenergy.2016.11.093.