Vai al contenuto

Temperature/Humidity Sensor Documentation

Overview

This is a high-precision digital temperature and humidity sensor transmitter with RS-485 interface using the Modbus-RTU protocol. The sensor provides reliable environmental monitoring with accurate measurements of both temperature and relative humidity in a compact, industrial-grade design. Multiple housing options are available (PVC, PE, and MT variants) to suit different installation environments.

Sensor Type

  • Interface: RS485 Modbus-RTU
  • Read Type: Holding Registers
  • Units: Temperature (°C), Humidity (%)
  • Communication Protocol: Modbus-RTU RS485
  • Baud Rate: 9600
  • Default Address: 01

Key Features

  • Temperature measurement range: -40°C to +80°C
  • Humidity measurement range: 0% to 100% RH
  • Accuracy: ±0.3°C (at 25°C), ±3% RH (at 60% RH, 25°C)
  • Resolution: 0.1°C (temperature), 0.1% RH (humidity)
  • Response time: Less than 1 second
  • Working voltage: 5-28V DC (12V recommended)
  • Power consumption: Less than 0.1W

Sample Implementation

Here's a complete example of a Modbus-Read node that polls periodically from the temperature/humidity sensor:

⚠️ Disclaimer

The following example is taken from test flows and may require configuration adjustments to work in your environment. Make sure to configure the nodes according to your specific setup and requirements.

Displayed flow

Temperature/Humidity

Flow Components

Modbus Read Node

  • Reads two registers starting from address 0 on Modbus Unit ID 1
  • Polling rate: every 5 seconds
  • Returns msg.payload = [temperature, humidity] containing temperature and humidity register values

Function Node

Converts the raw register values to actual temperature and humidity readings:

let temperature = msg.payload[0] / 10;
let humidity = msg.payload[1] / 10;

Routes the values to one of three outputs depending on environmental conditions:

Temperature (°C) Humidity (%) Output LED Status
≤25 <55 1 Green Perfect conditions
>25 or ≥55 2 Red Warning conditions
≥35 or ≥70 3 Heartbeat Red Critical conditions

Note: If both temperature and humidity read 0, the output is ignored (sensor initialization or error state).

Modbus Client

Configures communication with the sensor: - Serial port: /dev/ttyLP6 - Baud rate: 9600, 8N1 - Timeout: 1000ms - Reconnect timeout: 2000ms - Automatic reconnection on failure

Environmental Thresholds

Perfect Conditions

  • Temperature: ≤25°C
  • Humidity: <55%

Warning Conditions

  • Temperature: >25°C and <35°C
  • Humidity: ≥55% and <70%

Critical Conditions

  • Temperature: ≥35°C
  • Humidity: ≥70%

Flow Example

The following JSON can be imported directly into Node-RED:

[
  {
    "id": "ada498da8195cbaa",
    "type": "tab",
    "label": "Temperature/Humidity",
    "disabled": false,
    "info": "",
    "env": []
  },
  {
    "id": "374c1f8fd8bfab29",
    "type": "modbus-read",
    "z": "ada498da8195cbaa",
    "name": "T/H Sensor Read",
    "topic": "",
    "showStatusActivities": false,
    "logIOActivities": false,
    "showErrors": false,
    "showWarnings": false,
    "unitid": "1",
    "dataType": "HoldingRegister",
    "adr": "0",
    "quantity": "2",
    "rate": "5",
    "rateUnit": "s",
    "delayOnStart": false,
    "enableDeformedMessages": false,
    "startDelayTime": "",
    "server": "58adeeb67107b4f5",
    "useIOFile": false,
    "ioFile": "",
    "useIOForPayload": false,
    "emptyMsgOnFail": false,
    "x": 380,
    "y": 380,
    "wires": [
      [
        "41fa3449418fa97b",
        "9d86fb4b207179d7"
      ],
      []
    ]
  },
  {
    "id": "41fa3449418fa97b",
    "type": "function",
    "z": "ada498da8195cbaa",
    "name": "Calculate T/H",
    "func": "let temperature = msg.payload[0]/10;\nlet humidity = msg.payload[1]/10;\n\nlet out1 = null; // Perfect\nlet out2 = null; // Warning\nlet out3 = null; // Critical\n\n\nif(temperature === 0 && humidity === 0){\n    return [out1, out2, out3]\n}\n\nlet newMsg = { payload: { temperature, humidity } };\n\n// Critical\nif (temperature >= 35 || humidity >= 70) {\n    out3 = newMsg;\n}\n// Warning\nelse if (temperature > 25 || humidity >= 55) {\n    out2 = newMsg;\n}\n// Perfect\nelse if (temperature <= 25 && humidity < 55) {\n    out1 = newMsg;\n}\n\nreturn [out1, out2, out3];\n",
    "outputs": 3,
    "timeout": 0,
    "noerr": 0,
    "initialize": "",
    "finalize": "",
    "libs": [],
    "x": 680,
    "y": 380,
    "wires": [
      [
        "71ef6c892b64d956",
        "5d138627cfb564d8"
      ],
      [
        "b4e018ce1085fc2b",
        "2b29febc48ee5ead"
      ],
      [
        "09ba427f10c89865",
        "e22be014991d2ce9"
      ]
    ]
  },
  {
    "id": "09ba427f10c89865",
    "type": "LedControl",
    "z": "ada498da8195cbaa",
    "name": "Heartbeat Red",
    "led": "Red",
    "heartbeat": true,
    "green": "",
    "heartbeatGreen": "",
    "red": "",
    "heartbeatRed": "",
    "x": 1040,
    "y": 440,
    "wires": [
      []
    ]
  },
  {
    "id": "2b29febc48ee5ead",
    "type": "LedControl",
    "z": "ada498da8195cbaa",
    "name": "Red",
    "led": "Red",
    "heartbeat": "",
    "green": "",
    "heartbeatGreen": "",
    "red": "",
    "heartbeatRed": "",
    "x": 1010,
    "y": 380,
    "wires": [
      []
    ]
  },
  {
    "id": "5d138627cfb564d8",
    "type": "LedControl",
    "z": "ada498da8195cbaa",
    "name": "Green",
    "led": "Green",
    "heartbeat": "",
    "green": "",
    "heartbeatGreen": "",
    "red": "",
    "heartbeatRed": "",
    "x": 1010,
    "y": 280,
    "wires": [
      []
    ]
  },
  {
    "id": "71ef6c892b64d956",
    "type": "debug",
    "z": "ada498da8195cbaa",
    "name": "debug 54",
    "active": true,
    "tosidebar": true,
    "console": false,
    "tostatus": false,
    "complete": "payload",
    "targetType": "msg",
    "statusVal": "",
    "statusType": "auto",
    "x": 1020,
    "y": 240,
    "wires": []
  },
  {
    "id": "e22be014991d2ce9",
    "type": "debug",
    "z": "ada498da8195cbaa",
    "name": "debug 55",
    "active": true,
    "tosidebar": true,
    "console": false,
    "tostatus": false,
    "complete": "payload",
    "targetType": "msg",
    "statusVal": "",
    "statusType": "auto",
    "x": 1020,
    "y": 480,
    "wires": []
  },
  {
    "id": "b4e018ce1085fc2b",
    "type": "debug",
    "z": "ada498da8195cbaa",
    "name": "debug 56",
    "active": true,
    "tosidebar": true,
    "console": false,
    "tostatus": false,
    "complete": "payload",
    "targetType": "msg",
    "statusVal": "",
    "statusType": "auto",
    "x": 1020,
    "y": 340,
    "wires": []
  },
  {
    "id": "9d86fb4b207179d7",
    "type": "debug",
    "z": "ada498da8195cbaa",
    "name": "Reading values",
    "active": true,
    "tosidebar": true,
    "console": false,
    "tostatus": false,
    "complete": "payload",
    "targetType": "msg",
    "statusVal": "",
    "statusType": "auto",
    "x": 680,
    "y": 320,
    "wires": []
  },
  {
    "id": "58adeeb67107b4f5",
    "type": "modbus-client",
    "name": "Modbus-client",
    "clienttype": "simpleser",
    "bufferCommands": true,
    "stateLogEnabled": false,
    "queueLogEnabled": false,
    "failureLogEnabled": false,
    "tcpHost": "172.31.20.72",
    "tcpPort": 502,
    "tcpType": "DEFAULT",
    "serialPort": "/dev/ttyLP6",
    "serialType": "RTU-BUFFERD",
    "serialBaudrate": "9600",
    "serialDatabits": 8,
    "serialStopbits": 1,
    "serialParity": "none",
    "serialConnectionDelay": 100,
    "serialAsciiResponseStartDelimiter": "0x3A",
    "unit_id": 1,
    "commandDelay": 1,
    "clientTimeout": 1000,
    "reconnectOnTimeout": true,
    "reconnectTimeout": 2000,
    "parallelUnitIdsAllowed": true,
    "showErrors": false,
    "showWarnings": false,
    "showLogs": false
  }
]