Help Required Uploading Growatt Inverter To PVOutput

Hi guys,

What a detailed and informative thread this is!! Had a bit of trouble gathering the information but I just wanted to check in to see if I’m going in the right direction here.

I have a Growatt MIN 6000TL-X that has a USB WiFi dongle attached. I’m not sure if this is a newer version than what’s being discussed here, or if there is a new way of obtaining the API key so that I can link it straight to PVOutput?

If this is not the case, then will I have to get a RPi and the cable? If anyone can direct me to the post or link which has all the steps, that would be great! :slight_smile:

Hi and welcome. I’m not sure about you being able to do this without a Raspberry Pi, that’s the route I went down and it’s been working reliably for several years.

These are the instructions I followed when I originally got it working although it’s quite a while ago now. You may have to tweak things, I’m running using Python 2.7 but understand that the code has been updated for Python 3.9. Good luck.

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. 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 sleep 180 && /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

Thanks for that bobboulby, looks like I’ll have to start by sourcing a RPi and USB/RS232 cable!

1 Like

@highon2str I do not own an inverter like yours but as I see here maybe your MIN inverter needs this version of the script.

@jrbenito Hi, nice to have you back.
If you feel like coding there are some improvements that I could suggest.

  1. Send end of the day output at the end of each day. This is needed if there are long periods of internet outage in order to have the correct daily production. Otherwise c1=1 can be used but it breaks the pvoutput graphs especially in the mobile app. As you have coded the API this should not be too hard
  2. Use sunrise / sunset to start and stop the script. There is a library available that estimates sunrise / sunset based on coordinates which are already available in the pvoutput.txt
    So ping me if you want me to open these issues at github.

Hi @lampra,

Good suggestions, the item 2 was already on my list, the item 1 I noticed last week when we had an internet outage.

Lets work on that.

Hi @highon2str,

Do you mind provide a picture of this setup?
Also, besides USB port on the inverter, does it have RS232 or RS485 too?

Thanks,

I would love to see the Modbus spec he used. First I noticed he is reading the first 100 registers in a single read. The documentation we have explicit says inverter will not answer to that, for sure newer models have upgraded spec. He also removed the upper nibble calculation from power, not big deal since most small to medium installs will never reach such a high power. He sure have two arrays because he sums the voltage of vpv1 and vpv2, I did not care for a second array. He takes the inverter temperature from register 97, our documentation says this register is Grid Fault Record 2 (daily | hour)

So, clearly, the modbus spec went through revision for those newer models.

No I don’t believe it does, here is a manual for it: http://www.ginverter.com/upload/file/contents/2019/08/5d5b6afb90a56.pdf

And here is a picture of mine:

Not sure how to connect the inverter to the RPi w/o an interface port? :thinking:

According to the manual there is a com port (L page7 of the manual).
In your case this port seems to be occupied with the blue cable. Is this cable connected anywere?

It goes to my switchboard to a “SDM230-Modbus” meter.

@highon2str
Then you are probably able to connect a cable attached to an RS485 to usb (costs about 3 euro plus the cost of the cable like the blue one) to the modbus meter (where the blue cable is connected) and get both the data from the inverter and the meter using a pc or a raspi or even a cheap orangepi zero (with armbian). Is this bidirectional meter used for the inverter only or also for the grid energy?
You will need to adjust the modbus parameters of the meter if the installer has not done it already (i.e. Modbus ID: 2 if the inverter has id:1, Baud rate 9600, Parity: NONE, Stop bits:1). All these parameters needs to be the same on both the inverter and the meter except the id.

Edit: you can even use your router to get the data if it has usb, it is using Openwrt and you are able to use ssh
Edit2: Ask your installer for the current use of the meter before changing any parameters. Though as the connection is done by the installer the parameters are probably adjusted already.

Agreed

Same model a friend’s parent had installed recently.

As per manual, your blue cable might be connect to pins 2, 7 and 8 of the eastron SDM230. And your monitor software (aka RPi) shall be connected to pins 2, 3 and 4 (page 34 item 7.4). If those pins are going to some other place, let us know also.

You will need a rs485 to USB adapter as @lampra mentioned. I had success using those:

https://bit.ly/2WquKOo -> very simple, look and feel very cheap but worked on my ABB Uno for debug purposes and also on a Eastron SMD630a. Does not require ground (pin 2 on the diagram page 34 of your manual).

https://bit.ly/3nH10Jf -> while bare open it has (it least it say it has) TVS protection that is a bonus for areas with high lighting activity (where I lived in Brazil). You need a USB cable (USBA -> usbB connector, common on printers). This is the one I most used.

https://bit.ly/3mrdq6f -> just for the records, those also works really well. Although I used them connected to arduino/esp8266 boards, they can theoretically be connected to serial port of an RPi. But is too much external components to take care if you have the USB ports on an RPi. Go for the USB.

BRs

Hello, I decided using a Raspberry Pi with Raspbian.
1 - I run the following commands:
1.1 - #sudo apt update
1.2 - #sudo apt upgrade
1.3 - #sudo apt install bc jq
2 - I installed the following API Client: GitHub - Sjord/growatt_api_client: This Python script logs in to server.growatt.com and retrieves data on solar panels. following the steps informed on the page.
3 - In the API directory itself, I created the pvoutput.sh script with the following content:
#!/bin/bash

#Log on Growatt Server using your login and password (change on next line)
PROGRAMA=$(python -m growatt 'LOGIN' 'PASSWORD')
echo $PROGRAMA > saida.txt
sed "s/u'/'/g" saida.txt > saida1.txt
sed "s/\[//g" saida1.txt > saida2.txt
sed "s/\]//g" saida2.txt > saida3.txt
sed "s/'/\"/g" saida3.txt > saida4.txt
sed "s/True/\"true\"/g" saida4.txt > saida5.txt
sed "s/False/\"false\"/g" saida5.txt > saida6.txt
cat saida6.txt | jq --compact-output '.data.currentPower' > saida7.txt
sed -i "2d" saida7.txt 
sed "s/\"//g" saida7.txt > saida8.txt
sed "s/ /|/g" saida8.txt > saida9.txt
GERANDO=$(cat saida9.txt)
IFS='|'
read -a SPLITADO <<< "$GERANDO"
if [ "${SPLITADO[1]}" = "kW" ];
then
        POTENCIA=`echo "${SPLITADO[0]}*1000" | bc`
else
        POTENCIA="${SPLITADO[0]}"
fi
IFS='.'
read -a POTENCIAARRAY <<< "$POTENCIA"
POTENCIAOK="${POTENCIAARRAY[0]}"
DATA=$(date '+%Y%m%d')
HORA=$(date '+%H:%M')
#Send data to PVOutuPut using YOURAPI and SYSTEMID (change on next line)
curl -d "d=$DATA" -d "t=$HORA" -d "v2=$POTENCIAOK" -H "X-Pvoutput-Apikey: YOURAPI" -H "X-Pvoutput-SystemId: SYSTEMID" https://pvoutput.org/service/r2/addstatus.jsp

4 - I changed the crontab to run every 5 minutes:
4.1 - #crontab -e
4.2 - at the end of the file add the following line:
*/5 * * * * cd /home/pi/growatt_api_client/ && bash pvoutput.sh >/dev/null 2>&1

Okay, for me it’s working smoothly:
https://pvoutput.org/intraday.jsp?id=73728&sid=73092&dt=20210302

saida.txt → Portuguese speaker spotted

1 Like

Hello there!

I’ve been reading many times this thread the last couple of weeks, so much info! I have a Growatt SPF5000ES that uses another version of registers (v0.11 / 2017-8-09), so I’m trying to adapt codes to my particular case. This inverter has an USB type B to which I connected a RaspberryPi3, tried to read some registers without success (because I didn’t knew aboute the different versions). Today I was modifying the code of ZeroErrors and was able to inject some data on InfluxDB and draw it on Grafana.

My endgoal is to replace the RPi with an ESP8266 and integrate this monitoring on Home Assistant.

1 Like

Hi,

I do like a lot the code from ZeroErrors! Very organized and easy to to read. I do ingest inverter modebus using Telegraf and sending it to InfluxDB. Same end result just leveraging data collection offered by Telegraf (that I used to monitor the RPi anyway). Now I use a simple python script to query Influx and send to PVoutput. My motivation to that was the addition of a power meter to the house, so I would need to make the python code read two different RS485 buses (no way to put both in the same bus here) or two different script and a way to serve data to pvoutput together… so telegraf queries both RS485 buses and python queries influxdb to send pvoutput.

Regarding ESP8266, I thought a lot on pursuing this path, on my old ABB I had a radio based reading using Arduino (not wifi but same idea). Due to USB you might want to go something more powerful like ESP32 of some sort, deal with USB is not as easy as RS232. However, if you have no problems with RPi3 there, let it be. Too much effort just to save about 4Wh and not much money (in hardware).

I am glad this thread come so far and many people bringing a lot if cool ideas. Learning a lot together.

@lampra I did no forgot to make the modifications you asked :frowning:

pi@SolarLog:~/canadian-pvoutput $ docker build -t canadian-pvoutput .
Sending build context to Docker daemon 1.778MB
Step 1/4 : FROM python:3.8-alpine
—> 1a053abcf5a4
Step 2/4 : LABEL maintainer=“Josenivaldo Benito Jr. SvenDowideit@home.org.au
—> Using cache
—> 5878975cf54f
Step 3/4 : COPY requirements.txt .
—> Using cache
—> 386f90d163e5
Step 4/4 : RUN pip install --no-cache-dir -r requirements.txt
—> Running in 82e53a5f298e
Fatal Python error: pyinit_main: can’t initialize time
Python runtime state: core initialized
PermissionError: [Errno 1] Operation not permitted
Current thread 0xb6fbf390 (most recent call first):
no Python frame
The command ‘/bin/sh -c pip install --no-cache-dir -r requirements.txt’ returned a non-zero code: 1
pi@SolarLog:~/canadian-pvoutput $

Hi Mate, I fell into this hole while trying to build the docker container, and have not been able to resolve, can you please give me a tip on what the issue could be?

Thanks in advance.

Hi @cressie ,

Are you using latest commit in the master branch? I just did:

Successfully built 2bbd206a1dc7
Successfully tagged canadian-pvoutput:latest

Another question: where are you trying to build it? Does your user have permission to run docker? Otherwise, try it with sudo.

If you trust me, I just build it and pushed to docker registry under jrbenito/canadian-pvoutput. I say “if you trust me” because you have no easy way to audit what one puts into his own images, so you have to trust the source.

Let me know if you are able to advance.

1 Like

docker push jrbenito/canadian-pvoutput
Using default tag: latest
The push refers to repository [docker.io/jrbenito/canadian-pvoutput]
76d4874023e0: Pushed
3ff3caaab9b3: Pushed
c138b27e867b: Mounted from library/python
11d19a761ef7: Mounted from library/python
01534b568332: Mounted from library/python
267a6a0302bf: Mounted from library/python
b2d5eeeaba3a: Mounted from jrbenito/influx2pvoutput
latest: digest: sha256:8abbc64307913db72977241caf99f3876bab1e462aa1afba9dc5f6608f37f33c size: 1786

push log if interesting to anyone

1 Like