## 3 Multi-Sensor Architecture  
Multi-sensor integration in air quality monitoring transforms monitoring efforts from singular and limited perspectives to a comprehensive and dynamic approach, providing a deeper understanding of the intricate interplay between pollutants and environmental factors. The overall system architecture consists of two main components, as shown in Figure 1.  
First, the IoT multi-sensor layer covers the monitoring devices, network devices, and connecting equipment. It consists of a custom-designed NodeMCU-based multi-sensor with Tasmota firmware installed. This central unit is responsible for collecting data from multiple connected sensors, explained in detail in Section 2, and measures ammonia, hydrogen sulfide, carbon dioxide, PM2.5, PM10, TVOC, temperature, humidity, and pressure. In this way, continuous monitoring in the barn in real time of several physical parameters is ensured.  
Some of the sensors included in the system are connected via a serial interface to measure PM2.5 levels. Another part is connected by a combined sensor module including CCS811, SI7021, and BMP280 sensors. These sensors are connected to the NodeMCU via the I2C interface. On the other hand, to detect specific gases, the system uses MQ-136 and MQ-137 sensors, which detect hydrogen sulfide and ammonia (NH\({}_{3}\)), respectively. Due to the specificity of these sensors, they are connected via analog interfaces via an I2C ADS1115 16-bit ADC module that converts the analog signals to digital for processing by the NodeMCU.  
The multi-sensor devices pre-process the resulting data before being sent to OpenHAB for further processing and visualization. The wireless 4G router creates a Wi-Fi network to which the monitoring devices are connected and provides access to OpenHAB installed on the Raspberry Pi.  
Data transfer between each multi-sensor module and OpenHAB is conducted via the Message Queuing Telemetry Transport (MQTT) protocol, which is a publish-subscribe protocol popular among IoT applications. MQTT is based on the idea of maximally light communication (important for IoT) and small system requirements. The basic structure of MQTT includes a client, a broker, a publishing mechanism, and threading. At its core, MQTT is a message exchange-based protocol, and the model used is publish and subscribe.  
It is important to note here that there is no direct connection between the system sending data to the broker and the one that requests and then processes it. For this purpose, an intermediate component called a broker is used, which is part of the data processing and visualization layer. A few other important features of the protocol are as follows: from an MQTT perspective, clients do not use addresses; messages are posted to the broker in each topic One of the most important tasks of the broker is to filter the messages from a given topic and forward them to the customers who requested them--Subscribers. A client can receive the messages after requesting them from a specific broker and a precisely defined topic; any customer can post information and any customer can claim it; in general, the broker does not store the messages.  
The OpenHAB platform installed on Raspberry Pi 4 ([[https://www.openhab.org/](https://www.openhab.org/)]([https://www.openhab.org/](https://www.openhab.org/))), an open-source home automation system, acts as an MQTT client, subscribing to the topics of all multi-sensors and receiving their measurements. All received data are stored in an internal database, organized, and can be monitored and processed locally and remotely via My OpenHAB Cloud. For security and additional processing, the data are saved in a remote MySQL server installed on a Raspberry Pi 2. The price of all hardware components  
Figure 1: Multi-sensor system.  
of the multi-sensor is about USD 150, and the software used (Tasmota firmware 11.1.0 Ostara, OpenHAB 3.4.4, System MQTT broker of OpenHAB, MyOpenHAB Cloud) is open source, making the platform an affordable solution.