Using the TonidoPlug² as a Datalogger for Photovoltaic Panels

I managed to setup my TonidoPlug² (TP2) as a data-logger that automatically uploads live statistics of my solar panels to pvoutput.org. This post details the steps I followed to run sma-bluetooth on the TP2 .
After ssh'ing to your TP2, prepare a build environment on the plug pc:
  • follow the steps in: http://www.tonido.com/communitywiki/doku.php?id=advanceduses:setupbuildenvironment
  • step 4 & 5 are slightly outdated:
    • (4a) I had to install the deb-multimedia-keyring package first:
      apt-get install deb-multimedia-keyring 
    • (4b) the url for wget is diffent:
      wget http://www.debian-multimedia.org/pool/main/d/debian-multimedia-keyring/debian-multimedia-keyring_2010.12.26-3_all.deb 
    • (5) dpkg -i debian-multimedia-keyring_2010.12.26-3_all.deb
After that you can follow the steps I detailed in my previous post: http://michael-peeters.blogspot.com/2012/04/sb-inverter-bluetooth-connection-on.html. Summarized:
  • compile sma-bluetooth:
    wget http://sma-bluetooth.googlecode.com/files/sma-bluetooth-0.17b.tar.gz 
    tar -xzf sma-bluetooth-0.17b.tar.gz 
    cd sma-bluetooth-0.17 
    sudo apt-get install mysql-server mysql-client  libmysqlclient-dev 
      # (don't forget to enter a non-blank password for mysql!) 
     gcc -c smatool.c 
     gcc smatool.o -L/usr/lib -lmysqlclient -lbluetooth -lcurl -lm -o smatool 
  • edit the configuration. This can be tricky! Check the details first.
    # nano ./smatool.conf 
  • install the mysql tables:
    ./smatool --INSTALL 
  • run / debug errors:
    ./smatool -d -v 
Once smatool runs OK from the command-line, you can consider scheduling the run in cron.
  • create a smatool.cron file in your home-directory. Contents:
    # /etc/cron.d/smatool: crontab entries for smatool (monitoring of Sunnyboy Grid Interactive Inverter) 
    # The following line runs the smatool every 15 minutes between 0500 and 2300 and logs all output to the /var/log/smatool.log file. 
    */15 5-23 * * *   root cd /root/sma-bluetooth-0.17; ./smatool 2>&1 | logger -t smatool -p local5.info 
  • activate the new cron entry:
    cp ./smatool.cron /etc/cron.d/smatool 
    chmod 744 /etc/cron.d/smatool 
  • checkout /var/log/syslog for errors
  • each run is logged in /var/log/syslog
The result:

Possible improvements:
  • sma-bluetooth requires mysql which is a relatively heavy database for a plugpc. Sqlite would be a better choice. I experimented with the excellent fork http://rcphills-sma-bluetooth-dbabstraction.googlecode.com/ that supports sqlite, but the connection to pvoutput.org didn't work anymore.
  • the current setup does too much I/O preventing the SATA HD to sleep. Unfortunately booting from an external USB flash disk is not easy on TP², so I'll have to investigate other alternatives.
Post a Comment