Good old TCP
The klima-online application is used to control and regulate the operation of air conditioners. The user is fully in control of the modes in which the groups of devices operate. By simply setting up plans, the building manager determines when the heating comes on, when the air conditioning comes on or when the system shuts down. From the point of view of the user and the technologies used, we wrote about this application earlier in Inspiration.
This application doesn’t exist by itself. It also communicates with the dispatching system, which collects data at regular intervals, analyzes faults and sends alerts by e-mail. These are numerical values such as room temperature, supply temperature, fan condition, pump fault and the like. The requirement of this system is clear – to have all data as up-to-date as possible.
This external system allows communication in several ways. In the first version, we implemented HTTP-POST data sending. In practice, this worked by reading the MODBUS registers of all devices in a given location at regular intervals and sending them in JSON format to the server. As web technology developers, we work with JSON on a daily basis, so the implementation was basically straightforward. We followed the JSON message format according to the documentation and sending the data worked great.
In the introduction, I mentioned that when sending data, we only work with numerical data and the external system can also receive data packages of the MODBUS-TCP protocol. So why not use it? The protocol message format is relatively simple and you don’t need to search for it for long 🙂 We have implemented a simple TCP server that responds to the data request with the read values of the device registers. Requests are sent by the external system at regular intervals of a few seconds. And what was the point of all this?
We achieved two things at once. First – the size of the transmitted data has been reduced. We send all read values as a series of bytes. The systems don’t send any HTTP headers to each other, we don’t send any extra strings that previously formed the JSON message format. The second – external dispatching system allows you to change the device settings after this protocol, which is desirable in rare cases.
In the next step, we’ll improve the management of running MODBUS-TCP servers, where we want to make full use of the potential of podman containers in combination with systemd and enable start, stop, restart and status reading directly from the klima-online.eu application from the administrator’s screens.