Help Required Uploading Growatt Inverter To PVOutput

You probably have both python 2.7 and python 3 installed so this might be the source of your errors.
You can either try to use python 3 (I can’t help with it on raspberry pi), so you need to install ptz etc for python3 (what you have installed is for 2.7) or you could try to use the older stable version of the script.

To keep troubleshooting easy, download tag v0.7.2 of the script and run this version which is compatible with python 2.7 (but not with python3).
Test this version, If it works it’s ok you can keep this version running with python 2.7
If not open a terminal and go to the folder of canadian_reads.py and run it (i.e. python canadian_reads.py). Copy the output and paste it here for more troubleshooting!!

Hi

I think in the midst of trying anything to get this working this is what I have come up against. I have just managed in between reading your post and your latest reply to make the dependencies go away for python 3 by working out that’s what I was up against! If anything else I am learning, albeit slowly!

I think the next step is to try and remove python 3 go back to python 2 and use your version, then see how I get on.

As an aside, I managed to get past the issues with pytz by installing pip3 then worked out what was meant by dependencies, installed all the other bits and now I am getting this:

Error getting weather: 'OWM' object has no attribute 'weather_at_coords'

I am open to this being an issue with python 3 so this could go away when I try to remove python 3 but is there an example of how I should be putting my latitude and longitude into the script in case this is the reason it was failing, or could fail?

Thanks for your help, will let you know how I get on with the script you provided.

I am running it with python3 and I have no issue with OWM. If I remember well, you can disable it.
Here is an example how to put latitude and longitude into the pvoutput.txt

Latitude=40.29
Longitude=23.21
1 Like

Thank you. I had copied out the entire 6 or 7 digit version from google maps. (it’s a shame it cant use what3words as that would be so much easier!).

I have decided to remove python3 and all dependencies for now to eliminate that as per your previous post. Its a raspberry pi 1 so its not quick, but I have just finished installing the python2 dependencies and there is no output from the pi, which I can only see as a good thing at the moment. There is no output yet either on the pvoutput website but I will have to wait and see what happens as I am open to this taking a bit of time.

I think we are making progress so thanks for your help. I will let you know how I get on!

Cheers

Phill

Thats good news. You will have to wait 5-10 minutes for the first upload.
You could also try checking if it sends data with tcpdump:

Summary
root@OpenWrt:~/scripts# SET_INTERFACE=any
root@OpenWrt:~/scripts# SET_HOST=li916-169.members.linode.com
root@OpenWrt:~/scripts# /usr/sbin/tcpdump -i $SET_INTERFACE host $SET_HOST
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type LINUX_SLL (Linux cooked v1), capture size 262144 bytes
17:41:04.451257 IP OpenWrt.lan.55530 > li916-169.members.linode.com.80: Flags [S], seq 3945500662, win 29200, options [mss 1460,sackOK,TS val 1583976652 ecr 0,nop,wscale 7], length 0
17:41:04.451308 IP OpenWrt.lan.55530 > li916-169.members.linode.com.80: Flags [S], seq 3945500662, win 29200, options [mss 1460,sackOK,TS val 1583976652 ecr 0,nop,wscale 7], length 0
17:41:04.451324 IP OpenWrt.lan.55530 > li916-169.members.linode.com.80: Flags [S], seq 3945500662, win 29200, options [mss 1460,sackOK,TS val 1583976652 ecr 0,nop,wscale 7], length 0
17:41:04.454120 IP li916-169.members.linode.com.80 > OpenWrt.lan.55530: Flags [S.], seq 3410029703, ack 3945500663, win 19847, options [mss 1424,nop,wscale 2,sackOK,eol], length 0
17:41:04.454120 IP li916-169.members.linode.com.80 > OpenWrt.lan.55530: Flags [S.], seq 3410029703, ack 3945500663, win 19847, options [mss 1424,nop,wscale 2,sackOK,eol], length 0
17:41:04.454400 IP OpenWrt.lan.55530 > li916-169.members.linode.com.80: Flags [.], ack 1, win 229, length 0
17:41:04.454416 IP OpenWrt.lan.55530 > li916-169.members.linode.com.80: Flags [.], ack 1, win 229, length 0
17:41:04.454428 IP OpenWrt.lan.55530 > li916-169.members.linode.com.80: Flags [.], ack 1, win 229, length 0
17:41:05.808288 IP OpenWrt.lan.55530 > li916-169.members.linode.com.80: Flags [F.], seq 461, ack 356, win 237, length 0
17:41:05.808357 IP OpenWrt.lan.55530 > li916-169.members.linode.com.80: Flags [F.], seq 461, ack 356, win 237, length 0
17:41:05.808383 IP OpenWrt.lan.55530 > li916-169.members.linode.com.80: Flags [F.], seq 461, ack 356, win 237, length 0
17:41:06.028273 IP OpenWrt.lan.55530 > li916-169.members.linode.com.80: Flags [F.], seq 461, ack 356, win 237, length 0
17:41:06.028336 IP OpenWrt.lan.55530 > li916-169.members.linode.com.80: Flags [F.], seq 461, ack 356, win 237, length 0
17:41:06.028360 IP OpenWrt.lan.55530 > li916-169.members.linode.com.80: Flags [F.], seq 461, ack 356, win 237, length 0
17:41:06.384150 IP li916-169.members.linode.com.80 > OpenWrt.lan.55530: Flags [.], ack 462, win 6408, length 0
17:41:06.384150 IP li916-169.members.linode.com.80 > OpenWrt.lan.55530: Flags [.], ack 462, win 6408, length 0

Ok so I think I am still learning… Turns out I needed to install tcpdump! I am now over that hurdle, I have copied and pasted your commands, but the issue is how do I get the program running? I have to ctrl-c out of the code in order to run these commands and vice versa.

This is what I ran to get this going:

pi@solarpi:~/canadianSolar-pvoutput-master $ SET_INTERFACE=any
pi@solarpi:~/canadianSolar-pvoutput-master $ SET_HOST=li916-169.members.linode.com
pi@solarpi:~/canadianSolar-pvoutput-master $ /usr/sbin/tcpdump -i $SET_INTERFACE host $SET_HOST
tcpdump: any: You don't have permission to capture on that device
(socket: Operation not permitted)
pi@solarpi:~/canadianSolar-pvoutput-master $ sudo /usr/sbin/tcpdump -i $SET_INTERFACE host $SET_HOST
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes

I have tried running ./pvoutput.sh and had it running for half an hour or so with nothing appearing on the website. So it’s plain to see its not uploading, but whereas before I was getting some output, alas no such luck now. Its probably easier to show you in a picture as opposed to copying and pasting but this is what I get:

image

I’m still calling it progress, but it’s hopefully something that helps someone else out eventually!

Thanks for your continued help.

Phill

Ok, from what I see I expect that the script is running (python3 probably?).
Now with tcpdump (which need sudo (root) access), every 5 minutes you would see something like in my previous post where your pi would send data to pvoutput and pvoutput responds. If this is not the case, assuming the correct systemid, api key and timezone in the pvoutput.txt, either your system is not producing now (in which continent are you?) or there is no proper communication between your pi and the inverter.

Lets check if you do communicate with the inverter.
Check the cabling (what sort of cable are you using?). If ok then:
Open a terminal and enter python (i.e. python or python3)
then copy one line by one line the following commands in the python terminal. Paste here the output.
This assumes that your inverter has a modbus address of 1. If you have changed the address then you need to use the correct one (eg unit=0x5) or change it back to 1.
You might need to put brackets after the print command if using python3

Summary
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
inv = ModbusClient(method='rtu', port='/dev/ttyUSB0', baudrate=9600, stopbits=1, parity='N', bytesize=8, timeout=1)
inv.connect()
rr = inv.read_holding_registers(0, 45, unit=0x1)
print rr
print rr.registers
inv.close()
quit()

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,