Design of a Laboratory Scale Solar Microgrid Cyber-Physical System for Education

Renewable energy sources such as solar and wind provide an effective solution for reducing dependency on conventional power generation and increasing the reliability and quality of power systems. Presented in this paper are design and implementation of a laboratory scale solar microgrid cyber-physical system (CPS) with wireless data monitoring as a teaching tool in the engineering technology curriculum. In the system, the solar panel, battery, charge controller, and loads form the physical layer, while the sensors, communication networks, supervisory control and data acquisition systems (SCADA) and control systems form the cyber layer. The physical layer was seamlessly integrated with the cyber layer consisting of control and communication. The objective was to create a robust CPS platform and to use the system to promote interest in and knowledge of renewable energy among university students. Experimental results showed that the maximum power point tracking (MPPT) charge controller provided the loads with power from the solar panel and used additional power to charge the rechargeable battery. Through the system, students learned and mastered key concepts and knowledge of multi-disciplinary areas including data sampling and acquisition, analog to digital conversion, solar power, battery charging, control, embedded systems and software programing. It is a valuable teaching resource for students to study renewable energy in CPS.


Introduction
A microgrid is a group of interconnected loads and distributed energy sources as a single controllable entity with respect to the grid, used for power generation and energy storage. Its applications range from supplying a few hundred kilowatts to several hundred megawatts. A microgrid enables service providers and consumers to eliminate dependency on centralized energy generation [1,2]. Microgrids are growing very fast because of their cost effectiveness, reliability, ease of implementation, and integration of multiple sources of power generation methods. Solar photovoltaic systems offer advantages such as infinite energy sources, low maintenance costs, and most of all zero carbon emission characteristics [3,4]. Solar microgrids have been utilized extensively to augment grid power [5][6][7]. Simulation of a hybrid solar/wind microgrid has been performed [8].
The rapid growth of renewable energy sources, energy storage, and power semiconductor devices is dramatically changing the nature of the transmission, distribution, and utilization of electrical energy. Most of the renewable energy sources provide DC power. Modern loads, such as lighting, electric vehicles, data centers, or variable frequency drives, require DC power. Energy storage systems (ESS) such as batteries and capacitors are in DC as well. Compared with an AC microgrid, a DC microgrid has fewer power conversion stages; therefore, the structure, control, and power management of a DC microgrid are simpler, resulting in higher overall efficiency and system stability [9]. Extensive Li-ion battery rated at 12 V and 42 Ah provides energy storage for the system. Li-ion batteries were chosen because they operate over a wider temperature range with higher energy densities compared with NiCd batteries. Figure 1 shows the system connection. The solar panel is connected to the input of the charge controller, and the output of the charge controller is connected to the battery and loads. If the solar panel is able to provide enough power to the loads, the charge controller will charge the battery if the battery is not fully charged. On the other hand, if the solar panel is not able to provide enough power to the loads, the charge controller will discharge the battery, and provide power to the loads from both the solar panel and the battery.

Solar Microgrid Cyber-Physical System Design
The solar microgrid cyber-physical system is composed of a solar panel, a microcontroller, a maximum power point tracking (MPPT) charge controller, a Li-ion battery, and loads. The solar panel has an output voltage of 18 V and output power of 40 W. The Li-ion battery rated at 12 V and 42 Ah provides energy storage for the system. Liion batteries were chosen because they operate over a wider temperature range with higher energy densities compared with NiCd batteries. Figure 1 shows the system connection. The solar panel is connected to the input of the charge controller, and the output of the charge controller is connected to the battery and loads. If the solar panel is able to provide enough power to the loads, the charge controller will charge the battery if the battery is not fully charged. On the other hand, if the solar panel is not able to provide enough power to the loads, the charge controller will discharge the battery, and provide power to the loads from both the solar panel and the battery. A ProStar MPPT charge controller manages the power flow among the solar panel, the battery and the load. It uses a smart tracking algorithm that finds and maintains operation at the solar panel's peak power point to maximize energy harvest. The charge controller provides seven standard battery charging settings that are selected with the settings switches. These standard charging settings are suitable for Li-ion batteries and lead-acid batteries ranging from sealed (gel, AGM, maintenance-free) to Flooded and L-16 cells.
The MPPT charge controller has a four-stage battery charging algorithm for fast, efficient, and safe battery charging. In the bulk charge stage, the battery is not fully charged. The controller will deliver all the available solar power to charge the battery. When the battery will have charged to the absorption voltage setpoint, the charge controller will operate in the absorption stage. In this stage, constant voltage regulation is used to maintain battery voltage at the setpoint. The battery must remain in this stage for a cumulative 150-180 min, depending on the battery type. After the battery is fully charged, the charge controller reduces the battery voltage to the float voltage setpoint. The float stage provides a very low rate of maintenance charge. Once in the float stage, loads can draw power from the battery. If the loads exceed the solar charge current, the controller can no longer maintain the battery at the float setpoint. When the battery voltage drops below the float setpoint for a cumulative 60 min period, the controller will exit the float stage and return to bulk charging. The charging algorithm is shown in Figure  2. A ProStar MPPT charge controller manages the power flow among the solar panel, the battery and the load. It uses a smart tracking algorithm that finds and maintains operation at the solar panel's peak power point to maximize energy harvest. The charge controller provides seven standard battery charging settings that are selected with the settings switches. These standard charging settings are suitable for Li-ion batteries and lead-acid batteries ranging from sealed (gel, AGM, maintenance-free) to Flooded and L-16 cells.
The MPPT charge controller has a four-stage battery charging algorithm for fast, efficient, and safe battery charging. In the bulk charge stage, the battery is not fully charged. The controller will deliver all the available solar power to charge the battery. When the battery will have charged to the absorption voltage setpoint, the charge controller will operate in the absorption stage. In this stage, constant voltage regulation is used to maintain battery voltage at the setpoint. The battery must remain in this stage for a cumulative 150-180 min, depending on the battery type. After the battery is fully charged, the charge controller reduces the battery voltage to the float voltage setpoint. The float stage provides a very low rate of maintenance charge. Once in the float stage, loads can draw power from the battery. If the loads exceed the solar charge current, the controller can no longer maintain the battery at the float setpoint. When the battery voltage drops below the float setpoint for a cumulative 60 min period, the controller will exit the float stage and return to bulk charging. The charging algorithm is shown in Figure 2.
The MPPT charge controller is connected to the load to power various components. The load consists of a 12 V to 5 V DC-DC convertor, a Raspberry Pi microcontroller, a fourrelay module, a series of nine LEDs (a 3 × 3 grid with each row controlled individually), a light dependent resistive (LDR) circuit, and a wireless transmitter/receiver to charge an electric toy car to represent electric vehicles for proof of the concept. The system also includes other smaller components, such as physical switches and terminals to support the desired functionality. Schematics and a picture of the solar microgrid are shown in Figures 3 and 4, respectively. A list of hardware and costs are detailed in Table 1.  The MPPT charge controller is connected to the load to power various The load consists of a 12 V to 5 V DC-DC convertor, a Raspberry Pi microcont relay module, a series of nine LEDs (a 3 × 3 grid with each row controlled ind light dependent resistive (LDR) circuit, and a wireless transmitter/receiver electric toy car to represent electric vehicles for proof of the concept. The includes other smaller components, such as physical switches and termina the desired functionality. Schematics and a picture of the solar microgrid a Figures 3 and 4, respectively. A list of hardware and costs are detailed in Tab   The MPPT charge controller is connected to the load to power various com The load consists of a 12 V to 5 V DC-DC convertor, a Raspberry Pi microcontrolle relay module, a series of nine LEDs (a 3 × 3 grid with each row controlled individ light dependent resistive (LDR) circuit, and a wireless transmitter/receiver to ch electric toy car to represent electric vehicles for proof of the concept. The sys includes other smaller components, such as physical switches and terminals to the desired functionality. Schematics and a picture of the solar microgrid are s Figures 3 and 4, respectively. A list of hardware and costs are detailed in Table 1

Data Acquisition and Data Process
Data communication among the MPPT charge controller (Morningsta Pi 3 Model B, cloud server with MongoDB database, and graphical user inter in Figure 5. The MPPT charge controller is the central data sampling device the electrical data about the system components including the solar panel the loads. The sampled data were retrieved by the Raspberry Pi microc Modbus communications via a USB Meterbus adapter. Then the data wer formatted to proper values on the Raspberry Pi and sent via WiFi to the clou The Raspberry Pi was also connected to a touchscreen LCD monitor th

Data Acquisition and Data Process
Data communication among the MPPT charge controller (Morningstar), Raspberry Pi 3 Model B, cloud server with MongoDB database, and graphical user interface is shown in Figure 5. The MPPT charge controller is the central data sampling device that generates the electrical data about the system components including the solar panel, battery, and the loads. The sampled data were retrieved by the Raspberry Pi microcontroller and Modbus communications via a USB Meterbus adapter. Then the data were filtered and formatted to proper values on the Raspberry Pi and sent via WiFi to the cloud MongoDB. The Raspberry Pi was also connected to a touchscreen LCD monitor that provides a graphical user interface (GUI) to energize or de-energize the loads. Control to the loads on a mobile device from remote locations was realized through a Virtual Network Computing (VNC) Viewer connected to the Raspberry Pi.
Modbus is a communication method in which a device loads registers with data. These data can then be retrieved by another device as the client/server. For the microgrid system, the MPPT charge controller hosts the Modbus addresses where the data were retrieved. The data being monitored are the solar panel voltage and current, battery voltage and current, load voltage and current, maximum array voltage (daily), charger output power, charge state, load state, minimum and maximum battery voltage (daily), time in absorption, equalization and float (daily), heatsink temperature, battery temperature, and ambient temperature. The data provide detailed information on the operation of the solar microgrid.
Electronics 2021, 10, x FOR PEER REVIEW 6 of 12 time in absorption, equalization and float (daily), heatsink temperature, battery temperature, and ambient temperature. The data provide detailed information on the operation of the solar microgrid.

Programming Logic and Graphical User Interface (GUI) Design
Two interconnected programs were designed and developed: main logic and GUI. The main logic program processes all data logics. The GUI program receives user inputs and send instructions to the main logic. Users can energize or de-energize the loads including the wireless car charger and the LEDs through the GUI, as well as on a mobile device remotely through VNC Viewer for the Raspberry Pi. VNC Viewer is a graphical desktop sharing system that allows the system to work as a remote laboratory, where hardware can be controlled remotely. All programming was done on the Raspberry Pi with Python programming language before the data were sent to the cloud database.
The flowchart of the main logic program is shown in Figure 6. After initialization of the system environment, such as network IP addresses, port numbers, and other global variables, a data process loop with refreshing interval of 10 minutes is set by default. The refreshing interval is configurable. The first step in the loop is to collect MPPT data and keep the data in an array. Then the data are filtered, formatted, and converted from float 16 to decimal numbers. Finally, the data are packaged to JavaScript Object Notation (JSON) and sent wirelessly to the cloud MongoDB data server so that the data can be used for research, analysis, and visualization.
The flowchart of the GUI program is shown in Figure 7. After initialization of the GUI program, once the main user interface is loaded and displayed, the GUI program refreshes and changes every second based on user inputs and environment adjustment.

Programming Logic and Graphical User Interface (GUI) Design
Two interconnected programs were designed and developed: main logic and GUI. The main logic program processes all data logics. The GUI program receives user inputs and send instructions to the main logic. Users can energize or de-energize the loads including the wireless car charger and the LEDs through the GUI, as well as on a mobile device remotely through VNC Viewer for the Raspberry Pi. VNC Viewer is a graphical desktop sharing system that allows the system to work as a remote laboratory, where hardware can be controlled remotely. All programming was done on the Raspberry Pi with Python programming language before the data were sent to the cloud database.
The flowchart of the main logic program is shown in Figure 6. After initialization of the system environment, such as network IP addresses, port numbers, and other global variables, a data process loop with refreshing interval of 10 min is set by default. The refreshing interval is configurable. The first step in the loop is to collect MPPT data and keep the data in an array. Then the data are filtered, formatted, and converted from float 16 to decimal numbers. Finally, the data are packaged to JavaScript Object Notation (JSON) and sent wirelessly to the cloud MongoDB data server so that the data can be used for research, analysis, and visualization. time in absorption, equalization and float (daily), heatsink temperature, battery temperature, and ambient temperature. The data provide detailed information on the operation of the solar microgrid.

Programming Logic and Graphical User Interface (GUI) Design
Two interconnected programs were designed and developed: main logic and GUI. The main logic program processes all data logics. The GUI program receives user inputs and send instructions to the main logic. Users can energize or de-energize the loads including the wireless car charger and the LEDs through the GUI, as well as on a mobile device remotely through VNC Viewer for the Raspberry Pi. VNC Viewer is a graphical desktop sharing system that allows the system to work as a remote laboratory, where hardware can be controlled remotely. All programming was done on the Raspberry Pi with Python programming language before the data were sent to the cloud database.
The flowchart of the main logic program is shown in Figure 6. After initialization of the system environment, such as network IP addresses, port numbers, and other global variables, a data process loop with refreshing interval of 10 minutes is set by default. The refreshing interval is configurable. The first step in the loop is to collect MPPT data and keep the data in an array. Then the data are filtered, formatted, and converted from float 16 to decimal numbers. Finally, the data are packaged to JavaScript Object Notation (JSON) and sent wirelessly to the cloud MongoDB data server so that the data can be used for research, analysis, and visualization.
The flowchart of the GUI program is shown in Figure 7. After initialization of the GUI program, once the main user interface is loaded and displayed, the GUI program refreshes and changes every second based on user inputs and environment adjustment.  The flowchart of the GUI program is shown in Figure 7. After initialization of the GUI program, once the main user interface is loaded and displayed, the GUI program refreshes and changes every second based on user inputs and environment adjustment.

Pedagogical Approach
The solar microgrid CPS has been used as a teaching increase their interest and knowledge of renewable en undergraduate education and outreach program in many college and pre-college students to observe and experiment has inspired their interest in and curiosity about alternativ microgrid CPS involves many topics in electrical en engineering.
Problem-based learning (PBL) approach is an active, stu centered method [3,30,31]. It cultivates students' independe drawback when knowledge is transferred mostly by lectu motivated to acquire knowledge independently. By usin interest and curiosity are stimulated, generating excitement The system creates a central planform to integrate le experiments. Students can make changes to the system pa logic and observe the effect immediately. They become inde there are different ideas and solutions for real world enginee

Pedagogical Approach
The solar microgrid CPS has been used as a teaching tool for college students to increase their interest and knowledge of renewable energy. The system benefits undergraduate education and outreach program in many ways. First, it is exciting for college and pre-college students to observe and experiment with the system. The system has inspired their interest in and curiosity about alternative energy. Second, the solar microgrid CPS involves many topics in electrical engineering and mechanical engineering.
Problem-based learning (PBL) approach is an active, student-centered, and problemcentered method [3,30,31]. It cultivates students' independent and critical thinking. One drawback when knowledge is transferred mostly by lecturing is that students are not motivated to acquire knowledge independently. By using PBL approach, students' interest and curiosity are stimulated, generating excitement and increasing interaction.
The system creates a central planform to integrate lectures, demonstrations, and experiments. Students can make changes to the system parameters and programming logic and observe the effect immediately. They become independent inquirers and learn there are different ideas and solutions for real world engineering problems. The following experiments were developed around the solar microgrid CPS: (1) data acquisition for renewable energy, (2) Python programming for Raspberry Pi, (3) data sampling, digitization, and process, (4) battery charging, (5) maximum power point tracking, (6) digital data communication, (7) user interface design and control logic, (8) database operations, (9) data analysis and report. Each experiment is stand-alone, while they are all related to the system. Table 2 shows the learning objectives of each experiment. Students could understand the design and implementation of the entire solar microgrid system after completing the experiments.

Exp 9. Data analysis and report
Using Microsoft Excel and Matlab to process and analyze the collected data The system was designed to be open and easy to modify. The undergraduate students were able to extend their theoretical knowledge and apply it in practical applications. The system also served as a testbed for senior design projects. Students could design and modify the existing system to expand its functions. Students' ideas could be easily verified through the platform.

Experimental Results
The solar microgrid CPS was tested outdoors on a sunny day. The rechargeable battery was almost depleted of charge at the beginning of the test. The loads of LED lights and wireless car charger were energized. Data were collected automatically every 10 min. Table 3 shows the voltage and current for the solar panel, the battery, and the loads, charger output power, and battery temperature. The MPPT charge controller provided the loads with the power from the solar panel and used additional power to charge the rechargeable battery.
The voltage for the photovoltaic (PV) and loads remained relatively constant over time. PV current was highest initially to charge the battery. As the state of charge of the battery increased, the MPPT charge controller reduced the output current from the PV to avoid overcharging the battery. From 10:50 am to noon, there was a large current flowing into the battery. After that, the battery current was rapidly reduced and went to almost zero at 13:00. At 13:20, 13:30, and 13:50, the battery current became negative, which means the battery was being discharged to provide power to the loads. Overall, since the solar irradiation was very good on the day of testing, the solar panel was able to provide sufficient power to the loads and charge the rechargeable battery. When the battery was fully charged after noon, solar power was curtailed by the MPPT charge controller.
The PV provided a primary power source, and the battery supplied complementary source. The battery improved the microgrid's stability and reduced effects of the intermittent nature of solar power. The changes of the PV output power vs. the sum of battery and load power are shown in Figure 8. The battery voltage is shown in Figure 9. It can be observed that after the battery was fully charged after 13:00, the charge controller reduced the battery voltage to the float voltage setpoint, where a very low rate of maintenance charge was provided. The voltage for the photovoltaic (PV) and loads remained relatively time. PV current was highest initially to charge the battery. As the state o battery increased, the MPPT charge controller reduced the output current avoid overcharging the battery. From 10:50 am to noon, there was a large c into the battery. After that, the battery current was rapidly reduced and zero at 13:00. At 13:20, 13:30, and 13:50, the battery current became negativ the battery was being discharged to provide power to the loads. Overall, irradiation was very good on the day of testing, the solar panel was a sufficient power to the loads and charge the rechargeable battery. When t fully charged after noon, solar power was curtailed by the MPPT charge c The PV provided a primary power source, and the battery supplied c source. The battery improved the microgrid's stability and reduced intermittent nature of solar power. The changes of the PV output power battery and load power are shown in Figure 8. The battery voltage is sho It can be observed that after the battery was fully charged after 13:00, the ch reduced the battery voltage to the float voltage setpoint, where a ve maintenance charge was provided.    In addition to the data in Table 3, the MPPT charge controller was also the following values: heatsink temperature, ambient temperature, charge s PV voltage at maximum power, PV maximum output power, PV open maximum battery voltage (daily), minimum battery voltage (daily), time (daily), time in equalization (daily), and time in float (daily). The data e Battery Voltage (V) Figure 9. Battery Voltage Decreasing After Fully Charged.
In addition to the data in Table 3, the MPPT charge controller was also able to retrieve the following values: heatsink temperature, ambient temperature, charge state, load state, PV voltage at maximum power, PV maximum output power, PV open circuit voltage, maximum battery voltage (daily), minimum battery voltage (daily), time in absorption (daily), time in equalization (daily), and time in float (daily). The data enabled remote system monitoring and provided faculty and students information on how the system operated.

Educational Assessment
The system was used as an enabling teaching tool for the engineering technology curriculum in junior/senior level courses. The demonstrations and experiments were used in TECH 375 Control Systems, TECH 476 Industrial Control Electronics and TECH 426 Electric System Applications for Alternative Energy. Students completed an anonymous questionnaire after participating in the demonstration and experiments. The questionnaire addressed two research questions: (1) Did the demonstration and experiments enhance college students' awareness and knowledge of renewable energy? (2) Did college students perceive changes in their interest in renewable energy because of the demonstration and experiments?
The results in Table 4 were processed using 1 for Not at all, 2 for A little, 3 for Somewhat, and 4 for Very much to calculate the means and standard deviations. They show the solar microgrid CPS demonstration and experiments greatly enhanced students' perception of learning as compared with traditional instruction, and a majority of students perceived changes in their interest, awareness, and knowledge of renewable energy.
Students also completed a pre-and post-knowledge test containing 10 questions. The test was given in the first and last week of the semester. The group size for analysis was based on the number of students who completed both the pretest and posttest. Mixed analysis of variance (ANOVA) was used to analyze the tests. ANOVA is a collection of statistical models and their associated estimation procedures used to analyze the differences among means. The pretest had a score of (3.24 ± 1.147), and the posttest had a score of (7.65 ± 1.843). The mixed ANOVA comparing pretest to posttest scores revealed a significant increase in knowledge test scores from the beginning to end of the courses [F(1, 35) = 73.220, p < 0.001].

Discussion and Conclusions
This paper presented a teaching tool developed from a smart solar microgrid CPS. The system integrated the physical layer with the cyber layer that includes sensors, communication, and control. Demonstrations and hands-on experiments were developed around the platform. The experiments are stand-alone and can be conducted within a laboratory time frame. The hands-on experiments allowed students to connect classroom content with real world applications.
The system was used to teach engineering technology students solar power, control, data acquisition and process. We created a central planform to integrate lectures, demonstrations, and experiments for problem-based learning. Two research questions were asked during the assessment: (1) Did the demonstration and experiments enhance college students' awareness and knowledge of renewable energy? (2) Did college students perceive changes in their interest in renewable energy because of the demonstration and experiments? The assessment results supported the expectation that the use of the solar microgrid along with innovative teaching materials in the laboratory would enhance students' perceptions of learning as compared with traditional instruction and would increase their interest level and knowledge of renewable energy and STEM fields. In addition, the solar microgrid CPS described in this study can be easily scaled to higher power levels. The proposed system can be used to provide DC power to rural and developing areas where power is unavailable or unreliable. Future work can connect two or more solar microgrids and use an upper-level controller for hierarchical control. The primary control integrates control loops to regulate voltage, current, and power and defines the dynamic performance. The upper-level controller can provide advanced functions, such as power quality control, current sharing, and optimized operation. Future efforts can improve the intelligence of the system to achieve coordination among microgrids. Funding: Partial support for this work was provided by the United States National Science Foundation's Improving Undergraduate Science, Technology, Engineering and Mathematics Education (IUSE) program under Award No. 1712146. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of the National Science Foundation.

Data Availability Statement:
The data presented in the study are available in this article.

Conflicts of Interest:
The authors declare no conflict of interest.