## 4 The Software Implementation of the Dual-Axis-Based Solar Tracking System
Therefore, as an energy preservation method, the tracker will move the solar panel to the standard position (90 degrees to the south location, 45 degrees elevation angle)  
Figure 4: Workflow diagram custom functions used for automating the solar tracking system, comprising the (**a**) Homing Position Function, (**b**) Stepper Testing Function, (**c**) Wind Protection Function, (**d**) Solar Tracking Function, (**e**) Flat Position Function, and (**f**) Data Transfer Function. and will collect solar energy as a regular fixed-tilted PV system. However, if after a 5 min delay, the SR level improves, the software program will trigger the automated PV panel harvesting mode. Another important scenario to take into consideration is found in block (e), where we test if the SR goes below the value \(\text{SR}_{\text{low}}=5000\) lux, meaning that sundown will occur very soon, and certain protection measures must be applied before interrupting the entire system. While this block anticipates sundown, it can only move the solar panel to the flat position via software code to make sure that heavy wind will not damage the solar tracker overnight. Finally, block (f) describes the SIM800L V2 GPRS data transmission that can be executed in five steps according to Figure 4. The software program will commence with the GPRS data transmission protocol by connecting the chip to the GSM provider which is associated with the acquired SIM card. Once the SIM800L V2 module is tethered to the GSM network, the chip will retrieve the local wireless network IP and then will further connect to the ThingSpeak server where all the sensor data will be collected. The last step involves disconnecting from the local IP address and stopping the GPRS data transmission protocol. All five previously described custom function blocks are now strategically integrated into the main automation flowchart presented in Figure 5. The entire solar tracking automation process is divided into several stages, with the custom-implemented functions being called multiple times during code execution to handle real-time environmental changes. Figure 5: Main flowchart describing the entire solar tracking automation process. In the preparation stage, encompassing steps 1-4, all digital pins of the Arduino Mega2560 are assigned to the physical pins of the sensor modules. If the PV panel is in a random position, the horizontal and vertical stepper homing function block (a) will be triggered to bring both axes to their reference point. The software then verifies the functionality of all sensor modules and resets the steppers' internal counters to the origin point (0,0). These initial steps are executed only once when the solar tracker software is launched. The subsequent 32 steps are periodically executed in the main loop function. Once the preparation stage is complete, all sensor values are calibrated to an initial value, ready to read environmental data. Periodically, a complete check-up (steps 7-10) ensures efficient performance, invoking the scenarios for blocks (b), (c), (d), and (e). This check-up is followed by steps 11-26, which form the main body of the loop function. In this code section, the horizontal light intensity (HLI) is evaluated to see if it falls within an established tolerance range. If HLI exceeds the tolerance, the algorithm splits into two branches. Steps 12-14 adjust the horizontal motor if the west-side light-dependent resistor (LDRW) receives less energy than the east-side LDR (LDRE). Conversely, steps 15-17 adjust the motor if LDRW displays more voltage than LDRE. If the horizontal positioning is correct, the code checks the vertical light intensity (VLI) in steps 18-25, balancing discrepancies between the north-side LDR (LDRN) and the south-side LDR (LDRS). After achieving correct positioning, there is a 5 s delay, then the GPRS data transfer block (f) is called four times with 10 min intervals to send sensor data to the ThingSpeak server (steps 28-34).