Python wrapper for getting data asynchronously from Growatt inverters via serial usb RS232 connection and modbus RTU protocol.
The Growatt inverted must support the modbus protocol (some older inverters only support proprietary serial communication) Connect the RS232 DB9 usb adapter to the RS232 port on the underside of the inverter (you might have to remove a cover plate).
Depending on the firmware version of your inverter, not all attributes might be available
Inverter properties
DC input PV
DC input string 1 PV
DC input string 2 PV
AC output grid
AC output phase 1 grid
AC output phase 2 grid
AC output phase 3 grid
Miscellaneous information
Status, faults & warnings
import asyncio
import logging
from sys import argv
from growattRS232 import GrowattRS232
# defaults
# USB port of RS232 converter
DEFAULT_PORT = "/dev/ttyUSB0"
# Growatt modbus address
DEFAULT_ADDRESS = 0x1
logging.basicConfig(level=logging.DEBUG)
async def main():
port = str(argv[1]) if len(argv) > 1 else DEFAULT_PORT
address = int(argv[2]) if len(argv) > 2 else DEFAULT_ADDRESS
growattRS232 = GrowattRS232(port, address)
try:
data = await growattRS232.async_update()
print(f"Sensors data: {data}")
except Exception as error:
print("Error: " + repr(error))
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()