7. June 2016
Monitor SMA Sunny Boy Inverter via Modbus

Our Photovoltaik installation is powered by a SMA solar inverter, which provides the Modbus protocol for monitoring installation parameters.

SMA provides for this device (and other devices with Modbus) tables with information at which address which information resides.

For Python there is the Modbus library ‘pymodbus’.

With some tinkering I made a Python application, which can be used with a graphical interface or via command line (without graphical interface).

The application can display multiple current values in the graphical interface or via the command line a single value directly.

Also you can specify a log file where values can be stored in configurable intervals and configurable save interval to disk.

For long time monitoring I configured a Raspberry-Pi 3 with Raspbian to run in my network. The Raspberry collects then regularly data from the inverter. The Raspberry is only supplied by a 5 V power supply and is administred via WLAN.

For Raspbian I needed just a few preparations:

  • configure WLAN connection as default connection and automatic connection
  • install the Raspbian package python-dev (sudo aptitude install python-dev)
  • install the Python package pymodbus (sudo pip install pymodbus)
  • install the Python package docopt (sudo pip install docopt)

After this the script can be run with “python pymodmon.py -i Configfile.ini”.

The config file can be easily generated by running the skript in the graphical mode via “python pymodmon.py” in a xterm and then adding the desired addresses and settings. In the graphical mode can then be tested if the addresses are available. When all settings are set as desired the config file can be saved and is then usable in the command line mode.

The config file also allows for setting the log file. If this does not exist it will be generated. If it exists new data will be appended to it.

You can find the python script on github.com: https://github.com/transistorgrab/PyModMon


© 2006 — 2019 Transistorgrab.de

2 Kommentare »

  1. Vielen Dank für das Script!

    Ich kann leider kein Python und habe daher Probleme bei der Fehlersuche. Was habe ich falsch gemacht?

    —– Beginn —–
    python pymodmon.py –ip=wechselrichter.intern.nemox.net –port=502 –id=3 –addr=30775 –type=S32 –format=RAW
    Traceback (most recent call last):
    File “pymodmon.py”, line 971, in
    File “pymodmon.py”, line 313, in runCommunication
    File “pymodmon.py”, line 353, in pollTargetData
    message = BinaryPayloadDecoder.fromRegisters(received.registers, byteorder=Endian.Big, wordorder=Endian.Big)
    AttributeError: ‘NoneType’ object has no attribute ‘registers’

    PyModMon has exited cleanly.
    —– Ende —–

    Gibt es eine Möglichkeit per Bitcoin oder PayPal etwas zu spenden?

    Kommentar by Rudolf E. Steiner —