LabVIEW and Modbus/TCP Temperature and Humidity Monitoring System

Click the blue text above to follow our public account, where we share a LabVIEW case every day.

Based on the LabVIEW development platform and the Modbus/TCP communication protocol, a temperature and humidity data acquisition and monitoring system suitable for laboratory environments is designed. Through remote communication between the host computer and high-precision temperature and humidity acquisition devices, real-time collection, storage, analysis, and alarm functions of temperature and humidity data from multiple devices are achieved, solving the problems of low efficiency and poor environmental adaptability of traditional manual collection, thus enhancing the level of laboratory automation management.

LabVIEW and Modbus/TCP Temperature and Humidity Monitoring System

Application Scenarios

Applicable to high and low temperature environmental testing scenarios in fields such as electronics, communications, aerospace, and materials, it can centrally monitor the temperature and humidity data of dozens of high and low temperature test chambers, meeting the real-time monitoring needs of data under harsh environments (such as noise and vibration) during long-term cyclic tests, and supporting multi-device collaborative management and historical data traceability.

Hardware Selection

Hardware Component

Brand Model

Core Advantages

Host Computer

Dell Precision 5820

Industrial-grade stability, supports multi-task parallel processing, compatible with the LabVIEW development environment

Temperature and Humidity Recorder

Siemens S7-1200 Series (with TH module)

High reliability from a major brand, supports Modbus/TCP protocol, has 8-channel signal acquisition capability, and can connect 4 temperature and humidity sensors per device

Temperature and Humidity Sensor

Honeywell HIH-4000 Series

High measurement accuracy (humidity ±3.5% RH, temperature ±0.3℃), fast response speed, suitable for a wide temperature working environment of -40℃ to 85℃

Router

Huawei S1700-24G

All Gigabit ports, supports TCP/IP protocol, ensures communication stability and data transmission rate when multiple devices are connected

Selection Logic: Using branded hardware to enhance system reliability, the combination of Siemens PLC and Honeywell sensors meets industrial-grade accuracy requirements; the high-performance configuration of the Dell host ensures smooth operation of LabVIEW programs; the full-duplex communication characteristics of the Huawei router adapt to the data transmission needs of the Modbus/TCP protocol, avoiding communication delays in half-duplex mode.

Software Design and Function Implementation

(1) Architecture Framework

LabVIEW Development Platform
├─ Communication Module: Modbus/TCP protocol parsing, supports concurrent communication of multiple devices
├─ Data Processing Module: Real-time data calculation (big-endian mode conversion), threshold judgment, alarm triggering
├─ Storage Module: TDMS file storage (high-speed read/write) + Access database management (user/device/task information)
├─ Human-Machine Interaction Module: Permission login, real-time curve display, historical data query, report printing

(2) Core Function Implementation

  1. Multi-Device Communication Management Through the LabVIEW function <span><span>Modbus-MB-Ethernet-Master Query</span></span>, configure the TCP port 502 and device IP addresses, using a polling mechanism to sequentially read the temperature and humidity register data of 7 Siemens S7-1200 devices. Function code <span><span>0x04</span></span> is used to read input registers (such as temperature/humidity raw values), and <span><span>0x03</span></span> is used to read device status registers, achieving concurrent acquisition of 28 channels of temperature and humidity data.

  2. Data Calculation and Alarm Mechanism For the big-endian mode data from the Honeywell sensors (such as register value <span><span>C1 D8 41 B2</span></span>), use the LabVIEW function <span><span>From String</span></span> to perform byte order conversion, calculating the actual physical value (such as 22.35). Pre-set upper and lower limit thresholds for temperature and humidity, triggering audible and visual alarms when data exceeds limits, and displaying the alarm device number and time on the interface.

  3. Modular Data Management

  • Real-Time Storage: Using the NI TDMS file format, naming files after the experiment name, achieving high-speed data writing once per second, with a single file supporting millions of data points storage.

  • Database Management: Connecting to the Access database through the LabVIEW database toolkit, establishing user tables (permission management), device tables (IP/status/validity), and task tables (parameter configuration/execution status), supporting SQL statements for data CRUD operations, such as recording experimental task parameters through the <span><span>INSERT INTO</span></span> command.

  • Human-Machine Interaction Design

    • Login Module: Based on permission levels (administrator/operator) to restrict function access, verifying account passwords through the database to ensure system security.

    • Main Interface: Integrating real-time curves from multiple devices (trend graph controls), data tables, and device status indicators, supporting right-click menus for quick switching of display ranges, exporting CSV reports, and printing waveform graphs.

    Issues and Solutions

    (1) Issue 1: Multi-Device Communication Conflicts

    Phenomenon: When sending Modbus requests to multiple Siemens PLCs simultaneously, port occupation errors or data garbling occur. Solution:

    1. Use a <span><span>TCP</span></span><span><span> connection pool</span></span> mechanism to allocate independent connection handles for each device, avoiding port resource competition;

    2. Add a sequence structure and <span><span>wait function</span></span> in the LabVIEW program, setting a 50ms device polling interval to ensure complete request-response cycles;

    3. Capture communication exceptions through <span><span>error clusters</span></span>, automatically restarting the connection of faulty devices to improve system fault tolerance.

    (2) Issue 2: Big-Endian Mode Data Parsing Errors

    Phenomenon: The calculated temperature and humidity values deviate significantly from the actual values (e.g., displaying -20 when the actual value is 25).Solution:

    1. Use the LabVIEW function <span><span>Byte Swap</span></span> to reorganize the register values (e.g., converting <span><span>[Byte1, Byte2, Byte3, Byte4]</span></span> to <span><span>[Byte3, Byte4, Byte1, Byte2]</span></span>);

    2. Develop a calibration subroutine, using a standard temperature and humidity source (such as FLUKE 9170) to perform linear fitting on the calculation formula, correcting conversion coefficients (e.g., temperature conversion formula:<span><span>T = (</span></span><span><span>register value</span></span><span><span> × 0.01) - 40</span></span>).

    (3) Issue 3: Massive Data Storage Performance Bottlenecks

    Phenomenon: After continuous collection for 24 hours, the TDMS file writing speed decreases, and database query delays increase.Solution:

    1. Enable chunked storage for the TDMS file, generating sub-files by the hour to reduce the amount of data in a single file;

    2. Create indexes for commonly queried fields (such as “device number” and “collection time”) in the Access database to optimize SQL query statements;

    3. Use an asynchronous writing mechanism, caching collected data to memory via a queue before batch writing to storage media, reducing I/O operation frequency.

    LabVIEW Capabilities

    1. Graphical Programming Advantages: Through flowchart-style VI node connections, intuitively implement Modbus protocol parsing, data processing, and interface interaction logic, lowering the coding threshold for engineers, especially suitable for rapid prototyping in measurement and control fields.

    2. Hardware Driver Ecosystem: Built-in industrial-grade tools such as OPC Server and DSC modules, seamlessly connecting with major brand hardware like Siemens and Honeywell, supporting plug-and-play driver configuration, shortening hardware integration cycles.

    3. Real-Time System Compatibility: Can be directly deployed on the LabVIEW Real-Time module, supporting real-time hardware platforms such as PXI/CompactRIO, meeting industrial-grade requirements for temperature and humidity acquisition with “zero latency” and “high reliability”.

    4. Engineering Deployment Capability: Provides the ability to generate standalone executable files, allowing operation without installing the LabVIEW development environment, supporting packaging of EXE programs and dynamic link libraries (DLL), facilitating system integration and secondary development.

    Conclusion

    This system, through the deep integration of LabVIEW and major brand industrial hardware, constructs a highly reliable and easily expandable temperature and humidity monitoring system. The combination of LabVIEW’s graphical development model and the Modbus/TCP protocol effectively solves core issues such as multi-device networking, real-time data processing, and human-machine interaction, showing significant advantages over traditional solutions in development efficiency, system stability, and maintainability, providing a standardized reference solution for distributed data acquisition in industrial environments.

    About Us

    This is a feature introduction of LabVIEW, for more usage methods and development cases, please visit our official website for more information. If you need collaboration on LabVIEW projects, please contact us. Join our WeChat public account to stay updated on the latest technology trends.

    13691203761 Manager Wang (Mobile WeChat)

    LabVIEW and Modbus/TCP Temperature and Humidity Monitoring System LabVIEW and Modbus/TCP Temperature and Humidity Monitoring System

    Leave a Comment