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.
Go through the tabs below for information on the parts I used for this project.
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
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
Seek information here: http://elinux.org/RPi_USB_Wi-Fi_Adapters
I used a RALINK RA5370 with an external antenna.
Pictures of setup
Here is a picture of the setup.
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.
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
and make sure your setup looks like this.
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
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.