Solar Energy Harvesting and Storage Optimization Using Machine Learning

Solar Energy Harvesting and Storage Optimization Using Machine Learning

Elizabeth O. Amuta* Edith E. Alagbe Praise Iyogun Gabriel O. Sobola

Department of Electrical and Information Engineering, Covenant University, Ota 112104, Nigeria

Department of Chemical Engineering, Covenant University, Ota 112104, Nigeria

Corresponding Author Email: 
elizabeth.amuta@covenantuniversity.edu.ng
Page: 
195-205
|
DOI: 
https://doi.org/10.18280/ijepm.100204
Received: 
15 February 2025
|
Revised: 
15 April 2025
|
Accepted: 
15 May 2025
|
Available online: 
30 June 2025
| Citation

© 2025 The authors. This article is published by IIETA and is licensed under the CC BY 4.0 license (http://creativecommons.org/licenses/by/4.0/).

OPEN ACCESS

Abstract: 

The study uses embedded machine learning (ML) to focus on solar energy harvesting and storage optimisation. The research investigated environmental parameters, input features, including temperature, relative humidity, target variable, month and day, and solar surface radiation. A dataset for 5 years was used. An ML algorithm was employed for the study, and the linear regression feedforward neural network (FFNN) was used. The normal root mean squared (nRMSE) and R-squared (R2) scores were used as criteria to evaluate the model's performance. A solar tracker system, built with Arduino and ESP32 microcontrollers, maximises energy collection. The system harnesses the power of solar panels to convert sun radiation into electrical energy, which is then stored in a 3.7 V rechargeable battery. This battery powers the sensors, ensuring continuous operation. The root mean squared error (RMSE) value was 80.48 W/m², which measures the typical prediction error and optimises energy harvesting. The R2 of 0.896 shows the model experiences ~90% of the solar irradiance variability data. The higher R2 ensures the model reliably captures environmental parameters critical for adjusting solar panels and maximising energy efficiency. The research's practical implications show that we can have a high uptime for solar power systems, close to 24 hours. Embedded ML can enhance renewable energy management.

Keywords: 

machine learning (ML), solar panel, lithium battery, sensors, microcontroller, feedforward neural network (FFNN)

1. Introduction

In current times, the explosive growth of artificial intelligence (AI) has had transformative changes in several sectors [1, 2]. The capability of machine learning (ML) to process large data and derive meaningful insights has brought in an era of unique innovations [3, 4]. This paradigm shift prompts us to study novel applications, especially in fields where intelligent decision-making will make a substantial difference [5, 6]. One such area is in renewable energy management, considering solar energy systems [7-9]. Solar energy has a promising solution for various sectors [10-12]. Practical strategies for harnessing solar energy are essential to achieve robustness and reduce dependence on fossil fuel resources [13-15].

In recent years, the coming in of ML and AI into various domains has spurred advancements, and one such domain of great benefit is renewable energy management technologies, especially solar energy harvesting and storage optimisation. [16, 17]. Harnessing the power of ML in energy harvesting, storage, and management laid the foundations for more structured and sustainable practices [18]. Integrating ML algorithms enhances energy harvesting efficiency and introduces predictive maintenance and optimisation strategies [19, 20]. AI and ML have turned out to be powerful tools that can be deployed to transform the method of generating, distributing, and consuming solar energy. The study also explored how the challenges of solar energy can be addressed using AI and ML, and as a way to help create a more sustainable energy future [21]. The study [22] proposed a system to solve solar tracking by arranging the solar module to track the Sun, handling the air velocity and pressure created on the structure due to the different angles, and creating air resistance, thereby tracking the sun and achieving structural stability and optimisation. Study [23] reviewed types of solar PV and solar tracking systems, focusing on the design and performance analysis of the various dual-axis tracking solar systems. The choice of the use of trackers depends mainly on the physical features of the land.

Embedded ML integration can have transformative potential in renewable energy, involving solar energy systems, emphasizing their role in improving solar cell efficiency and contributing to a greener future. ML revolution in renewable energy systems is providing innovative solutions for optimising efficiency and performance in solar energy systems, thereby optimising the output of energy [24, 25]. Hence, the significance of this study lies in its potential to contribute to global sustainable energy solutions [26], demonstrating the effectiveness of embedded ML and edge computing in optimising solar energy systems. This study is vital in many dimensions, looking at sensitive aspects of renewable energy management and technological convergence. Efficient energy harvesting and optimised battery management contribute to steady equipment life, reducing the need for recurring replacements and minimising environmental impact [27]. This study explores how advanced technologies can be harnessed to address pressing environmental challenges and improve the sustainability of energy systems. Hence, the study aims to develop a system to demonstrate an efficient solar energy harvesting and storage optimisation system using embedded ML.

2. Related Work

Solar energy systems often grapple with inefficiencies in energy harvesting, leading to sub-optimal performance, increased downtime, and heightened environmental impact [28, 29]. As the integration of solar trackers becomes more common, there is a need for innovative solutions that enhance energy yield through precise solar panel alignment and incorporate advanced technologies that can handle the evolving intricacy of renewable energy systems [30, 31].

The ability of ML algorithms to analyse data patterns and make informed decisions that align seamlessly with the intricacies of managing solar energy systems is vital [32, 33]. Exploiting these technologies promises to enhance energy yield from solar panels and introduce intelligent techniques for system optimisation to ensure a sufficient economic return on investment in solar energy systems. Dobrilovic et al. [34] analysed the use of ML techniques for evaluating solar panel performance in edge sensor devices. The study utilised Python Scikit-learn and micromlgen libraries on Arduino clone boards (ESP8266) to implement edge intelligence to predict solar panel voltage output and deploy a decision tree model. However, the study was limited to UV and BH1750 sensors, which did not cover all ambient conditions; the scope was confined to voltage prediction and did not extend to other performance metrics like current or power. Khadka et al. [35] presented current solar photovoltaic panel cleaning systems practices and prospects of ML implementation. The paper reviewed current solar panel cleaning practices and potential ML implementations, but lacked real-time data integration and actuator implementation.

In study [36], the authors used regression models to predict solar irradiance with all-sky image features but did not incorporate real-time actuator adjustments for optimisation. Peltonen et al. [37] analysed many faces of edge intelligence, considering edge intelligence applications and benefits, and highlighted diverse applications and benefits of edge computing, including reduced latency and improved data processing. The study had a limitation focused on specific environmental monitoring applications. Satyanarayanan [38] presented the Emergence of Edge Computing, exploring edge computing technologies and their implications. The study identified edge computing as a critical enabler for real-time data processing and reduction in latency, and the paper had a limitation in the application of not extending the work to renewable energy systems [39]. The paper examined the impact of AI on photovoltaic systems, revolutionising solar energy.

The study considered AI applications in photovoltaic systems. It demonstrated significant improvements in solar energy efficiency through AI, but with insufficient focus on small-scale integrated systems with real-time adjustments. The authors [40] presented an innovative solar energy management system supplying energy to several loads within intervals and charging and discharging battery banks. The study used a modularised method to design, simulate, construct, and test the energy conversion. Soomar et al. [41] conducted a statistical analysis, emphasising the efficiency and performance of some solar technologies and identifying their global rankings in terms of power output. The study also assumes that the main goals of optimisation methods are to reduce investment, operation, and maintenance costs and emissions to improve system dependability. Ogundipe et al. [42] presented advancements in energy storage solutions, including high-capacity batteries and hybrid systems that enhance the reliability and efficiency of solar energy, making it a practical alternative for residential, commercial, and industrial applications. The study also noted that reducing the cost of solar energy increases its accessibility and promotes its adoption worldwide.

The authors in the study [43] explored Efficiency and Sustainability in Solar Photovoltaic Systems, considering Maintenance, sizing technologies, optimisation, material degradation, and advanced monitoring systems as essentials for sustaining solar system efficiency over time.

3. Materials and Methods

ML models are an essential element of AI that crucially enhances the function of energy storage systems, including batteries. The algorithms can predict energy demand and adjust charge and discharge cycles accordingly [44]. Operational optimisation of renewable energy systems can deploy ML by continuously adjusting system parameters to maximise system output. The orientation and tilt of solar panels can be optimised by ML models using real-time weather data of solar PV systems to ensure that the panels receive the most sunlight when positioned [45]. The study methodology overview is given in Figure 1.

Figure 1. The solar PV tracking system block diagram

3.1 Method overview

3.1.1 The system setup

This involves selecting appropriate components and preparing them for integration. The Arduino Uno and ESP32 microcontrollers were chosen for their low power consumption and computational efficiency, making them ideal for energy-constrained applications. The light intensity sensor (photodiode), temperature sensor, and humidity sensor are configured to monitor environmental conditions accurately. A 3.7 V rechargeable lithium-ion battery is the primary energy storage medium, while a solar panel converts sunlight into electrical energy to power the solar PV tracker system.

3.1.2 Sensor integration

The sensors were calibrated before integration into the system to ensure accurate data collection. The light intensity, temperature, and humidity sensors are installed and connected to the Arduino Uno, which handles data gathering and preprocessing. This setup ensures the sensors provide reliable input for subsequent system operation stages.

3.1.3 Data transmission

A robust communication protocol is established between the Arduino Uno and ESP32 to facilitate seamless data transfer. The Arduino transmits preprocessed data from the sensors to the ESP32 using serial communication. This transmission allows the ESP32 to analyse the data and make predictions for optimising system performance. 

3.1.4 ML model deployment

Key features for the ML model were identified to guide energy optimisation decisions. Sample data is collected and preprocessed to train a lightweight ML model suitable for embedded systems, which is linear regression. The trained model is then optimised to minimise memory and computational requirements, ensuring efficient deployment on the ESP32 microcontroller. 

3.1.5 System implementation

Once the ML model is trained, it is deployed on the ESP32 microcontroller. The model is configured to operate in real time, analysing incoming data from the Arduino and making predictions about optimal sensor operations and energy management strategies. This implementation ensures the system operates autonomously and efficiently.

3.1.6 Energy management

The energy management strategy leverages predictions from the ML model to adjust the solar panel's orientation dynamically, maximising energy harvesting throughout the day. Low-power modes are implemented to conserve battery life, where sensors and microcontrollers are deactivated during periods of inactivity, such as nighttime or extended cloudy conditions.

3.1.7 Simulation and testing

Performance metrics were deployed to assess the energy harvested, battery charge cycles, system uptime, and overall optimisation. The system was tested to evaluate its functionality and performance. Figure 2 illustrates the solar tracker logic flowchart of the study.

Figure 2. Solar tracker logic flowchart

3.2 Solar PV system description

The solar PV system assembles components comprising the solar tracker kit, designed to optimise energy harvesting. The Keystudio Solar Panel Tracking Kit provided sensors such as the light intensity module, a pivotal component selected for its accuracy, low power consumption, and adaptability to varying environmental conditions. This module, strategically positioned on the solar tracker, is the primary sensor capturing real-time data on ambient light conditions. The solar tracker system operates by continuously monitoring the intensity and direction of sunlight through its sensors.

3.3 Key components

3.3.1 Keystudio Uno

Keystudio Uno is a variation of the Arduino Uno. The primary control unit handles sensor data acquisition and servo motor control. The Keystudio Uno has 14 digital input/output pins, USB connection, 16 MHz crystal oscillator, power jack, reset button, and 2 ICSP headers. The VCC can be switched through a slide switch between 3.3 V and 5 V. The Keystudio Uno is given in Figure 3.

Figure 3. Keystudio Uno

3.3.2 Solar panel

The solar panel is a crucial solar energy harvesting system for converting sunlight into electrical energy. The solar panel with dimensions of 137 mm by 85 mm is given in Figure 4. The main factors affecting solar panels' output performance include load impedance, sunlight intensity, temperature, and illuminance. The Polyethene Terephthalate (PET) Solar PV Panel was deployed in the study, a type of thin-film solar panel known for being durable and flexible. The Solar Panel specifications are shown in Table 1. The maximum charging current provided by the solar panel is 80 mA. The solar panel requires extended periods of direct sunlight to charge the battery sufficiently.

Figure 4. Solar panel

Table 1. Parameters of the solar panel

Solar Panel Ratings

Specification Values

Power rating

1.5 W

Panel dimensions

137 mm × 85 mm × 2 mm

Rating of voltage

6 V

Rating of current

250 mA

Weight

36.5 g

3.3.3 BH1750 digital light intensity module

The module measures ambient light intensity accurately, supplementing the photo-resistor. Figure 5 shows the module mounted beside the aforementioned solar panel.

Figure 5. BH1750 light intensity module

3.3.4 Photo-resistor module

The module detects light intensity from different directions, enabling the system to determine the optimal panel orientation. The photo-resistor module is given in Figure 6.

Figure 6. Photo-resistor

3.3.5 DHT11 temperature and humidity sensor

The Sensor monitors environmental conditions to assist in predicting optimal operational parameters for energy conservation. Figure 7 presents the DHT11 temperature and humidity sensor.

Figure 7. DHT11 temperature and humidity sensor

3.3.6 Solar USB charging module

The module charges the lithium-ion battery 2200 mAh, ensuring a sustainable power supply. The boost module increases the battery output voltage to 6.6 V. Figure 8 shows the solar charging module. The parameters for the module are given in Table 2.

Figure 8. Solar USB charging module

Table 2. Parameters of solar USB charging module

External Battery

2200 mAh Battery

Solar panel interface input voltage

4.4-6 V

Battery constant voltage charging value

4.15-4.24 V

Maximum output current

1 A

Output voltage

6.6 V

Output interface

3 P 2.54 mm Bent Needle

Maximum charging current

800 mA

Charging interface

1. Micro USB

2. HP2.0MM interface for solar panel

Environmental attributes

ROHS

3.3.7 Servo motors

The solar panel's position is adjusted based on the processed data from the sensors, making it face the direction of maximum sunlight. There are 2 of them provided to ensure the flexibility of the solar panel's movements.

3.3.8 LCD display with I2C interface

This is used to view the illuminance, temperature, and humidity at a particular time. Figure 9 shows the LCD display in front and with the I2C interface behind it.

Figure 9. LCD display with I2C interface

3.3.9 Smartphone charging module

The solar kit also has a charging module that can be deployed to charge mobile devices. Figure 10 depicts the smartphone charging module.

Figure 10. Smartphone charging module

3.3.10 Battery and the battery box

The kit uses a 2200 mAh lithium battery, which is recommended to have a capacity greater than 2200 mAh. The energy harvested from the solar panel is stored in the battery. Figure 11 shows the 2200 mAh lithium battery and the battery box that holds the battery.

Figure 11. (a) 2200 mAh lithium battery; (b) Battery box

3.4 Solar PV system description

The weather conditions dataset used in this study was taken from an open source as incorporated in Solcast [46]. The spreadsheet had over 80,000 data points. The resolution was set to Ota, Ogun state as the location, with coordinates Latitude 6.6927°N, Longitude 3.23655°E. Past data was collected over about 5 years (from June 2019 to June 2024) to ensure a comprehensive dataset that takes seasonality into account and captures various environmental conditions. The dataset includes temperature, time of the day, relative humidity, solar radiation, and detailed day/year information, which are essential for optimizing energy production from solar panel sources. The data were taken at 30-minute regular intervals. Table 3 presents the solar data sample from the file.

Table 3. Parameters of solar USB charging module

Day of Year (Day no. in 365 Days.)

Time of Day (mins)

Relative Humidity (%)

Air Temperature (℃)

Solar Irradiance (W/m2)

160

30

94.8

26

0

160

60

94.8

26

0

160

90

94.9

26

0

160

120

95.2

26

0

160

150

95.3

25

0

160

180

95.3

25

0

160

210

95.2

25

0

160

240

94.9

26

0

160

270

94.9

26

0

160

300

95.2

26

0

160

330

95.2

26

0

160

360

94.9

26

9

160

390

94.4

26

54

3.5 Data preparation

Historical data mentioned in section 3.4 were used to train ML models. The dataset was split into training and test sets. Out of the total dataset, 80% of the samples were used for training the model, while the remaining 20% were used for testing to evaluate its performance on unseen data. Data preprocessing technique, normalisation was deployed for the study dataset, to reduce the size, increase the robustness of the model, and improve the training time of the neural network. The solar surface radiation values as the target value were scaled with a MinMaxScaler to ensure consistent scaling across all inputs, and the input features were normalised using a StandardScaler. The variable's features were standardised to ensure consistency and enhance ML models' effectiveness. The features are split into two: the input features, temperature, relative humidity, month, and day, and the target variable. Temporal aggregation was conducted to capture seasonal patterns and variations over time. The daily weather data includes temperature, relative humidity, month, and day. A regression-trained TensorFlow type of ML program was employed in the study to predict solar energy generation in terms of global horizontal irradiance (GHI) [47, 48]. A batch size of 32 was deployed for a more frequent model update. The model was built using features such as sinusoidal transformations of time of day and day of the year, along with temperature and humidity, to capture both the cyclical nature of solar irradiance and its dependence on environmental factors. The sinusoidal transformation of the time of day was specifically chosen to represent its periodic nature, as solar irradiance follows a daily cycle that repeats every 24 hours. This transformation allows the model to learn these cyclical patterns more effectively than using raw time values. The proposed model was trained and evaluated using a feedforward neural network (FFNN). The FFNN was employed to predict solar irradiance for optimizing solar energy harvesting. The model is implemented as an FFNN, consisting of an input layer with ReLU activation functions, hidden layers, and an output layer. A FFNN consists of multiple layers of interconnected neurons with a deep learning architecture [49]. Figure 12 shows the common configuration of FFNN.

Figure 12. FFNN general configuration

3.6 Neural network

The neural network was implemented using TensorFlow and consists of three layers:

3.6.1 Input layer

The input receives the data that was used to train the model. The input layer processed environmental features such as sinusoidal transformations of time of day and day of the year, as well as temperature and humidity. These features were normalised to ensure consistent scaling across inputs.

3.6.2 Hidden layers

The model included two dense hidden layers using the ReLU activation function. These layers extracted non-linear relationships between input features and solar irradiance, enabling the model to capture complex patterns of solar irradiance values.

3.6.3 Output layer

The output layer consists of a single neuron that provides a continuous regression output, predicting solar irradiance in watts per square meter.

3.7 Loss function

The loss function measures how well the model predicts the solar energy output for a given set of inputs [50], considering the numerous features that affect energy production. The features include temperature, relative humidity, and the month and day. The loss function adjusts its parameters to optimize its predictions over time. The learning rate controls the step size taken towards the minimum of the loss function when training the dataset. Hence, a learning rate of 0.001 was used for the study to give the model optimal, accurate predictions.

3.8 The proposed model features

3.8.1 Time of day

The time parameter captures daily changes in solar radiation levels. Solar energy availability varies throughout the day. This feature helps predict optimal energy harvesting times and manage sensor activity.

3.8.2 Day of the year

Seasonal changes affect sunlight intensity and duration. Including this feature allows the model to give results for seasonal variations in solar energy. The day of the year helps to identify seasonal cycles, such as solar angle changes and day length, that affect solar radiation.

3.8.3 Temperature

Temperature influences the amount of solar radiation. Atmospheric absorption and scattering are usually increased by higher temperatures, which affects solar radiation levels. Monitoring temperature helps optimise energy storage and system operation, thereby influencing battery efficiency and performance.

3.8.4 Relative humidity

Relative humidity impacts how solar radiation is transmitted and scattered, and also influences the atmosphere's composition. Changes in relative humidity can affect cloud formation and the amount of atmospheric particulates interacting with solar radiation.

3.9 Performance criteria

The selection of performance criteria relies on the nature of the task, which can be regression, classification, or optimisation. The study deployed two regression performance metrics, including root mean squared error (RMSE) [51] and coefficient of determination, R-squared (R2) [52], deploying predicted and actual values. RMSE and R2 as performance metrics were chosen for this study because RMSE is easier to interpret in a research study when compared with other metrics and R2 normally provides a baseline for comparing models, when also compared with other metrics. The metrics predict continuous variables like energy generation or consumption. Eqs. (1) and (2) show the R2 and the RMSE matrices, respectively.

$\mathrm{R}^2=1-\frac{\sum_{\mathrm{i}=1}^{\mathrm{n}}\left(\mathrm{y}_{\text {actival, } \mathrm{i}}-\mathrm{y}_{\text {pred, } \mathrm{i}}\right)^2}{\sum_{\mathrm{i}=1}^{\mathrm{n}}\left(\mathrm{y}_{\text {actual, } \mathrm{i}}-\overline{\mathrm{y}}_{\text {actual, } \mathrm{i}}\right)^2}$               (1)

The RMSE metric was used to penalize more significant errors heavily. RMSE gives insight into the performance of the model under extreme conditions.

$\mathrm{nRMSE}=\frac{\sqrt{\frac{1}{\mathrm{n}} \sum_{\mathrm{i}=1}^{\mathrm{n}}\left(\mathrm{y}_{\text {actual, } \mathrm{i}}-\mathrm{y}_{\text {pred }, \mathrm{i}}\right)^2}}{\mathrm{y}_{\max }-\mathrm{y}_{\min }}$              (2)

where, $\mathrm{y}_{\text {pred,i }}$ is the predicted value of the ith data, $\mathrm{y}_{\text {actual, } \mathrm{i}}$ is the actual value for the ith data point, and n is the total number of data points. $\overline{\mathrm{y}}_{\text {actual,i }}$ is the mean of the actual values, ymax is the maximum value of the actual data, and ymin is the minimum value of the actual data.

3.10 Feature conversion

Time of day conversion: The study uses a sinusoidal function to convert the time of day into a format suitable for a M=- model that helps to capture the periodic nature of daylight as given in Eqs. (3) and (4). This conversion transforms the time into two features representing the cyclical pattern of a day.

Time of day $(\sin )=\sin \left(\frac{2 \pi \times \text { hour }}{24}\right)$              (3)

Time of day $(\cos )=\cos \left(\frac{2 \pi \times \text { hour }}{24}\right)$              (4)

Day of the year conversion: Convert the date into a day-of-the-year format:

Day of the Year = Date                   (5)

Eq. (5) represents the day of the year using sinusoidal functions to capture seasonal variations as with the time-of-day conversion. The expression for energy harvesting is given in Eq. (6).

$\text {Energy Harvesting Efficiency}=\frac{\text {Power Output}}{\text {Solar Irradiance}} \times \text {Area of the Solar Panel}$                   (6)

Battery charge and discharge rates are given in Eqs. (7) and (8).

Charging Rate $=\frac{\text { Energy Harvested }}{\text { Battery Capacity }}$                   (7)

Discharging Rate $=\frac{\text { Energy Consumed }}{\text { Battery Capacity }}$                   (8)

The duty cycle to balance energy consumption and operational efficiency used for power management is given in Eq. (9).

Duty Cycle $=\frac{\text { Active Duration }}{\text {Total Duration }}$                  (9)

3.11 Implementing embedded ML with the ESP32

The ESP32 microcontroller was selected for the study to add an intelligence layer by using embedded ML algorithms to predict the best times and positions for solar panel adjustments. It considers several factors, including time of day, day of the year, temperature, and humidity, to optimize energy harvesting and minimize power consumption. The ESP32, shown in Figure 13, is designed for energy efficiency, which is crucial for a solar-powered system where conserving battery life is essential due to its low power consumption. The ESP32's built-in real-time clock (RTC) allows it to keep accurate time, providing essential factors critical for the ML model. Arduino does not come with a built-in RTC. Its features of Wi-Fi and Bluetooth capabilities facilitate wireless communication and data transmission, making it easier to interface with other devices if needed. With its dual-core processor, the ESP32 can handle complex tasks, including running ML algorithms, without significant latency, with robust processing power. The external sensors and modules make it an essential solar tracking and optimisation system component.

Figure 13. ESP32 microcontroller unit

3.11.1 Hardware setup

The core hardware components included an Arduino Uno and an ESP32 microcontroller. The Arduino Uno controlled the solar panel's physical movements, while the ESP32 handled data processing and ML tasks. Various sensors were integrated into the system to monitor environmental conditions such as light intensity, temperature, and humidity. These sensors provided real-time data for optimising the solar panel's orientation and performance. Figures 14, 15, and 16 present the prototype of the designed solar tracking system, the solar panel tracker when not powered and when powered, respectively. The LCD displayed parameters such as temperature, humidity, and luminous intensity.

Figure 14. Prototype of the designed solar tracking system

Figure 15. Solar tracker, when not powered

Figure 16. Solar tracker, when powered

3.11.2 Software development

The software was modular, with separate code bases for the Arduino and ESP32. The Arduino was programmed to control the servo motors to adjust the solar panel's angle, considering the input from the ESP32. ML algorithms were trained and embedded into the ESP32.

3.11.3 System optimisation and testing

System testing was conducted to validate the accuracy of the ML models and the responsiveness of the hardware. It was placed beside the window of a room on the second highest floor of a 4-storey building for nearly a week straight. It was observed that the system was able to stay active for most of the day; the sensors were active for about a third of the day, and the system completely shut down after 7 days, primarily due to how often it rained during that period. After confirming that the system was operating optimally, it was deployed in the same position to monitor its performance over about 10 days. Data collected during this phase was used to determine the system performance metrics. Figure 17 presents the solar tracking system used to charge devices, such as laptops.

3.12 Implementing embedded ML with the ESP32

The solar tracking system begins its operation with the initialisation of the Arduino Uno and ESP32 microcontrollers. The battery powers the calibrated sensors. The Arduino monitors the environmental parameters throughout the day using integrated sensors to collect data. The data is transmitted to the ESP32, where an embedded ML algorithm processes the information to predict the solar irradiance. The ESP32 sends the calculated adjustment values back to the Arduino, which drives the servo motors to reorient the solar panel toward the optimal position. As sunlight is converted into electrical energy by the solar panel, the system stores the energy in a 3.7 V lithium-ion battery via a solar USB charging module. The system operates autonomously, with the ML algorithm ensuring that sensors and motors are only active when necessary, conserving battery life. The operational approach ensures efficient energy harvesting and storage while maintaining minimal energy consumption, enabling the solar tracking system to function sustainably for extended periods. After training, the model was converted to TensorFlow Lite format and deployed on an ESP32 microcontroller for real-time inference. This lightweight deployment enables the system to operate autonomously, predicting GHI and optimising solar panel orientation efficiently without reliance on cloud-based resources.

Figure 17. Solar tracker connected to a laptop

4. Results and Discussion

Harvesting solar energy and optimising storage using ML was the focus of the research. Incorporating ML into renewable energy systems introduces a positive application in power systems [53]. The study explored an ML model for harvesting solar energy, management, and optimising energy.

4.1 Daily energy parameter harvested

The solar panel was exposed to sunlight on consecutive days during the testing period. The energy harvested was recorded every hour over 10 days. The daily energy parameter harvested results are summarised in Table 4. The average energy harvested per day was approximately 1.35 Wh. This data indicates a relatively consistent energy capture, with variations due to changing weather conditions.

Table 4. Daily energy parameter harvested

Day

Energy Harvested (Wh)

Charge Cycles

Weather Simulation

Light Intensity (W/m²)

Uptime (Hours)

Activation Duration (Hours)

1

1.2

0.5

Cloudy

300

23.5

8.5

2

1.4

0.6

Slightly cloudy

500

23.9

9.0

3

1.1

0.4

Cloudy

250

22.9

8.0

4

1.5

0.6

Sunny

850

24.0

9.5

5

1.3

0.5

Slightly cloudy

450

23.2

8.2

6

1.6

0.7

Sunny

900

24.0

9.7

7

1.4

0.6

Slightly cloudy

500

23.7

8.8

8

1.2

0.5

Cloudy

300

23.5

8.6

9

1.3

0.5

Slightly cloudy

500

23.4

8.3

10

1.5

0.6

Sunny

860

24.0

9.0

4.2 Battery charge cycles

The battery's number of charge cycles during the testing period was monitored. The process of charging the battery from 0 percent to 100 percent and then discharging it back to 0% is known as the charge cycle. The average number of daily charge cycles was approximately 0.55, indicating efficient use of the harvested energy.

4.3 System uptime

The system uptime was recorded to evaluate the operational duration of the system without interruptions. The system was designed to enter low-power mode during periods of inactivity to conserve energy. The system maintained an uptime of approximately 24 hours on most days, demonstrating the effectiveness of the power management strategies.

4.4 Sensor activity duration

The duration for which the sensors were active was also tracked to ensure they were powered only when necessary. The sensors were active for an average of 8.76 hours per day, showing that the ML model effectively predicted the optimal times for sensor operation. The ML model optimised sensor activity, reducing unnecessary power consumption and extending the battery's lifespan. This approach ensured that the system remained energy-efficient even under varying environmental conditions. The solar tracker energy system results indicate that integrating embedded ML and edge computing significantly improved the efficiency of solar energy harvesting and storage efficiency [54]. The consistent energy harvesting and high system uptime suggest that the solar tracker and power management strategies were effectively implemented. The normal root mean squared (nRMSE) was 80.48 W/m², approximately 44.57% of the mean GHI and 8.31% of the maximum GHI. This indicates that the model performs well during peak energy production conditions while maintaining reasonable accuracy overall. The R2 score of 0.896 shows that the model captures nearly 90% of the variance in GHI, demonstrating strong predictive capabilities. Multiple optimisers were tested, including Adam Optimiser, Stochastic Gradient Descent (SGD), and root mean square propagation (RMSprop). RMSprop achieved a slightly better loss of 0.0063 compared to 0.0068 for Adam and 0.0068 for SGD, reflecting a minor performance advantage as given in Table 5. The low loss values across all optimisers reaffirm the model's architecture and preprocessing pipeline suitability for this regression task. Therefore, the loss (0.0064) reflects how well the model minimises errors during training. That means the model learned the patterns in the data effectively, enabling accurate solar irradiance predictions.

Table 5. Multiplier optimiser

Optimizer

Adam

Sdg

Rmsprop

Loss

0.0068

0.0068

0.0064

The study had an RMSE value of 80.48 W/m², which measures the typical prediction error. The low RMSE directly improves solar panel alignment, leading to more accurate solar irradiance predictions and optimising energy harvesting. R2 had 0.896; this shows the model experiences ~90% of the solar irradiance variability data. A higher R2 ensures the model reliably captures environmental parameters critical for adjusting solar panels and maximizing energy efficiency. The experimental results show the viability of deploying embedded ML for efficient renewable energy management.

The findings provide valuable insights that can be scaled up for larger applications. The key findings of the research are summarised as follows:

  1. Efficient battery charge cycles, with an average of 0.55 cycles per day.
  2. High system uptime, close to 24 hours on most days.
  3. Optimised sensor activity reduces unnecessary power consumption and extends battery life.

The study examined the feasibility and effectiveness of using embedded ML for renewable energy management, providing valuable insights that can be scaled up for larger applications.

Aside from the environmental benefits of optimising solar energy harvesting that leads to energy efficiency, the economic impact of harvesting solar energy includes a reduction of electricity bills for residential homes and businesses, reduces health costs by mitigating air pollution, and increases economic resilience by selling the excess energy generated.

5. Conclusions

The paper presented practical results for renewable energy management and climate change evaluation. The study accurately predicted surface solar radiation. The system's dynamic response to environmental changes ensures optimal energy yield, making it especially valuable for large-scale solar installations. System's potential and value in practical applications includes real-time optimisation performance, because the embedded ML models will predict maximum angle tilt of the solar panel, detect panel soiling early signs and inefficiencies of the inverters. Also, the model can conveniently decide when to supply excess power to the grid, thereby enabling local demand, in case of a solar system connected to the grid, hence improving the efficiency and reliability of solar energy systems. The system currently uses a set of features, including temperature, day of the year, humidity, and time of day, as needed for the Arduino and ESP32 for this study. The model's limitations, such as having data from different locations being trained, can give the model issues because of climate variations; moreover, the battery's nonlinear ageing process gives less precision.

Investigating the integration of cloud-based ML models for more extensive data analysis and management, and overcoming potential limitations the embedded systems pose, developing more powerful and specialized microcontrollers capable of handling more complex ML models and larger datasets tailored to renewable energy applications could be used for enhanced performance, which can be an area for further studies. The energy stakeholders can make decisions and develop sustainable policies for tropical locations.

Acknowledgment

The authors are thankful to the Covenant University Centre for Research, Innovation, and Discovery for sponsoring this study.

Data Availability Statement

The data used in this study are publicly available from Solcast [46].

Nomenclature

GHI

global horizontal irradiance

nRMSE

normal root mean square

Subscripts

max

maximum

min

minmium

  References

[1] Yang, J., Xu, Y., Cao, H., Zou, H., Xie, L. (2022). Deep learning and transfer learning for device-free human activity recognition: A survey. Journal of Automation and Intelligence, 1(1): 100007. https://doi.org/10.1016/j.jai.2022.100007

[2] Subeesh, A., Mehta, C.R. (2021). Automation and digitization of agriculture using artificial intelligence and internet of things. Artificial Intelligence in Agriculture, 5: 278-291. https://doi.org/10.1016/j.aiia.2021.11.004

[3] Zhang, W., Wu, Y., Calautit, J.K. (2022). A review on occupancy prediction through machine learning for enhancing energy efficiency, air quality and thermal comfort in the built environment. Renewable and Sustainable Energy Reviews, 167: 112704. https://doi.org/10.1016/j.rser.2022.112704

[4] Alamo, D.H., Medina, R.N., Ruano, S.D., García, S.S., et al. (2019). An advanced forecasting system for the optimum energy management of island microgrids. Energy Procedia, 159: 111-116. https://doi.org/10.1016/j.egypro.2018.12.027

[5] Heylen, E., Deconinck, G., Van Hertem, D. (2018). Review and classification of reliability indicators for power systems with a high share of renewable energy sources. Renewable and Sustainable Energy Reviews, 97: 554-568. https://doi.org/10.1016/j.rser.2018.08.032

[6] Ciplet, D. (2021). From energy privilege to energy justice: A framework for embedded sustainable development. Energy Research & Social Science, 75: 101996. https://doi.org/10.1016/j.erss.2021.101996

[7] Kaabeche, A., Bakelli, Y. (2019). Renewable hybrid system size optimization considering various electrochemical energy storage technologies. Energy Conversion and Management, 193: 162-175. https://doi.org/10.1016/j.enconman.2019.04.064

[8] Ugwoke, B., Adeleke, A., Corgnati, S.P., Pearce, J.M., Leone, P. (2020). Decentralized renewable hybrid mini-grids for rural communities: Culmination of the IREP framework and scale up to urban communities. Sustainability, 12(18): 7411. https://doi.org/10.3390/SU12187411

[9] Manni, M., Formolli, M., Boccalatte, A., Croce, S., et al. (2023). Ten questions concerning planning and design strategies for solar neighborhoods. Building and Environment, 246: 110946. https://doi.org/10.1016/j.buildenv.2023.110946

[10] Lias, K., Basri, H.M., Buswig, Y.M.Y., Jamali, A., et al. (2024). Development of 9kWp solar system to enhance smoked shrimp (sesar unjur) production at Igan, Sarawak, Malaysia. e-Prime - Advances in Electrical Engineering, Electronics and Energy, 7: 100459. https://doi.org/10.1016/j.prime.2024.100459

[11] Stauch, A. (2021). Does solar power add value to electric vehicles? An investigation of car-buyers’ willingness to buy product-bundles in Germany. Energy Research & Social Science, 75: 102006. https://doi.org/10.1016/j.erss.2021.102006

[12] Orovwode, H., Afolabi, G., Agbetuyi, F., Adoghe, A., et al. (2022). Development and performance evaluation of a solar powered tomatoes storage chamber. IOP Conference Series: Earth and Environmental Science, 1054(1): 012043. https://doi.org/10.1088/1755-1315/1054/1/012043

[13] Magazzino, C., Giolli, L. (2024). Analyzing the relationship between oil prices and renewable energy sources in Italy during the first COVID-19 wave through quantile and wavelet analyses. Renewable Energy Focus, 48: 100544. https://doi.org/10.1016/j.ref.2024.100544

[14] Hess, D.J., McKane, R.G., Belletto, K. (2021). Advocating a just transition in Appalachia: Civil society and industrial change in a carbon-intensive region. Energy Research & Social Science, 75: 102004. https://doi.org/10.1016/j.erss.2021.102004

[15] Li, J., Guo, J., Deng, Y. (2024). Multi-objective optimization for economic load distribution and emission reduction with wind energy integration. International Journal of Electrical Power & Energy Systems, 161: 110175. https://doi.org/10.1016/j.ijepes.2024.110175

[16] Sayed, G.I., Abd El-Latif, E.I., Hassanien, A.E., Snasel, V. (2024). Optimized long short-term memory with rough set for sustainable forecasting renewable energy generation. Energy Reports, 11: 6208-6222. https://doi.org/10.1016/j.egyr.2024.05.072

[17] Munusamy, N., Vairavasundaram, I. (2024). AI and Machine Learning in V2G technology: A review of bi-directional converters, charging systems, and control strategies for smart grid integration. e-Prime-Advances in Electrical Engineering, Electronics and Energy, 10: 100856. https://doi.org/10.1016/j.prime.2024.100856

[18] Okoro, E.E., Adeleye, B.N., Okoye, L.U., Maxwell, O. (2021). Gas flaring, ineffective utilization of energy resource and associated economic impact in Nigeria: Evidence from ARDL and Bayer-Hanck cointegration techniques. Energy Policy, 153: 112260. https://doi.org/10.1016/j.enpol.2021.112260

[19] Bressi, S., Santos, J., Losa, M. (2021). Optimization of maintenance strategies for railway track-bed considering probabilistic degradation models and different reliability levels. Reliability Engineering & System Safety, 207: 107359. https://doi.org/10.1016/j.ress.2020.107359

[20] Kondisetti, L., Katragadda, S. (2024). A multi-objective artificial hummingbird algorithm for dynamic optimal volt-var controls for high electric vehicle load penetration in a photovoltaic distribution network. e-Prime-Advances in Electrical Engineering, Electronics and Energy, 7: 100474. https://doi.org/10.1016/j.prime.2024.100474

[21] Gamor, E. (2023). AI and ML for sustainable solar energy: Revolutionizing the future of renewable energy. https://www.researchgate.net/publication/369885044.

[22] Kale, A.G., Shivpuje, R.S. (2020). Structural analysis and optimization of sun tracking solar system. International Research Journal of Engineering and Technology, 7(9): 302-306. https://d1wqtxts1xzle7.cloudfront.net/64740288/IRJET_V7I948-libre.pdf.

[23] Awasthi, A., Shukla, A.K., SR, M.M., Dondariya, C., et al. (2020). Review on sun tracking technology in solar PV system. Energy Reports, 6: 392-405. https://doi.org/10.1016/j.egyr.2020.02.004

[24] Dastmalchian, O. (2024). Integrating machine learning and artificial intelligence in data science for optimizing renewable energy systems: A case study on solar cells. International Journal of Engineering and Applied Sciences, 12(4): 1-11. https://isi.ac/storage/article-files/Pbpoqv1kot60RyDZL5XuAEuM1Q4WE3ywfymeh5PI.pdf?utm_source=chatgpt.com.

[25] Nadeem, A., Hanif, M.F., Naveed, M.S., Hassan, M.T., et al. (2024). AI-Driven precision in solar forecasting: breakthroughs in machine learning and deep learning. AIMS Geosciences, 10(4): 684-734. https://doi.org/10.3934/geosci.2024035

[26] Sulaiman, N., Hannan, M.A., Mohamed, A., Ker, P.J., et al. (2018). Optimization of energy management system for fuel-cell hybrid electric vehicles: Issues and recommendations. Applied Energy, 228: 2061-2079. https://doi.org/10.1016/j.apenergy.2018.07.087

[27] Oguntosin, V., Ogbechie, P.T. (2023). Design and construction of a foam-based piezoelectric energy harvester. E-Prime-Advances in Electrical Engineering, Electronics and Energy, 4: 100175. https://doi.org/10.1016/j.prime.2023.100175

[28] Zhou, N., Shang, B., Xu, M., Peng, L., Feng, G. (2024). Enhancing photovoltaic power prediction using a CNN-LSTM-attention hybrid model with Bayesian hyperparameter optimization. Global Energy Interconnection, 7(5): 667-681. https://doi.org/10.1016/j.gloei.2024.10.005

[29] Vatti, R., Vatti, N., Mahender, K., Vatti, P.L., Krishnaveni, B. (2020). Solar energy harvesting for smart farming using nanomaterial and machine learning. IOP Conference Series: Materials Science and Engineering, 981(3): 032009. https://doi.org/10.1088/1757-899X/981/3/032009

[30] Oyedepo, S.O., Abam, F.I., Ajayi, O.O., Samuel, O.D., et al. (2024). Recent development in energy conversion systems. Frontiers in Energy Research, 12: 1385470. https://doi.org/10.3389/fenrg.2024.1385470

[31] Idachaba, F.E., Olowoleni, J.O., Ibhaze, A.E. (2017). Design of an automatic renewable energy supply and switching system. In Proceedings of the World Congress on Engineering and Computer Science (WCECS), San Francisco, USA. https://www.iaeng.org/publication/WCECS2017/WCECS2017_pp91-94.pdf. 

[32] Chen, H., Ahmed, O.A., Singh, P.K., Abdullaeva, B.S., et al. (2024). Coupling a thermoelectric-based heat recovery and hydrogen production unit with a SOFC-powered multi-generation structure; An in-depth economic machine learning-driven analysis. Case Studies in Thermal Engineering, 61: 105046. https://doi.org/10.1016/j.csite.2024.105046

[33] Hasan, M.K., Abdulkadir, R.A., Islam, S., Gadekallu, T.R., Safie, N. (2024). A review on machine learning techniques for secured cyber-physical systems in smart grid networks. Energy Reports, 11: 1268-1290. https://doi.org/10.1016/j.egyr.2023.12.040

[34] Dobrilovic, D., Pekez, J., Ognjenovic, V., Desnica, E. (2024). Analysis of using machine learning techniques for estimating solar panel performance in edge sensor devices. Applied Sciences, 14(3): 1296. https://doi.org/10.3390/app14031296

[35] Khadka, N., Bista, A., Adhikari, B., Shrestha, A., et al. (2020). Current practices of solar photovoltaic panel cleaning system and future prospects of machine learning implementation. IEEE Access, 8: 135948-135962. https://doi.org/10.1109/ACCESS.2020.3011553

[36] Fu, C.L., Cheng, H.Y. (2013). Predicting solar irradiance with all-sky image features via regression. Solar Energy, 97: 537-550. https://doi.org/10.1016/j.solener.2013.09.016

[37] Peltonen, E., Ahmad, I., Aral, A., Capobianco, M., et al. (2022). The many faces of edge intelligence. IEEE Access, 10: 104769-104782. https://doi.org/10.1109/ACCESS.2022.3210584

[38] Satyanarayanan, M. (2017). The emergence of edge computing. Computer, 50(1): 30-39. https://doi.org/10.1109/MC.2017.9

[39] Mohammad, A., Mahjabeen, F. (2023). Revolutionizing solar energy: The impact of artificial intelligence on photovoltaic systems. International Journal of Multidisciplinary Sciences and Arts, 2(3): 591856. https://doi.org/10.47709/ijmdsa.v2i1.2599

[40] Umoh, V., Obot, J., Ekpe, U. (2019). Development of a smart solar energy management system. International Journal of Advanced Research and Publications, 3(2): 1-5. https://d1wqtxts1xzle7.cloudfront.net/59095921/Development-Of-A-Smart-Solar-Energy-Management-System20190430-88179-w9sycg-libre.pdf.

[41] Soomar, A.M., Hakeem, A., Messaoudi, M., Musznicki, P., et al. (2022). Solar photovoltaic energy optimization and challenges. Frontiers in Energy Research, 10: 879985. https://doi.org/10.3389/fenrg.2022.879985

[42] Ogundipe, O.B., Okwandu, A.C., Abdulwaheed, S.A. (2024). Recent advances in solar photovoltaic technologies: Efficiency, materials, and applications. GSC Advanced Research and Reviews, 20(1): 159-175. https://doi.org/10.30574/gscarr.2024.20.1.0259

[43] Iturralde Carrera, L.A., Garcia-Barajas, M.G., Constantino-Robles, C.D., Álvarez-Alvarado, J.M., et al. (2025). Efficiency and sustainability in solar photovoltaic systems: A review of key factors and innovative technologies. Eng, 6(3): 50. https://doi.org/10.3390/eng6030050

[44] Graves, D.Z., Bilbao, A.V., Bayne, S.B. (2024). Machine learning based foreign object detection in wireless power transfer systems. e-Prime-Advances in Electrical Engineering, Electronics and Energy, 7: 100384. https://doi.org/10.1016/j.prime.2023.100384

[45] Tanoli, I.K., Mehdi, A., Algarni, A.D., Fazal, A., et al. (2024). Machine learning for high-performance solar radiation prediction. Energy Reports, 12: 4794-4804. https://doi.org/10.1016/j.egyr.2024.10.033

[46] Solcast. The solcast API toolkit. https://toolkit.solcast.com.au.

[47] Cheung, P., Beckett, P., Kumar, D.K. (2023). A recovery-point mechanism for low-power embedded ML applications. Research Square. https://doi.org/10.21203/rs.3.rs-3774323/v1

[48] Merenda, M., Porcaro, C., Iero, D. (2020). Edge machine learning for AI-enabled IoT devices: A review. Sensors, 20(9): 2533. https://doi.org/10.3390/s20092533

[49] Es-Sabery, F., Hair, A., Qadir, J., Sainz-De-Abajo, B., et al. (2021). Sentence-level classification using parallel fuzzy deep learning classifier. IEEE Access, 9: 17943-17985. https://doi.org/10.1109/ACCESS.2021.3053917

[50] Armghan, A., Logeshwaran, J., Raja, S., Aliqab, K., et al. (2024). Performance optimization of energy-efficient solar absorbers for thermal energy harvesting in modern industrial environments using a solar deep learning model. Heliyon, 10(4). https://doi.org/10.1016/j.heliyon.2024.e26371

[51] Safae, M., Bekkay, H., Mellit, A., Aneli, S., et al. (2024). Integrated machine learning models for predictive analysis of thermal and electrical power generation of a photo-thermal system at Catania, Italy. Case Studies in Thermal Engineering, 61: 105018. https://doi.org/10.1016/j.csite.2024.105018

[52] Oladapo, B.I., Olawumi, M.A., Omigbodun, F.T. (2024). Machine learning for optimising renewable energy and grid efficiency. Atmosphere, 15(10): 1250. https://doi.org/10.3390/atmos15101250

[53] Nur-E-Alam, M., Mostofa, K.Z., Yap, B.K., Basher, M.K., et al. (2024). Machine learning-enhanced all-photovoltaic blended systems for energy-efficient sustainable buildings. Sustainable Energy Technologies and Assessments, 62: 103636. https://doi.org/10.1016/j.seta.2024.103636

[54] Sharma, R., Balaji, S. (2018). A framework for optimizing the process of energy harvesting from ambient RF sources. International Journal of Electrical and Computer Engineering, 8(1): 450. https://doi.org/10.11591/ijece.v8i1.pp450-457