# IoT Data Collection - Interfacing with Commercial Building Monitoring Solutions, Part I

> The ÄLLITÄ project team has been busy figuring out new ways to collect data from Savonia’s campus building in Varkaus.

## Overview
In our previous article, “Leveraging IoT Solutions for Real-Time Data Acquisition,” we discussed the importance of collecting real estate-related time series data to develop AI-based energy consumption optimization solutions. This article details the integration of a Kamstrup MULTICAL 603 heating energy monitoring device into our data backend to collect real-time data from the Varkaus campus district heating system.

## Hardware Setup
The Kamstrup MULTICAL 603 monitors district heating parameters including:
*   Incoming and outgoing water temperatures
*   Water volume, flow, and pressure
*   Total heating energy consumption

The device was equipped with a Modbus TCP/IP communication module. To interface with this, we used a Raspberry Pi 3B:
1.  **Physical Connection:** The Modbus TCP module was connected to the Pi’s Ethernet port. Since the module lacks a standard RJ45 connector, we manually wired the green and orange pairs (T568B termination).
2.  **Network:** The Pi connects to the campus IoT network via WLAN. We expanded the local wireless network to ensure stable signal quality within the heat distribution room.

## Network Configuration
To manage the Modbus module's IP addressing:
*   We used `tcpdump` to identify the module's MAC address by listening for DHCP broadcast messages.
*   We installed `dnsmasq` on the Raspberry Pi to act as a DHCP server, assigning a fixed IP address to the Modbus module based on its MAC address.
*   Connectivity was verified using the Linux utility `mbpoll`.

## Data Acquisition Logic
Modbus devices store data in "holding registers." Our process for extracting data involves:
1.  **Reading:** We read the full address space into a buffer using three separate read operations (due to the 125-register limit per operation).
2.  **Processing:**
    *   Raw values are read as int32, uint32, or IEEE-754 float (big-endian).
    *   Scaling factors are read as signed 16-bit integers.
    *   Unit codes are read as unsigned 16-bit integers.
    *   The final value is calculated by multiplying the raw value by the scaling factor.
3.  **Formatting:** Data is converted into a JSON object containing the timestamp and 56 measurable parameters.

## Software and Backend Integration
*   **Application:** A NodeJS program using `modbus-serial` and `moment` packages, running inside a Docker container on the Raspberry Pi.
*   **Backend:** A self-hosted Thingsboard PE instance.
*   **Transmission:** Data is sent via HTTP POST to the Thingsboard REST API every 20 seconds.
*   **Reliability:** The system has been running for 8 weeks without interruption. The backend handles potential duplicate entries by utilizing the original timestamps provided by the monitoring device.

## Future Work
In the next article, “IoT Data Collection – Interfacing with Commercial Building Monitoring Solutions, Part II,” we will discuss integrating multiple commercial LoRaWAN air quality monitoring devices into our data backend.

## Project Team
*   **Mika Leskinen**, RDI Specialist, DigiCenter, Savonia University of Applied Sciences
*   **Shahbaz Baig**, RDI Specialist, DigiCenter, Savonia University of Applied Sciences
*   **Laura Leppänen**, RDI Specialist, Savonia University of Applied Sciences
*   **Aki Happonen**, Digital Development Manager, DigiCenter, Savonia University of Applied Sciences

## References
*   Kamstrup A/S, 2025. Data Sheet – Multical 603 and 803. [Available here](https://kamstrup-delivery.sitecorecontenthub.cloud/api/public/content/59507-downloadOriginal)