pvsolar Nov 2012 Dick Middleton GPL-3 ------- Introduction ------------ A collection of scripts and programs for collecting reading from pv solar inverters and storing in a database. Sboy - reader program in C for SMA SunnyBoy 3800 solar pv inverter. Likely to work with other SMA inverters. Aread2 - reader program in perl for Power One Aurora inverter. Uses CPAN package Device::Inverter::Aurora. pvsolar - data collection management program. Schedules readings every 5 minutes and stores them to mysql data base. Performs updates at end of day to provide summary and statistics. Schedules FIT meter reading submissions. N.B. but doesn't, interact with third-party data collection web services. fernietickle - connects to pvsolar over network and provides status monitoring and some control. fitmeter.tmpl - email template file for FIT meter reading submissions update.tmpl - email template for daily reports to administrator. pvsolar.sql - mysql table schema. Other A collection of php and javascript programs for retrieving and displaying retrieved data. In the web subdir there is enough to get started. These files have been editied to remove cruft before uploading. They have not been tested in the de-cruft form; there my be typos. The generation of the html code is site specific. The code example I have given should work if placed in the body of a simple page. The head needs to include the javascript and stylesheets as required. Other - (WIP. not released yet) 15-Nov-2012 A result of this work can be seen at http://www.fouter.net/fernietickle.php Sboy (for reading SMA Sunny Boy inverter) ---- See README in sboy directory Aread2 (for reading Power-One Aurora inverter) ------ Takes current reading and exits. Intended to be called by management program every 5 minutes. The data returned looks like: READINGS: 114: 0.905: 2967.751: The fields are: 1: A constant "READINGS" which is to give some confidence that the right string is being parsed. 2: The power being developed at the time of the reading (integer watts). 3: The total energy generated (yield) so far today. (decimal kW.h) 4: The total energy generated in the lifetime of the inverter. The inverter's meter. (decimal kW.h). 5: A comment field (or fields) possibly to contain the name and version of the program. pvsolar ------- pvsolar is a perl script. It depeds on a number of contributed packages. You'll need to make sure the following are available: Getopt::Std, JSON, DBI, Proc::PID::File, Proc::Daemon, Log::Log4perl, POE, Date::Format, Time::Local, Config::INI::Reader, Text::Template, DateTime::Astro::Sunrise, Term::Readkey If they're not part of your distro (they are all in Debian) they can be obtained from CPAN. DateTime::Astro::Sunrise needs to be patched - see below. Configuration is in /etc/pvsolar/pvsolar.conf Copy email templates to /etc/pvsolar too. Create mysql data base with appropriate privileges and use schema to create tables. Configure access to mysql in pvsolar.conf under section [dbase]. Configure locn with the latitude and longitude of the solar site. This is used to compute sunrise and sunset times. locn can be either expressed in decimal degrees or as degrees and decimal minutes. Set path of reader program e.g /usr/local/sbin/sboy Set email options and remember to edit tmpl files with appropriate email addresses and text. If email not required then comment out the whole [email] section. Set a passcode for use with fernietickle. This is not really a security feature it is merely to protect against issuing damaging commands unintentionally. Pvsolar must be run as superuser (root). It won't start otherwise. Tail /var/log/pvsolar.log to check for errors. Using logrotate to manage the logfile is recommended especially if a log level setting more verbose than 'WARN' is used. 2013-07-05 Added check for unlikely sequence of zero readings and send alarm email alarm email template added to config GOTCHAS ------- Locale settings are enirely disregarded. There are other compromises in the design of this program which need to be addressed to make it generally useful. fernietickle ------------ Needs no configuration except to set the host of the running pvsolar. fernietickle will connect to pvsolar and allows reading of status and the last few readings. You can also change log level, tail the log and terminate pvsolar. Some commands e.g. terminate, need to have passcode as argument: Command: terminate yesireallymeanit help will provide info on main commands: ? | help - this message ! | status - show status info last - show last 12 results lt | logtail - display lines from log file st | stoptail - stop displaying log file level <p> - change log level <p> = inc | + | dec | - level - show log level all | always | trace | debug | info | warn | error | fatal - set log level fit <reading> - enter fit meter reading terminate <pc> - stop server and exit <pc> is pass code exit | quit - exit program DateTime-Astro-Sunrise ====================== This module has a problem relating to computing time offsets which causes it to break if the sunrise and sunset are not in the same day UTC. Australia beware. A patch file with a fix (that I think works) is in sunrise.patch. It has to be applied to Sunrise.pm which is part of a perl module. On a Debian system it's in /usr/share/perl5/DateTime/Astro. cd /usr/share/perl5/DateTime/Astro cat sunrise.patch | patch -p0 Sunrise.pm ---//---