System File 2:PHP script to write CSV header
File to write the CSV file header once each day or turn on cycle:
CODE
<?php
/* epoutX-write-header.php */
error_reporting(0);
exec ('sudo hwclock > /var/www/html/_hwc_out.txt');
exec ('date > /var/www/html/_date_out.txt');
exec ('sudo hwclock -w');
#$file= 'data_'.date('m-d-Y').'.txt'
$myfile = fopen('/var/www/html/data_'.date('m-d-Y').'.txt', "a") or die("Unable to open file!");
#shell_exec ( string 'sudo chown pi $file' )
fwrite($myfile,"time,time12,date,PV array voltage(V),PV array current(A),PVpower,Battery voltage(V),Battery charging current(A),Battery charging power(W),BattSOC,elevcalc,azicalc,Si,Sm\n");
fclose($myfile);
exec ('/bin/bash /var/www/html/epoutX-unlock_files.sh');
#$myfile = fopen('/var/www/html/data_XXX'.date('m-d-Y').'.txt', "a") or die("Unable to open file!");
#fwrite($myfile,"time,time12,date,PV array voltage(V),PV array current(A),PVpower,Battery voltage(V),Battery charging current(A),Battery charging power(W),BattSOC,azimuth,elevation\n");
#fclose($myfile);
?>
END CODE
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home