Sunday 24 January 2016

Growatt inverter monitoring with Raspberry Pi

At home we have a small (2.5KW - 10*250w panels) PV system to try and offset our daytime electricity usage. This is connected to a 'Growatt' inverter that handily has both RS485 (wierd 2 pin plugs) and RS232 (9 pin D connector buried under a screwplate) outputs.

With the firmware on ours (installed Sept 2013) it supports modbus-rtu over serial 9600 8N1.

I had done some initial digging and experimentation (as announced on Whirlpool) but never really got sensible values out.When my guruplug (via a long USB to serial adaptor) finally died and I shelved the whole thing. With the completion of the structured wiring though I finally got round to reconnecting it and starting again.

Blue serial cable attached to structured wiring.
Small D9 Gender changer, + cisco console cable (all hail fleabay) gives a nice neat look on the outside, and in the garage I have another console cable plugged into the relevant patch outlet and a cheap usb-serial adaptor in a Raspberry Pi (which also has a GPS module connected, acting as a PPS NTP master)

Anyway, in the intervening time, someone had worked on my hacky scripts and wrapped the posting to PVoutput in an exec(curl) call -- first up I ripped that out and swapped for python requests.

I then went through the growatt modbus guide and made sure that it correctly calculated high and low byte values where these are split. The resulting script can be found on github,  and todays output can be seen on pvoutput. - a couple of charts are duplicated below.
Todays output v insolation prediction
As you can see, we had a couple of clouds going overhead today, so only generated 13KWh  vs 13.7 yesterday. Also the pvoutput fields are somewhat vague - 'Voltage' I've chosen to upload the array DC voltage rather than the grid AC volts (actually, I upload that and the grid frequency as extended data), and 'temperature' - I'd ideally like to have the panel temperatures, but upload the inverter temp so I can see if it's getting toasty. These can be seen on the 'all info' plot below

The observant of you will notice that the Etoday figure was slow to take off - this is because I didn't RTFM and discover that it's uploaded in watts, not kW...

Update 2016-02-08

If you pulled an early version of my code, please grab a new version - I realised the total lifetime generated (and any other 2*2word values) were off as I was doing thing[1]<<8+thing[2] and it should be thing[1]<<16+thing[2]. Ahem. 

The new version also just runs once in the background rather than being called from a cron entry every 5 mins, - it still publishes every 5 mins to pvoutput, but publishes all the messages (in json format) onto my message broker (MQTT) so I can draw a spiffy html5 canvas + websockets graph of whatever I fancy from 

solar/json {"Status": "Normal", "Etotal": 8705.3, "Tinverter": 46.1, "Pac1": 305.1, "ttotal": 32957749.5, "Vac1": 242.1, "PV1Curr": 1.1, "Etoday": 14.4, "Iac1": 1.3, "Pac": 305.1, "Ppv": 339.0, "Fac": 50.02, "PV1Watt": 339.0, "Vpv1": 303.8}

It also monitors the status, and if it changes to 'Fault' it'll look up the fault code and send an alert via pushover. 



Feeling Pumped!

Having just had a day without power, and then going round the site to check everything came back online correctly (including services such a...