Monday, March 5, 2018

System File 1:Data saver PHP script

 
   I'm publishing the files I've created to run and monitor, my system. There will be no explanations. I

The file to load and save data from the MPPT controller:

CODE
<?php
/*   epoutX-2.php   */
#date_default_timezone_set('EST');
#exec ('/bin/bash /var/www/html/epoutX-unlock_files.sh');

#$x=0;
require_once 'PhpEpsolarTracer.php';
$tracer = new PhpEpsolarTracer('/dev/ttyXRUSB0');
error_reporting(0);


$y = 1;
$x = 3;
#######################################
# exec ('/bin/bash /var/www/html/chd.sh');
#######################################

while($x = 3):
#######################################
exec ('/bin/bash /var/www/html/example_web.sh');
#######################################








#while($x=3):
$myfile = fopen('/var/www/html/data_'.date('m-d-Y').'.txt', "a") or die("Unable to open file!");
#If  ($y = 1){
# 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,Si,Sm\n");
# $y = 0;
#  }


$nano = time_nanosleep(30, 0);
  if ($tracer->getRealtimeData()) {
    $i=0;
#--------------------------------------->
    $pythonnoaaephem = `/usr/bin/env python3.6 /var/www/html/resources/NOAA.py`;

#____________________________________


    $date=date("Y-m-d H:i:s");
    $seconds = strtotime($date);
    $seconds /= 30;
    $seconds = round($seconds);
    $seconds *= 30;
    $date2 = date("h:i:s", $seconds);
    $date = date("h:i:s A", $seconds);
    $today = date("Y-m-d"); # Y-m-d
    $now = $date;
#______________________________________
    fwrite($myfile, $date2);
    fwrite($myfile, ",");
    fwrite($myfile, $now);
    fwrite($myfile, ",");
    fwrite($myfile, $today.",");
#---------------------------------------->
    while ($i<=5):
      $dat[$i] = $tracer->realtimeData[$i].",";
       fwrite($myfile, $dat[$i]);
       $i++;
    endwhile;
  $i=12;
$dat[$i] = $tracer->realtimeData[$i].",";
    fwrite($myfile, $dat[$i]);

    }
#--------------------------------------------------------->
    fwrite($myfile,$pythonnoaaephem);
#--------------------------------------------------------->





endwhile;
    fclose($myfile);
?>
END CODE

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home