Help Required Uploading Growatt Inverter To PVOutput

I’ve recently had a Growatt 1500-S inverter installed and would like to upload the data to PVOutput. The inverter is “on-line” via an Ethernet dongle (ShineLAN) and is uploading 5 minute data to the Growatt cloud monitoring service Shine Server (https://server.growatt.com/).

I see that there is a PVOutput integration service for Growatt inverters and have read some forum threads about getting the service running on a Raspberry Pi which is what I’d like to do. The bit I’m missing is how to interface the inverter or Growatt cloud service to the PVOutput integration service.

Is there anyone here who could point me in the right direction?

Thanks – Bob.

1 Like

Hi ,

I have a Canadian Solar inverter and it is a Growatt variant (they both speak same protocol). Mine is interfaced to the RPi through the RS232 port on the inverter and a RS232/USB converter cable.

However, in your case, the RS232 seems to be used by the ethernet dongle that sends data to Growatt cloud. Am I right?

BRs,
JrBenito

Hi and thanks for your reply.

Yes the RS232 is currently used by the Ethernet dongle but to be honest I’m not too bothered about sending the data to the Growatt cloud, I’d much rather that is was sent to PVOutput.

So how does it work, have you got the PVOutput Integration Service running on the Pi?

Thanks - Bob.

Hi,

I don’t know Growatt cloud but if they have some kind of API to export data it would be possible to write a service that get data there and send it to PVOuput.

Regarding my setup, I can’t take credit, I took the idea from here and modified the script a little bit for my needs but it works as it is there. One think I really dislike in the original script is that it reports total generation on every iteration. This sometimes (speacially early in the morning or late in the afternoon) causes the average power to be zero in one interation and 1200W on another iteration (and keep swinging until sun give more power - midday - or dark makes inverter turn off). It happens because Growatt (or at least my version) report generation in increments of 100watts and, early in the morning, with a power input of say 300 watts or less, in 5 minutes it will not produce 100W, hence, for pvoutput thinks zero power was generated and 0 avg power. After some chunks of 5 minutes, the power generated in a day will raise 100W and pvoutput would calculate 100w delta over the last chunk of 5 minutes resulting in average power spike of 1200W (0,1KWh / (5/60 minutes) = 1,2KWh). I solved this by make python a long running script (instead of oneshot like it is the site) and memorizing latest energy total for the day, if it has no change, report only power and not total energy to PVOutput.

Another thing you might face is python script fail to communicate with inverter on the first attempt, if you retry (once or twice) it does. I could not figure out if this is due low quality of my USB/RS232 cable (really cheap one) or due my RaspberryPI terrible USB performance (PI model B is known by its inability to supply good voltage to USB devices) or due to python library or a fault of the inverter itself. I took the quick n dirty approach by intercepting exception and retry until it works or threshold of attempts be reached… I still don’t sleep well not knowing what causes the bug but it works.

All that said, this Canadian inverter (growatt clone???) is installed at my mother’s place, she lives almos 600Km from here. I went to visit her in a weekend and put everything together as quick as possible so I can come back and still monitor her production. To assemble the Pi, wire it to inverter and network, and test python script took me no more than 4 hours. One or two changes to meet her needs and voi la. The thing is running for 1 month without my mom or me having to put hands on it.

I have some ideas to try out:

  1. switch the USB cable with a MAX232 board (a chip that converts TTL 3v3 signals into RS232 signals) and wire it direct to RPi GPIOs (Pi has serial TTL). This way I get ridge of cheap cable and RPi crap USB in one single shot. But this needs me to solder wires in place, hence this will happen someday during vacations at mom’s home. Until there, cheap USB will do the trick

  2. here at my place I have an ABB inverter (former Aurora PowerOne). Today I interface with its RS485 using a small Moteino (arduino variant with a 433MHz radio attached). It reads inverer every one minute and sends results over RF to my central raspberry far away inside home; also, do same with my energy meter at home entrance. Both arduinos are runnning over a year without one single issue. However those 433MHz radios need a gateway attached to the Pi inside home. My idea, almost complete by now, is to user a ESP01 or ESP12 instead of the Moteinos. This way I have wifi conectivity direct and enough computational power to send data directly from ESP to the PvOutput.
    If this works well here, I will do the same at my mom’s inverter because the only difference between her Inverter and my smart energy meter is the physical interface (inverter is RS232 and smartmeter is RS485) but protocol is Modbus for both. Once correct implmented ESP code, it does not matter the serial converter I would use underneath.
    Don’t get me wrongly, RPi does a wonderful job there at my mom’s but the environment is not the best one to keep the RPi and waste that much power just to read the inverter really bugs me.

  3. I will share my version of the python script as soon as I can get back to my mom’s place because later changes I did directly in the RPi and forget to transfer back to my laptop. Also, as you can see here, my modifications about power average worked on test stage and I, sleepy, forgot to merge it back on RPi production version. (also I noticed the time is shifted by 3 hours, am I sending local time instead of UTC or vice versa? Need to check there, I can’t remeber ahahaha)

If you need any other information or face an issue I can help, please let me know.

BRs,
Benito.

Wow, thanks for that, I appreciate the time you spent putting it together.

I had seen the Python script site you linked to but was a bit put off by a number of people raising what seemed to be apparently unresolved problems in the comments section. I’m have another look though, I do have some (somewhat rusty) coding experience so I’ll take a look at the code and try and understand what it’s doing (I’m the sort of person who likes to try and understand how things work before I implement them) :slight_smile:.

I’d appreciate a copy of your own code as I think that I’ll run in to the same issue as you - my inverter only seems to report in 0.1kW increments the same as yours.

Thanks again for your help - Bob.

As soon as I get my hands on that RPi again I will put code in my Github repository and paste it here. This might happen until end of may since there is a holiday I am planning to visit mom.

Until there, if you need anything drop me a message. I will be glad to help.

That’s great, thanks.

Bob.

If you want to access the RPi remotely check out this link: https://www.raspberrypi.org/documentation/remote-access/ssh/
Then you won’t have to wait till you have vacation time.:slight_smile:

Cheers!

Hi Iwsmiser,

Thanks for your suggestion. I am aware of this setup and in fact the RPi is configured headless SSH since day one. The problem is the ISP that serves my mom home uses CGNAT and I didn´t figure this out when I was there, I put everything in place and also setup a VPN connection so I could remote get inside network but I did not account for the CGNAT and just thought about when I already was far away. Yes, there are lot of ways to circumvent CGNAT (mainly by making Pi initiate the VPN connection instead of me from here) but I did not account for this in advance so I will have to wait.

BRs

Hi again jrbenito, just wondering if you managed to get a copy of your script?

Thanks - Bob.

Hi Bob,

Sorry for being in silence for so much time. Life got in the way. I am heading to my mother’s home this week and finally will get my hands on this again. Give me until next week and I will upload it to you.
Once again sorry for delay.

BR
Benito

No problem, thanks.

Bob.

Hi Bob,

I´ve been in my mom´s home and done some work to the script. It ended up in a spaghetti code so I decided to rewrite it organizing in a way I can, in future, break it into modules. It is not perfect but still works and little better now. There are bugs and corner cases I did not account - sure! But now I have VPN connection to the RPi and deal with issues will no longer take months.

Timezone issue ended up being docker “issue”. I did not realize that docker image has default UTC timezone so I made python code timezone aware and added proper configuration to the pvoutput.txt.

The code now saves energy reported between two reports (as I described early) what decreased occurrences of “0W average followed by 1200W or 2400W average”. However, sometimes it still occurs, I will debug overtime to understand why. Anyway, I still have some tests to do since this version of script was not running (my mistake) and entered production today.

Also, I added some code to sleep over night not trying to query inverter between 21:00 and 5:00 (I chose these hours because on daylight saving period, on winter it will waste some hours polling inverter). This is cosmetic but helps to save CPU cycles on the PI while inverter is turned off. One idea is to get sunrise and sunset times from Openweathermap instead of fixed hours like I did. Warning: this was not extensively tested simple to remove.

“Well, shut up and show me the code!” You might be thinking now.

Here you have it.. Hope it serves as inspiration. Please, post any comments here but open issues on github if you find bugs (I know they are there).

BR,
Benito

1 Like

Thank you very much. I’m away from home at the moment but will have a good look at this soon. It may take me a while to understand and get it up and running but I’ll report back and let you know how i get on.

Bob.

Fantastic. If you need any help drop me a message.

One thing I did not mention, although I use docker (for portability), script itself is not docker dependent so don´t worry about docker stuff mentioned in readme if you are not interested in it.

One quick question, I need to get one of these, is that correct? https://smile.amazon.co.uk/UGREEN-20210-Converter-Connecting-Controller-grey/dp/B00QUZY4UG/ref=sr_1_1?ie=UTF8&qid=1533134028&sr=8-1&keywords=RS232%2FUSB+converter+cable

Also does it matter which USB port I use on the Pi?

Bob.

Yes, you need a USB to RS232 converter like that one (expensive!!! You may find cheaper yet good options). The USB port does not matter, probably your Pi will recognize it on /dev/ttyUSB0 and script has it hardcoded, change if necessary. (to find out what device was associated with cable, after insert it, run dmesg command on Pi, it will show you the new device information - 99% chance it will be ttyUSB0)

Sidenote: other option for USB/RS232 is a TTL/RS232 converter direct attached to PI serial (pin header on PI), the device would be /dev/ttyAM0 (if I remember). This option is, for sure, less practical requiring wiring and connectors but could be a good option for people with USB power issues or using USB for other things.

I’ve got this working (system name Sunny Idle 1.34) so in case anyone else is looking to set it up from scratch I’ve documented the steps I took below:

  1. On my Pi I created the folder canadianSolar-pvoutput-master under /home/pi/
  2. Downloaded canadianSolar-pvoutput-master.zip from GitHub, unzipped and copied contents to /home/pi/canadianSolar-pvoutput-master
  3. From canadianSolar-pvoutput-master folder ran pip install -r requirements.txt
  4. Renamed pvoutput.txt.rename to pvoutput.txt
  5. Edited pvoutput.txt with System Id, API Key, OWM variables and TimeZone=Europe/London
  6. Connected Pi to inverter with USB to RS232 interface lead and rebooted Pi.
  7. $ chmod +x pvoutput.sh
  8. $ ./pvoutput.sh

Data then started being uploaded to my system :slight_smile: I added two extended data variables to my PVOutput system settings - AC Volts and Inverter Temperature (I didn’t include ‘v10’: inv.wh_total).

I’d been doing all this from a ssh session on my laptop and I wanted to get the script to start automatically when the Pi restarts so I created a cron job for user pi with the entry “@reboot /home/pi/canadianSolar-pvoutput-master/pvoutput.sh >> /home/pi/canadianSolar-pvoutput-master/canadianSolar.log 2>&1”. To get this to work I also had to modify pvoutput.sh as follows:

#!/bin/bash
cd /home/pi/canadianSolar-pvoutput-master/ # Needs to be run from the directory where code is #
while true; do
python /home/pi/canadianSolar-pvoutput-master/canadian_reads.py
echo “python script erro, sleeping few seconds and call it again”
sleep 60s
done

So all working at the moment but will monitor over the next few days.

2 Likes

Hi Bob,

Glad to see you mastered it. Congratulations.

Hi All,

I would like to register that there is a way to intercept traffic from Growatt Wifi adapter and send it o pvoutput. I did not tested it myself since I don´t have Growatt Wifi dongle but worth to mention for those who have to keep both, growatt and pvouput, working together.

Here: https://www.photovoltaikforum.com/download/file.php?id=42091

BRs