_DSC1495

Monitoring a Growatt PV inverter using Raspberry Pi

A Raspberry Pi is used to read data from a PV inverter (Growatt 1500) with firmware version G1.8 (modbus protocol) via the RS232 serial port. The data is automatically uploaded to pvoutput.org. Upload is sceduled every 5 min by setting up  a cronjob for running a dedicated python script.
Feel free to use any bit of the code you like. Due reference is appreciated.
The code has been tested over some days and seem stable enough. It spits out a glitch AttributeError: ‘NoneType’ object has no attribute ‘registers’ when the inverter is not connected to the grid. But the effect is just that nothing is uploaded to pvout.org.

For older versions of the Growatt inverters a standard serial protocol is used. If you happen to own one of these you cannot use the python script as it is. Either the script should be modified for the serial protocol or you may want to look at : http://www.snafu.priv.at/mystuff/ where a perl script is provided which basically does the same stuff just for a serial protocol
The most resent upload from the system is here read with a portlet from pvoutput.org.
PVoutput.org

Go through the tabs below for information on the parts I used for this project.

RPIUSB/serialPowerWiFi
The Raspberry Pi used here is the model B with 512 MB RAM.

RPI model B from Adafruit
RPI model B from Adafruit

http://www.adafruit.com/products/998 It is installed with Derbian on a standard SD 4GB memory card. The Pi is enclosed in a standard casing

USB/Serial Converter -  FT232RL
USB/Serial Converter – FT232RL

To connect to the inverter you need a serial port on you RPI. I used a USB/Serial adapter but you may also try it out with TTL/Serial. Recommended: The FT232RL from Adafruit provides +-10V serial (RS232) not 5V serial (TTL). Don’t buy your USB/serial adapter cheap since it is really annoying debugging on a faulty connection. The above displayed product from Adafruit is high quality and reliable: http://www.adafruit.com/products/18 It is plug and play and automatically available on /dev/ttyUSB0 on your pi. You can check if it is correctly recognised by

lsusb

You should see it somewhere in the list. In my case it says

Bus 001 Device 005: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
Any Micro USB Charger will do. Buy one with at least 750 mA since the RPI needs to power both a WiFi dongle and a USB/serial adapter.
If your inverter is placed somewhere with poor signal you may consider an external antenna type adapter. But make sure it is compatible with the chipset on the RPI!
Seek information here: http://elinux.org/RPi_USB_Wi-Fi_Adapters
I used a RALINK RA5370 with an external antenna.

RALINK RA5370 USB WiFi
RALINK RA5370 USB WiFi

Pictures of setup

Here is a picture of the setup.

Growatt PV inverter and RPI
Growatt PV inverter and RPI

Python stuff

You will need a few libraries installed in Python before running the code.
A Python wrapper around the OpenWeatherMap web API

pip install pyowm

And the modbus protocol for talking to you modbus serial device.

easy_install -U pymodbus
pip install  -U pymodbus

If you find any Python libraries missing, please post it here.

Setting up the serial port

Configure your serial port on the RPI correctly before connecting to the inverter. Start with a connection to you PC using putty.

  1. Enable SSH on your RPI
  2. Download the Putty SSH client on your PC.
  3. Setup a connection.

When you are done and you can connect to your PC then you will need to configure the serial port on the RPI. Use e.g. Minicom to do this. In the command line on your RPI type in

minicom

and make sure your setup looks like this.

Serial port setup

If you are using a TTL/serial connection instead of the recommended USB/serial adapter then your serial port should probably be named /dev/ttyAMA0

Make sure your the user group you are running the script from is a member of “dialout”

 ls -l /dev/tty*S*

You should see something like this

ScreenShot061

I don’t know if there is much else to say. Try it out and if you run into problems I may be able to help you out since already made most of the mistakes on the way.

14 thoughts on “Monitoring a Growatt PV inverter using Raspberry Pi”

  1. Hi thx for the script!
    I bought the same cable and its recognized by the pi:
    Bus 001 Device 005: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC

    my inverter (TL1000) with firmware 1.8 is at com1 and up and running.

    when I start your script it gives me this error:
    Traceback (most recent call last):
    File “./growatt2.py”, line 32, in
    print rr.registers
    AttributeError: ‘NoneType’ object has no attribute ‘registers’

    any idea what could be wrong?

    Jan

  2. oke I solved it , I deleted the print rr.registers line and now it works!
    thx for the script!!

  3. I’m an absolute raspbeginner, I hope you will forgive me too silly questions. But:
    will your method work when ‘some’ wifi module is connected to the rs232 port in my Growatt 1500 and my raspberry is connected (rj45) to our wifi router?

    Barry Binnenweg
    Den Haag, Holland

    1. Hi Barry,

      Can you tell us how you connected the Growatt system to the PVoutput.org website?
      We are using a Growatt 4200MTL with a Growatt wireless connector and the Growatt logging server but we also want to log on PVoutput.org

      1. Hi Johan.
        It is a little broadly formulated question. Let me point you in the right direction.
        You create an account on PVOutput.org. Get your APY Key and system ID by logging into your account and browse to the relevant section.
        Then you use Curl to upload the data you read out of your Growatt inverter.
        There is a quite elaborated help section on PVOutput for how to use the Curl commands.

        You can see how I did it under the os output section in the python script for uploading:
        http://www.sisand.dk/?page_id=139

  4. Hi,
    Thanks for your guide.
    I had everything working but my pi got hacked so I formatted my pi and started again. I’ve followed the same instructions but now it wont read from the inverter (NoneType error).
    The modbus test code doesnt work, same pi, same code, its completely baffled me.
    Any ideas?

    1. It may have to do with your firmware version of the inverter.
      I know that some 1.7 and below would have an older modbus protocol.

      The code is tested for 1.8 firmware version but newer may Again have a different protocol.

      You can check your firmware version by the silly knock-menu on the inverter.

  5. I’ve been using your script succesfully to monitor a Growatt inverter during more then one year now. Do you think i should be able to use it monitoring a Samil inverter as well? Or could you fingerpoint me to a modification in the script to make it work for that inverter as well?

Leave a Reply

Your email address will not be published. Required fields are marked *