Data gaps is a misnomer. What happens is the PHP script runs but the Triron charge controller does not output data sometimes. The script does run the python NOAA2 script and writes elevcalc and azicalc the the csv file.
I used Google AI to pinpoint the problem and come up with a solution. I gave the agent relevant data and a result was formed from analyzing the github software sources and my data. The agent explained what was happening and pinpointed the PHP library from github as the origin of the problem.
The AI wrote a simple software modification to prevent the script from writing blank lines to the csv files.
The code:
========================================================================
// --- Your existing code above ---
// VALIDATION: Ensure both power data points are present and valid
if (
isset($tracer->realtimeData[2]) && $tracer->realtimeData[2] !== '' && $tracer->realtimeData[2] !== false &&
isset($tracer->realtimeData[5]) && $tracer->realtimeData[5] !== '' && $tracer->realtimeData[5] !== false
) {
$i = 2;
$dat[$i] = $tracer->realtimeData[$i] . ",";
fwrite($myfile2, $dat[$i]);
$i = 5;
// Make sure to append your newline character (\n) here if this is the end of your row!
$dat[$i] = $tracer->realtimeData[$i] . ",\n";
fwrite($myfile2, $dat[$i]);
}
// If the data is missing, it falls through here and writes nothing.
} // <-- This is your existing closing curly brace for the parent 'if' statement