Electrical and Electronic Engineering

p-ISSN: 2162-9455    e-ISSN: 2162-8459

2021;  11(1): 13-21


Received: Aug. 17, 2021; Accepted: Sep. 6, 2021; Published: Sep. 15, 2021


Modeling and Energy Management Strategy in a Grid Connected Solar PV System

Elias Apiyo1, Christopher Maina1, Livingstone Ngoo2

1Department of Electrical & Electronics Engineering, Murang’a University of Technology, Murang’a, Kenya

2Department of Electrical & Telecommunications Engineering, Multimedia University of Technology, Nairobi, Kenya

Correspondence to: Elias Apiyo, Department of Electrical & Electronics Engineering, Murang’a University of Technology, Murang’a, Kenya.


Copyright © 2021 The Author(s). Published by Scientific & Academic Publishing.

This work is licensed under the Creative Commons Attribution International License (CC BY).


Electric power is substantially an important resource in the modern world. With the increase in demand for electric energy, there is a need to search for alternative energy sources because conventional resources are being exhausted. This results to significant increase in electricity cost. Use of green energy as an alternative to the conventional generation of electricity is currently on the rise. This study presented modeling and energy management of a grid-connected solar PV system aimed at reducing electric energy cost to an ordinary consumer in Kenya. Electricity cost is one of the top expenses of the ordinary consumer. The study was conducted at Murang’a University of Technology, Kenya. MATLAB Simulink software was used for modeling. Arduino Uno was chosen to perform real-time energy management that involved switching between the micro sources and the grid when the supply current from the micro sources dropped below a defined threshold value. Arduino microcontroller used instantaneous method of calculating current, voltage and power. An Application Programming Interface was proposed for forecasting energy production from the solar Photovoltaic system. Significant savings in electric energy bill was expected with the proper application of the Energy Management System in a smart house. The prototype developed managed to disconnect the loads one at a time and reconnect the particular load to the grid whenever the supply current from the micro sources dropped below the specified threshold value.

Keywords: Energy Management System, Micro Grid, Solar Photovoltaic, Weather Forecasting

Cite this paper: Elias Apiyo, Christopher Maina, Livingstone Ngoo, Modeling and Energy Management Strategy in a Grid Connected Solar PV System, Electrical and Electronic Engineering, Vol. 11 No. 1, 2021, pp. 13-21. doi: 10.5923/j.eee.20211101.03.

1. Introduction

Use of green energy as an alternative to the generation of electricity from conventional resources is currently on the rise. This is because the conventional resources are being exhausted. Government policies, technological innovation and the drive to address climate change have also made renewable energy gain global popularity [1]. Micro-grid system is a technology which provides a solution to green energy production [2]. Micro-Grid is defined in [3] as a low tension distribution network consisting of distributed generations, storage devices and loads which are flexible. The Micro-Grid system is controllable, provides reliable energy, is localized, minimizes environmental pollution and is able to reduce grid electricity needs [4]. The commonly installed distributed generations are solar Photo-Voltaic (PV) and wind turbine systems. Solar energy depends on changing weather conditions i.e. irradiance and temperature. Batteries are therefore used to store surplus energy generated from PV panels and later on releases this energy when the necessary environmental parameters drop in their value. This reduces the unreliability problem of the solar energy. Over a span of time, several studies have been conducted on Micro Grids. The study conducted by [5] modelled and simulated a 400 kW grid-connected solar PV but did not use energy storage system (ESS). Energy management between the micro source and the utility grid was not performed in this study. Authors in [6] used deep-cycle lead acid batteries to model ESS for their 3.4 MW grid connected PV-battery hybrid system for Adamawa State and addressed synchronization issues. The study did not address energy management between the grid and the micro sources. Researchers in [2] provided literature review on modeling and simulation of a micro grid system that can be operated in both islanding and in grid-connected mode. Researchers in [7] applied Arduino-based Energy Management System to control the power flow in the Micro Grid consisting of renewable energy resources like wind, solar, battery and utility grid with a view to minimise carbon dioxide emission to the atmosphere and to reduce energy consumption rate. In [8], detailed literature review on the Micro Grid EMSs is provided classifying them into various categories. Researchers in [9] applied MATLAB/Simulink software to perform Optimal Energy Management System in a grid-connected PV system. A load management system for a home in Pakistan was simulated using Proteus software in [10] to automatically reduce the load during peak hours. The recent research conducted in [11] modelled and simulated Energy Management in a smart Micro Grid the possibility of using Electric Vehicle as energy storage system consisting of a battery, Power Electronic converters and electric motor was studied. The simulation was validated using prototype hardware. Modeling of components and Energy Management Systems in Micro-Grids have been studied mostly by simulations. Real-time studies are rare.
This study aims to model a grid-connected solar PV system, apply energy management system to manage its energy sources in real-time application and estimate the next day energy production from the solar PV.
The study implements modeling of Micro-Grid components using MATLAB Simulink software because of its effectiveness and manages its energy resources in real-time using Arduino-based microcontroller. The aim of this energy management is to reduce the grid electricity need and create dependency on the renewable energy resources. Real and laboratorial hardware equipment are used in the study. One Solar PV, battery energy storage system, medium rating consumer loads connected in parallel and the utility grid are the main micro grid players in this study. The energy demanded by the loads is supplied from either the micro-source or the utility grid. An Application Programming Interface (API) is proposed for forecasting the next day energy production from the solar PV. The API provides short-term (7 days ahead) forecast weather data necessary for economic dispatch. The API is a new technology to related literature about the solar PV systems. It is based on Google search to predict solar radiation parameters. The API allows for easy download of live and forecast solar radiation data [12]. It can be integrated with other systems which require live and forecast solar radiation data. Research conducted in [13] analyzed and validated Solcast’s global performance on hourly Ghi data. The study provided a comprehensive validation highlighting the strengths and weaknesses of the data. The organization of the remaining parts of the study are as follows: Section 2 presents the methodology used, section 3 presents results and analysis of the study and section 4 provides conclusion and future work of the study.

2. Materials & Methods

2.1. Micro Grid Modelling

Various components of the Micro Grid system are modeled using MATLAB/Simulink software.
2.1.1. PV Modelling
The single diode model of figure 1 was chosen for modelling the PV system.
Figure 1. Single diode model of a solar cell
Based on the single diode model, the solar cell output current at Standard Test Condition (STC) in [11] is expressed in equation (1).
where I is the solar cell output current at STC, Iph is the photocurrent, IO is the reverse saturation current of the diode, V is the diode voltage, RS is the equivalent series resistor, A is the ideality factor of the diode generally taken between [1-3], RS the equivalent series resistor and Vt is the thermal voltage. The Simulink model of a solar PV module is shown in figure 2.
Figure 2. Simulink model of a solar PV
2.1.2. Inverter Modelling
This model uses single phase IGBT bridge as its converter to operate as unidirectional from the PV panel and the battery to the A.C load. Voltage, phase and frequency are harmonized to the grid. The Simulink model of an inverter is shown in figure 3.
Figure 3. Simulink model of an Inverter
2.1.3. Battery Modelling
A more convenient generic model of a Lead-Acid battery was used in this modeling because of its low cost and availability. A Basic model as described in [14] is given by equation (2) for charging (+) and discharging (-) states.
Where V is the current battery voltage, VOC is the open circuit voltage of the battery, I is the battery charging current from external charge (approximated zero in idle state) and 𝑅 is the battery internal resistance. The battery state of charge is found by applying equation (3).
Where SOC is the battery state of charge, Q is the actual battery charge, Q𝑑𝑖𝑠c is the actual battery discharge rate and Cbat is the battery capacity.
The Simulink model of a Lead-Acid battery is shown in figure 4.
Figure 4. Simulink model of a Lead-Acid battery
2.1.4. Load Modelling
For the simulation to execute faster, the best-form mathematical model by MathWorks was chosen. The load was modeled as resistor-inductor-capacitor series circuit. The voltage drop across this circuit is expressed as in equation (4).
where the subscripts R, L and C denote resistance, inductance and capacitance respectively. The load had a nominal voltage, frequency and power of 240 V rms, 50 Hz and 200 W respectively. Single phase three-load models with constant electric impedances are available in the Simscape Power System library.
2.1.5. Grid Modelling
The utility grid was modeled as a 240 V single phase voltage source supplied from a typical 11 kV distribution feeder. The user-defined built-in MATLAB/Simulink model was used in the modelling.
2.1.6. Complete Model of the Micro Grid System
The complete MATLAB/Simulink model of the grid connected solar PV system is shown in figure 5. The controls and scopes are modeled to enable energy management and monitoring of the Micro Grid.
Figure 5. Simulink model of the Micro-Grid system

2.2. Micro Grid Energy Management

Arduino microcontroller was selected to perform the energy management between the micro sources and the utility grid by switching between the two and meeting the thresh hold limits specified in the study. Arduino is an electronic building platform that consists of a programmable physical circuit board and accompanying software [15]. The programmable circuit is the microcontroller and the accompanying software is the Integrated Development Environment (IDE). The IDE is used to write and upload code to Arduino module. As in [16], the preassembled Arduino module costs less, has extensible hardware, Arduino software is easy to use and the software can be extended by advanced programming.
According to research conducted in [17], the solar energy produced within a time frame of one day can be estimated using equation (5).
where E is the daily energy generated in kWh, Ppv is the PV power in Watts, G is the solar irradiation per day given in W/m2 and R is the systems performance ratio taken as 80%. In this study, three consumer loads with different power ratings were connected in parallel. The energy demanded by the three loads were supplied from either the micro-source or the utility grid with the priority given to the micro-source comprising of the solar PV and the battery energy storage system. Figure 6 shows the schematic diagram of the proposed system.
Figure 6. Proposed Micro-Grid system
2.2.1. Hardware Components
The components used for the prototype development included one Yingli Energy (China) YL210P-26b solar panel, 150 AH Lead-Acid battery, 5A charge controller, 300 W power inverter, 240 V power supply bench socket outlet, three light bulbs of 100 W, 60 W and 40 W used as home consumer loads, Arduino Uno development board, 5A current sensor ACS712, voltage sensor detection module, Arduino-compatible 250Vac 10A 12Vdc 8-channel relay interface board, Arduino-compatible AC250V 10A DC12V 4-channel relay interface board, 16x2 LCD display with 12 channel interface, bread board and jumpers. Arduino Uno board architecture is shown in figure 7.
Figure 7. Arduino Uno board architecture
It has 14 digital and 6 analog pinouts. The pins are either input or output and sensors are used to interface them. The analog input pins utilize Analog to Digital Converter (ADC) to convert the analog input to digital signal. The analog input pins A0-A5 have capability to read analog voltages 0-400V rms. Digital Pins D0-D13 represent voltage in 1 bit i.e. either 0 or 1 (OFF or ON) depending on the user’s needs. The ACS712 sensor is used because it is reliable, can be installed in existing system and is relatively cheap. It is used to detect the system current The output of the sensor is processed through Arduino Uno board which uses the instantaneous method of calculation to determine the relevant quantity to which the system takes decision to disconnect the specified load, through relay, from the micro source when the system current exceeds the specified threshold value. The relay interface boards were able to control the three loads. The interface was directly connected with the microcontroller. Hardware components were connected and tested as shown in figure 8.
Figure 8. Snapshot of assembled hardware components
2.2.2. Software Code
The sequence and flow of energy, as implemented by Arduino Uno, is represented by the flowchart given in figure 9.
Figure 9. Flow chart showing the sequence and flow of energy
According to this algorithm, with sufficient electricity produced from solar panel (when the sky is clear and the sun is out), the solar PV supplies all the loads connected in the circuit. When the PV power is more than the total load demand, the excess charges the battery through charge controller. When the PV power becomes less than the total load demand due to drop in irradiance, the battery comes in and supplies load_1, load_2 and load_3. When the battery current becomes less than 0.7 A but greater than 0.42 A, the battery supplies load_2 and load_3, load_1 is supplied from the grid supply. With further decrease in battery current below 0.42 A but greater than 0.17A, the battery supplies load_3 alone. Load_1 and load_2 are supplied from the grid supply. With further decrease in current, the grid supplies all the loads connected in the circuit.

2.3. API Forecast

In [18], the API is an intermediary software allowing two applications to communicate with each other. When an API is used in a mobile device, it connects to the internet and sends data to a server. The server interprets the data performing the necessary actions and sends it back to the mobile device. The API then presents the information to the user in a readable form. Various sequential steps are followed to retrieve live and forecast solar data from the API Toolkit. The user browses internet on a networked mobile device like laptop or smart cell phone at https://solcast.com. The first-time user registers as a student or a research institution or a commercial entity in order to use the API Toolkit. Once registered, the user accesses the data commensurable with the free credit allowance provided. A registered user can access live and forecast data specific to the location of interest around the world. The user navigates to world API-Radiation which provides solar irradiance data at 30-minute resolution and selects Solar Radiation. The user selects or inserts location of interest in address search provided then proceeds to download data directly as CSV by selecting type Forecast. Finally get solar irradiation data in excel spreadsheet. Desired data variables for download include Global Horizontal Irradiance (Ghi), Direct Normal Irradiance (Dni), Diffuse Horizontal Irradiance (Dhi), air temperature and cloud opacity. Forecasts are made for the next 7 days. The API has the advantage of global coverage covering the five major continents of the world. Ground measured data in the study area was done using the standard instruments (irradiance meter and mercury thermometer for instantaneous irradiance and temperature respectively) for a period of three months.

3. Results and Analysis

3.1. Micro Grid Modelling and Simulation

The model of figure 5 was simulated using MATLAB/Simulink software with the powergui simulation type set to discrete. Environmental weather conditions i.e. solar radiation and temperature were considered while modelling the solar PV. The model was simulated at 800 W/m2 and 26°C measured irradiance and temperature respectively at East African time 2021-08-02T12:00:00Z. The simulation results of loads, battery and grid switching are shown in figure 10.
Figure 10. Simulation results of switching load_1, load_2 load_3, PV, Battery and Grid
The D.C outputs from the solar PV and the battery were converted to A.C and synchronized to the grid. Both the solar PV and the battery output voltages which were 12.8 Vd.c (varying depending on weather conditions) were fed to the input of the DC-DC converter which fed the inverter through DC link. The inverter output supplied the loads at 220 Vrms. The loads are also supplied from the grid supply. The simulation results show that the three loads of different power ratings are constantly operating (constant load operation). The loads are first supplied from the solar PV up to simulation time t = 2. The battery is turned on at simulation time t = 2 and supplied the loads up to simulation time t = 4. The grid intervened at simulation time t = 4 when the battery power was insufficient to supply the loads.

3.2. Real-time Energy Management

The Arduino programming code used for sensors reading is shown in figure 11. The Code for calculating instantaneous voltage and current is shown in figure 12.
Figure 11. Code for sensor reading
Figure 12. Code for calculating instantaneous voltage and current
The code for load switching between the micro sources and the grid resulting from the drop in magnitude of current drawn by the loads from the micro sources is shown in figure 13.
Figure 13. Code for switching load_1 and load_2 between the micro sources and the grid
The prototype is observed to be disconnecting loads one at a time whenever the supply current from the micro sources becomes less than the specified threshold value. The load with the highest current demand is disconnected first. After the disconnection, the relay reconnects the particular load to the grid supply. For economic viability of the system, the installation cost of the renewable energy sources was considered, the daily energy generation from the solar PV system was calculated as in equation (5). By subtracting the daily solar PV energy generated from the total power consumed by the loads for a period of three months (expected period is the life expectancy of the solar system installed), the total financial savings from the renewable generations can be realized. Payback period for renewable energy sources is considered in calculating the saving. The difference multiplied by the current National Electrical Energy Agency Tariff gives the financial estimate or saving for the three months considered.

3.3. Energy Generation Forecasting

The Live and Forecasts weather data collected from the API-Radiation of the study area on 2nd August 2021 at T05:30:00Z is shown graphically in figure 14 and its summary in table 1.
Table 1. Summary of API-Radiation forecast of Murang’a University of Technology
Figure 14. Live and Forecast solar radiation of Murang’a University of Technology
The results of Ghi and air temperature collected from the world API-Radiation of the study area were used as inputs in the modelled Micro Grid and simulated. The Simulink software was used as the energy generation prediction software. The output was voltage, current and power. According to [19], increase in irradiance resulted to direct increase in solar panel power generation whereas the rise in temperature decreased the panel voltage. Based on specific times of the day as in table 1, the average irradiance of the study area forecasted from 2nd to 6th August 2021 were 469 W/m2, 639 W/m2, 625 W/m2, 637 W/m2 and 651 W/m2 respectively. From the radiation pattern, the maximum power generated from the solar PV was realized on 3rd August 2021 but dropped slightly on the subsequent days that followed. On this day, the battery state of charge is such that it sustains the load for longer period as compared to the previous day. In the case of prepaid electricity bills, the forecast is advantageous to the user because the user is informed in advance whether to increase spending on tokens with the expected drop in weather pattern or spend less on favorable next coming weather pattern. The user can also plan which equipment are critical and which are not to cope up with the changing weather pattern.

4. Conclusions and Future Work

This study discussed Micro-Grid modeling, real- time Energy Management and a weather forecast for the study area. Experimental setup with Arduino board was made and an API used as web interface. Based on the simulation results, the system was able to manage the energy balance between the micro sources and the grid. The prototype built managed to switch the loads automatically between the micro sources and the grid without going beyond the set thresh hold limits of the study. The API made possible forecast of weather data which led to the prediction of next day power production from solar PV system. The measured weather data at the study area used as simulation inputs were validated by comparing with those obtained by the Solcast’s API-Radiation forecast of the same area. This work is beneficial to people in remote areas. It is economical as creates dependency on renewable energy resources and also modifies the usage habit of the consumer. The system implemented in this study is a prototype developed to control three bulbs only.
The future direction of this work is to predict consumer behavior using artificial intelligence and integrate it with the appliance automation studied for load scheduling.


The authors gratefully thanked Job Masika Wekesa of Murang’a University of Technology and Yusuf Abdiwali Mohamed of the Technical University of Kenya for their humble contribution in developing this research.


[1]  L. O. Polanco, C. A. Carreño, A. P. Martínez and M. P. García, "Optimal Energy Management within a Microgrid: A Comparative Study," Energies, pp. 1-22, 19 August 2018.
[2]  R. Chowdhury and T. Boruah, "Design of a Micro-Grid System in Matlab/Simulink," International Journal of Innovative Research in Science, Engineering and Technology, vol. 4, no. 7, pp. 1-8, 2015.
[3]  E. J. G. Sedighizadeh, "Stochastic multi-objective economic-environmental energy and reserve scheduling of microgrids considering battery energy storage system," Int. Journal of Electrical Power Energy Syst, vol. 106, pp. 1-16, 2018.
[4]  R. a. Li, "An overview of distributed microgrid state estimation and control for smart grids," Cross reference, vol. 15, pp. 4302-4325, 2015.
[5]  S. Dash and V. P. kumri, "A Design of 400 KW Photovoltaic Array Connected Micro Grid System Using MatlabSimulink Model," International Journal of Advanced Research in Electrical, Electronics and Instrumentation Engineering, vol. 7, no. 12, pp. 4257-4262, 2018.
[6]  A. B. Baams, I. T. Thuku and S. Samuel, "Design of a grid connected solar system for Yola North and South, Adamawa State," International Journal of Science and Engineering Applications, vol. 6, no. 10, pp. 331-342, 2017.
[7]  S. Nagalakshmi, M. Prabha and R. Senthamarai, "Design and Implementation of Aurdino Based Smart Home Energy Management System Using Renewable Energy Resources," International Journal of ChemTech Research, vol. 10, no. 6, pp. 696-700, 2017.
[8]  H. Shayeghi, E. Shahryari and M. Moradzadeh, "A Survey on Microgrid Energy Management Considering Flexible Energy Sources," Energies, a Review, pp. 1-26, 31 May 2019.
[9]  M. Tabaa, A. Chakir, F. Moutaouakkil and H. Medromi, "Optimal energy management for a grid connected PV-battery system," Energy Reports, pp. 218-229, 06 September 2019.
[10]  M. B. Butt, S. Dilshad and S. Rauf, "Design of home load management system for load rationing in Pakistan," Wiley, pp. 1-17, 2020.
[11]  D. Chippada and M. D. Reddy, "Mathematical modeling and simulation of energy management in smart grid," International Journal of Smart Grid and Clean Energy, vol. 9, no. 4, pp. 746-755, 2020.
[12]  M. Palmer, S. Elliott and H. Jack, "Solar Irradiance Data," Solcast, 06 February 2019. [Online]. Available: https://solcast.com/solar-data-api/solar-irradiance-data-everywhere-you-need-it/. [Accessed 27 July 2021].
[13]  J. M. Bright, "Validation of a satellite-derived solar irradiance dataset," ResearchGate, vol. 07, no. 86, pp. 1-23, 2019.
[14]  J. Mora and D. Amaya, "Modelling and Simulation of a Photovoltaic Solar System with Lead-Acid Battery," International Journal of Applied Engineering Research, vol. 13, no. 16, pp. 12827-12831, 2018.
[15]  webmaster@arduino.cc, "Guide/Introduction to arduino," 05 February 2018. [Online]. Available: https://www.arduino.cc/en/Guide/Introduction. [Accessed 22 October 2020].
[16]  trademark@arduino.cc., "Introduction to Arduino," 05 February 2018. [Online]. Available: https://www.arduino.cc/en/Guide/Introduction. [Accessed 15 October 2020].
[17]  M. O. de Lara, C. Unsihuay and V. R. Gonçalves, "Integrated project of a smart microgrid allied with energy management: An initiative to reduce electrical energy costs," Brazilian Archives of Biology and technology, vol. 62, pp. 1-8, 2019.
[18]  B. Hayward, M. Amiel, L. Irvine and R. Laner, "2021 MuleSoft LLC," 2021. [Online]. Available: https://www.mulesoft.com/resources/api/what-is-an-api. [Accessed 9 July 2021].
[19]  H. Bellia, R. b. Youcef and M. Fatima, "A detailed modeling of photovoltaic module," NRIAG Journal of Astronomy and Geophysics, vol. 3, pp. 53-61, 2014.