Saturday, 4 March 2017

Using a raspberry PI to upload Sunny Boy PV data

I have a Sunny Boy PhotoVoltaic generator (solar panel inverter).
I have been wanting to upload the generation data, preferably using a Raspberry Pi Zero.

I found this excellent article. Now the Pi-W is out, which supports bluetooth and Wifi on-board, it makes getting the data a cinch.

There are a couple of updates to the article:
1. It expects to download the sma-bluetooth code from Google Code. This is now defunct. Instead I ran

git clone https://github.com/sma-bluetooth/sma-bluetooth.git

to get the code.

2. It doesn't mention libxml2; when running make on sma-bluetooth it errors because of a missing dependency. I installed it with

git clone git://git.gnome.org/libxml2-dev

and then I had to edit the makefile to add the include path (which is /usr/include/libxml2)

sudo nano Makefile

editing the second line below:
smatool.o: smatool.c sma_mysql.h
        gcc -I/usr/include/libxml2 -O2 -c smatool.c

3. The description around the config file is a little unclear.
You should leave the variable name intact, and add the data afterwards.
e.g.


test the config with ./sma_tool -d

3. There is an error in the code.
sma_mysql.c has the line
UNIQUE KEY 'DateTime'(`DateTime`,`Inverter`,`Serial`,`Description`) \

and the first DateTime is a single-quote.

This results in the error:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''DateTime'(`DateTime`,`Inverter`,`Serial`,`Description`)

The delimiter around DateTime should be an angled single-quote (called a backtick), rather than a straight single-quote. A backtick is used to delimt identifiers (tables and fields) whereas a single quote delimits strings e.g. 'Hello World'. The two can't be mixed.

The fix is to modify the line to:
UNIQUE KEY `DateTime`(`DateTime`,`Inverter`,`Serial`,`Description`)

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. I can send you my makefile if it helps?

      Delete
    2. Many thanks - I had a problem and sorted it hence deleting the comment. Makefile would be handy though thanks. Do you need an email address?

      Delete