View Categories

MODBUS TCP: Integration with Photovoltaics

1. Introduction #

The DOMIQ/Base module has built-in support for the MODBUS TCP protocol. In practice, this means wide integration possibilities with many devices. Thanks to this, the capabilities of a smart building are significantly expanded. Examples of such devices include PV inverters, ventilation units, heat pumps, and central heating boilers. In this tutorial, we’ll focus on the first type – photovoltaic inverters.

2. What do you gain from integrating PV with DOMIQ? #

Main goal: Optimization of energy production management. #

Optimization is achieved by enabling control of devices in the building based on the parameters of the PV installation. This is particularly important if you don’t have an energy storage system and your production is settled using the net billing model. In this scenario, the Base module reads production data from the PV inverter and, according to programmed rules, can activate certain devices to consume energy on-site without sending it to the power grid (maximizing self-consumption). This also helps lower grid voltage to avoid PV inverter shutdowns when the 253V limit is exceeded. As a result, you gain real financial savings – you don’t pay distribution fees and avoid selling energy at low rates.

Below are some examples of actions worth executing during peak PV energy production:

  1. Activating the hot water heater (DHW).
  2. Increasing the target temperature of the DHW buffer tank.
  3. Increasing the target temperature on the heat pump/central heating boiler.
  4. Starting air conditioning to cool the house during production peaks.
  5. Activating building heating (e.g., electric heaters, storage heaters). Particularly useful during transitional periods (early fall/spring).
  6. Charging battery-powered devices.
  7. Heating water in a pool or jacuzzi.

Additional goal: Data monitoring #

Thanks to the integration of the DOMIQ system with Grafana, you can easily collect data on energy production and PV system performance over any time period. Additionally, current system data can be displayed in the Remote app. With historical trends, you can discover further optimization opportunities.
More on Grafana integration here: https://domiq.pl/wiki/wykresy-w-domiq-integracja-z-grafana/

3. What will you need? #

To implement the functionality presented in this tutorial, you will need:

  1. DOMIQ/Base – the base module of the DOMIQ system.
  2. Photovoltaic inverter – must be equipped with support for the MODBUS TCP protocol and connected to the LAN network in which the DOMIQ/Base module operates.
  3. Bidirectional energy meter – it is important that the inverter can communicate with the meter to retrieve data on current production and consumption. This is essential for detecting energy surplus. Based on our experience, the following brands integrate without issues:
    1. Fronius
    2. Solar Edge
    3. SMA
    4. Victron
    5. GoodWe
  4. Documentation with the Modbus register map of the inverter and meter.

4. Example implementation #

In this section, we present an integration example with the Fronius Symo-Gen24 Plus inverter.
For Fronius, to detect energy surplus, the installation must include a Fronius Smart Meter bidirectional energy meter. This meter works with the inverter and is visible via the Modbus TCP protocol as a separate device.

All configuration is done in the Modbus tab of the DOMIQ/Base configurator.

  1. Click +Connection to add a new TCP connection to the PV inverter.
  2. In the Details window, enter connection parameters:
    1. Name – enter the name of this connection here. The name cannot contain spaces or Polish characters and must be unique throughout the entire configuration in the Modbus tab. Example name: pv.
    2. Type – select TCP
    3. IP Address – enter the IP address of your inverter. It’s recommended to assign a fixed IP based on the MAC address of the inverter’s network card
    4. Port – typically 502 (default for MODBUS TCP)
  3. With the connection selected in the Structure list, click +Device to add a device definition for the connected inverter. In the Details window
    • Name – enter a name for the inverter, e.g., inverter, fronius
      • 2. Address – enter the address set in the inverter configuration (range 1–247). In our case: 1
  4. Add another device for the energy meter:
    • Name – e.g., meter, smartMeter
    • Address – e.g., 2 (range 1–247)

At this stage, the configuration remains the same regardless of the inverter brand. The key is properly configuring the register map as described above.

The most important part is properly configuring the register map, which the Base module will use to read data from devices. All configuration is performed in the Registers window. Registers should be defined according to the manufacturer’s documentation. For illustration purposes, here is the configuration for a Fronius PV inverter and a Fronius Smart Meter.

Inverter #

Smart Meter #

5. Controlling devices #

At this stage, the configuration remains the same regardless of the inverter brand. The key is properly configuring the register map as described above.

The most important part is properly configuring the register map, which the Base module will use to read data from devices. All configuration is performed in the Registers window. Registers should be defined according to the manufacturer’s documentation. For illustration purposes, here is the configuration for a Fronius PV inverter and a Fronius Smart Meter.

  1. The timer checks the surplus power produced by the PV system every 5 minutes within a specified time window. If this is greater than or equal to the heater’s power and the heater is not turned on, the system will turn the heater on.
  2. If the excess power produced falls below a pre-determined threshold (we assumed 1800W), a 15-minute timer will be activated. If this condition persists for 15 minutes (the timer will count down), the heater will be turned off. This action is intended to prevent the boiler from operating when the excess power is insufficient and also to protect against frequent heater switching.
  3. If, in the meantime, the excess power produced by the PV installation again exceeds the expected value, the 15-minute timer will be reset and the heater will continue to operate.

Implementation #

For the purposes of the example, we made the following assumptions:

  • Boiler power: 2000W
  • Minimum PV surplus to turn on boiler: 2000W
  • Cutoff threshold: 1800W. Below this value, the timer to turn off the heater will be activated.
  • Boiler shutdown delay: 15 minutes
  • PV surplus identifier: MODBUS.pv.smartMeter.ac_power
  • Shelly socket identifier: SHELLY.bojler.relay.0
  • an auxiliary identifier that indicates whether the heater shutdown timer has been activated: VAR.boiler.timer.
    All of the above parameters can be customized to suit your needs.

IMPORTANT: The Fronius meter has one register that indicates the current system power. A positive value means that energy is being drawn from the grid. A negative value means that there is excess power and energy is being fed into the grid. Therefore, in our configuration, all comparisons are made with respect to a negative value, because, as mentioned earlier, we are interested in the excess power that we want to use to maximize self-consumption of energy.The configuration files for the procedure described below are an appendix to the tutorial.

In the first step, we will define a timer that will check for excess power produced by the PV installation. In our case, we assumed the timer will run from 9 a.m. to 4 p.m.

  1. Define a timer in the Timers tab:
    • Hour: 9,10,11,12,13,14,15
    • Minute: 0,5,10,15,20,25,30,35,40,45,50,55
    • Condition: MODBUS.pv.smartMeter.ac_power <= -2000 and SHELLY.bojler.relay.0 == 0
  2. +Command
    • Name: C.SHELLY.bojler.relay.0
    • Value: 1
  3. Save the configuration.

The timer defined in this way will be called during all the mentioned hours, every 5 minutes, each time checking the PV surplus power and the boiler status.

  1. In the Events tab, add a group (+Group). In the Description field, enter, for example, Boiler Control.
  2. Add the first event to the group. It will respond to excess power drops below a threshold by setting a timer to shut down the boiler.
    • Channel: E.MODBUS.pv.smartMeter.ac_power
    • Data: (leave empty)
    • Condition: $D0 > -1800 and SHELLY.bojler.relay.0 == 1 and VAR.bojler.timer == 0
  3. Actions:
    • +Command – setting the timer for 15 minutes to turn off the boiler:
      • Name: TIMER.bojler_off.15min.C.bojler
      • Value: 0
    • +Command – marking via the VAR variable that the timer has been started.
      • Name: C.VAR.bojler.timer
      • Value: 1

4. Add a second event. This event is a macro for turning off the boiler and simultaneously resets the VAR variable signaling that the timer for automatic boiler shutdown has started.

  1. Channel: C.bojler
  2. Data: 0
  3. Actions:
    • +Command
      • Name: C.SHELLY.bojler.relay.0
      • Value: 0
    • +Command
      • Name: C.VAR.bojler.timer
      • Value: 0

5. Add another event to the group. This event will respond to an increase in excess power above the expected value. This event will reset the timer that counts down to automatic boiler shutdown.

  1. Channel: E.MODBUS.pv.smartMeter.ac_power
  2. Data: (leave empty)
  3. Condition: $D0 <= -2000 and VAR.bojler.timer == 1
  4. Actions:
    • +Command – clear timer.
      • Name: TIMER.bojler_off.0
      • Value: 0
    • +Command – resetting the variable informing about the running countdown.
      • Name: C.VAR.bojler.timer
      • Value: 0

6. Save the configuration

6. Summary #

If you’ve made it this far – congratulations! We believe that by integrating DOMIQ with your PV installation, you’ll significantly expand your smart building’s capabilities, optimize energy usage, and achieve real financial benefits.

Attached files #

Powered by BetterDocs