Help Required Uploading Growatt Inverter To PVOutput

Hi

So I removed python3 as the two were confusing. This is running python2 and I have installed all the dependencies. Should I reinstall python3?

The cable I am using is this one: Sabrent USB to Serial Cable Adapter (SBT-USC1M) | SBT-USC1M

From what I can see on this site here, the USB cable is seen and is configured according to the instructions there: Monitoring a Growatt PV inverter using Raspberry Pi | Sisand . Minicom is setup and when I run ls -l /dev/ttyS I get the following:

crw-rw---- 1 root dialout 188, 0 Sep 28 17:03 /dev/ttyUSB0
pi@solarpi:~/canadianSolar-pvoutput-master $

When I undertake your instructions I get the following:

Not sure what you mean about changing an address, to my knowledge I have not changed anything. I have a growatt 1500 if that helps at all?

Thanks

Phill

For the moment stay with python 2.7.
The input output error indicatives no communication with the inverter. If the inverter is on and producing, check the following:

  1. In the inverter manual, check if RS232 is activated by default or if it needs activation
  2. On the inverter screen, check the modbus address (usually 1 by default). Check also the communication parameters baudrate=9600, stopbits=1, parity='N', bytesize=8
  3. Check that the serial connection on the inverter is proper (not loose) and correct (should connect and disconnect without too much strength).
  4. Check the cd of the cable, if it provides Linux driver you might need to install it
  5. Disconnect the usb and check the output of command (ls -l /dev/ttyU*) with sudo, is there any /dev/ttyUSB0 in the output? (paste the output here). Connect the usb and check again (what is the new ttyUSB that appeared in the output?) paste the output here.
  6. Increase the timeout
inv = ModbusClient(method='rtu', port='/dev/ttyUSB0', baudrate=9600, stopbits=1, parity='N', bytesize=8, timeout=3)

If nothing works, test with a different cable

Again super help. I will try and get this done today and will feedback the results. BTW I am in England so UTC time so while dark and grey as is usual here, there is some output and its early morning as I type.

Cheers

Phill

hi @bobboulby,

I am really sorry not answering you! My life changed upside down in the last year, I am now living in Canada!!! Because of that I was out for a very long time. My own system stopped worked days after a left Brazil and I was only able to remotely put it back together 3 days ago. (4836 KWh not logged to pvoutput later).

I am still catching up with this thread.

Hi all,

Thanks to @lampra the code is working with python 3 now. I am running it in python 3.9 inside a docker container on a RPi 1 B+ (old… very old and slow one).

Finally got my system (my mother’s system actually) reporting again to PVOutput.

Hope everyone is safe and healthy during this difficult time we are in.

BRs
Jose

Hi @jrbenito. Good to see you back :slight_smile:.

Bob.

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