## 3 Materials and Methods
### Integration with the Legacy Heating Control System  
To verify the robustness of the proposed solution, we implemented it in a multi-family building located in Warsaw, Poland. The legacy control system schematic is shown in Figure 1. The system has central heating (CH) and domestic hot water (DHW) circuits. The output temperature (measured at TCR/08) of the CH circuit is managed by a PID controller acting on a TVR/04 valve. The output temperature (measured at TCR/020) of the DHW circuit is managed by another PID controller acting on a TVR/05 valve. Both tasks are performed by a local controller: Honeywell Excel Web Ethernet-based, freely-programmable building automation controller. The local controller was configured to automatically connect to a Message Queuing Telemetry Transport (MQTT, ISO/IEC 20922 [33]) broker and to subscribe to a topic where the data coming from optimization algorithms is published. The publisher is a computer program running on the edge router presented in subsection 3.4. It aggregates the data received from wireless temperature sensors described in the next subsection. The hardware on which it is running is a custom built extension board for Raspberry Pi Compute Module, with Ethernet interface and LoRa radio interface. The interior of the control room, where the local controller and the edge router were installed, as well as all the hydraulics and controls, are shown in Figure 2.  
Figure 1: Heating control system schematic of the building where tests were performed. The central heating control loop consists of a controller acting on TVR/04 according to central heating circuit supply water temperature measured at TCR/08. The domestic hot water controller acts on TVR/05 valve according to the domestic hot water heat exchanger outlet temperature measured at TCR/020. Legend: �  
The local controller has access to the following data sources shown in Figure 1:  
**TCR07**: Outdoor temperature sensor
**TCR13**: Temperature of water returning from the central heating heat exchanger
**TCR08**: Temperature of central heating circuit supply water
**TCR09**: Temperature of central heating circuit return water
**TCR011**: Temperature of supply water from heat plant
**TCR013**: Temperature of return water to heat plant
**TCR016**: Inlet temperature of domestic hot water after mixing with recirculation line
**TCR017**: Temperature of domestic hot water recirculation system
**TCR015**: Temperature of tap water flowing into the domestic hot water circuit
**TCR020**: Domestic hot water heat exchanger outlet temperature
**TCR021**: Temperature of supply domestic hot water
**PCR01**: Central heating system pressure
**PCR02**: Domestic hot water system pressure
**PTR01**: Pressure of supply water from heat plant  
Figure 2: Control room in the building where tests were performed. On the right-hand side there are two control cabinets. The smaller one is a heat substation switchgear. The larger cabinet contains Honeywell Excel Web Ethernet-based programmable building automation controller, Weintek CMT-SVR-100 data logger, Ethernet switch, and an edge router for wireless sensors connected to an antenna visible in the upper right corner. In the background is the hydraulic installation: vertical pipes are for domestic hot water, horizontal pipes are for primary side district heating. A Kamstrup Multical 603 energy meter is visible straight ahead. On the right-hand side, behind the cabinets, there is a cylindrical strainer for secondary side central heating return water. Above it, there are two variable speed drive pumps.