Xantrex GT Unix Scripts Version: 2006.11.13
Author: Justin Shumaker
Email: justin at arl.army.mil
Website: http://solar.js.cx
===========================================

This package consists of a collection of PERL scripts I wrote one
evening to interface a Xantrex GT Inverter and publish statistics in 
both tabular and graph formats to the web.  In order to use these 
scripts you will need to have the following things installed:

* PERL
* PERL Device Serial Port package
* MySQL
* Apache with cgi-bin enabled (or other webserver).
* GNUPlot

Disclaimer: I do not claim responsibility if you misconfigure anything.
Make sure your inverter is plugged into the webserver using a DB9 serial 
cable or a DB9 to USB cable if you have the drivers for it.

P.S. A typical DB9 cable will not fit through one of the four side holes 
so I trimmed mine on a table saw using a cutting wheel not a saw blade.
I am not responsible if you try this and hurt yourself.


Now you must do the following:

1. Edit the "localvars.pm" file and set the variables listed to their
appropriate values based on your local configuration.  You must also
edit the xantrex_daily_logger.pl and xantrex_totals_logger.pl and change
the line below to match the location of localvars.pm
use lib '/usr/www/solar.js.cx/cgi-bin';

2. Login to the MySQL database using the MySQL client and type the 
following:

create database xantrex;
use xantrex;
create table daily_log(datetime datetime, output_watts smallint, 
input_watts smallint);
create table totals_log(date date, kwh float, kwh_cost float, time int);
create table visitors(count int);

3. Now change to root and edit the root crontab by typing "crontab -e".  
You need to insert the following two lines into the crontab:
00	21	*	*	*	/usr/www/solar.js.cx/cgi-bin/xantrex_totals_logger.pl
00,10,20,30,40,50	*	*	*	*	/usr/www/solar.js.cx/cgi-bin/xantrex_daily_logger.pl

replace "/usr/www/solar.js.cx/" with the location you installed to.

The above crontab lines will log wattage statistics every 10 minutes and 
it will also log totals information at 9:00 pm every day.

4. Permissions can be problematic.  You might need to change the 
permissions of your serial device under /dev to the web user.  You 
should also chown and chgrp the scripts to the web user.  Since the 
graphing scripts touch: cost_graph.dat cost_graph.gplot power_graph.dat 
and power_graph.gplot you might need to chown and chgrp these files to 
the web user as well.  Don't get frustrated, just run the scripts from 
the console if things aren't working and be sure to look over your 
webserver log files to provide clues as to what is going wrong.  After 
you are done testing and things work then you may want to purge your 
MySQL database and let it go.  You might also want to sync the time on 
your server using ntpd, man ntpd or ntpd.conf for more info.

5. Create a fancy website and add links to the cgi scripts and a link to 
http://solar.js.cx

6. Check "http://solar.js.cx" for updates and new features from time to 
time.
