Instructions for monitoring your solar system

  1. Get a Linux box. I run Ubuntu Server on a crappy Dell box in my basement.
  2. Get mysql running.
  3. Add a "solar" user to mysql, create a "solar" database, and give the "solar" user permissions to do ALL on the "solar" database.
    mysql> create user 'solar' indentified by '<password>';
    mysql> create database solar;
    mysql> grant all on solar.* to 'solar';
    
  4. Plug a serial cable (straight through, not a crossover) from your computer into the Xantrex inverter.
    DON'T ELECTROCUTE YOURSELF! Without proper precautions, almost every wire inside the inverter could kill you.
    I have 3 inverters, so I spliced the three serial cables I used into one CAT-5 cable (sharing the ground pin) and ran the CAT-5 from the inverters through some conduit into the crawlspace under my house, then to the basement, where I broke it back into 3 separate serial cables.
  5. Get a few packages that my programs require: python-serial, python-mysqldb, and python-gnuplot.
    bash> sudo apt-get install python-serial
    bash> sudo apt-get install python-mysqldb
    bash> sudo apt-get install python-gnuplot
    
    You might need to enable universe and/or multiverse to get these.
  6. Grab my getsolardata.py and run it as a cronjob. In other words, add something like this in your crontab:
    # get data from solar array every 5 minutes
    */5 * * * * /home/keith/solar/getsolardata.py localhost:solar:<password>:solar /dev/ttyS0 /dev/ttyUSB0 /dev/ttyUSB1 >> /home/keith/solar/getsolardata.log 2>&1
    
    getsolardata.py takes a database specification (host:user:password:database), then a list of serial ports which are connected to Xantrex inverters. I have a 3 inverter system, with one built-in serial port (/dev/ttyS0) and two USB-serial adapters (/dev/ttyUSB0 and /dev/ttyUSB1). Don't worry about the order, getsolardata.py identifies inverters by their internal serial number and not by which port they are connected to.
  7. Grab my plotsolar.py and run it. I run it once an hour as a cronjob.
    # plot the data every hour
    1 * * * * /home/keith/solar/plotsolar.py localhost:solar:<password>:solar /home/keith/solar >> /home/keith/solar/plotsolar.log 2>&1
    
    It will read data from the given database specification and produce some *.png graphs into the directory identified by the second argument. Do with them what you will. I copy them to my website, also with a cronjob:
    # copy generated graphs to keithandkatie.com
    2 * * * * scp /home/keith/solar/*.png kkcom@keithandkatie.com:keithandkatie.com/solar/ >> /home/keith/solar/plotsolar.log 2>&1