npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

node-red-contrib-edgelink-modbus

v1.3.2

Published

EdgeLink Modbus TCP 采集节点 — 长连接池 + 表格编辑器 + 字节序 + 模拟模式

Readme

node-red-contrib-edgelink-modbus

npm version license Node-RED

Modbus TCP 采集节点。一个节点读 N 个点位,长连接池,表格编辑器,零外部依赖。


截图

(替换为实际截图地址)


为什么选这个节点?

| 痛点 | node-red-contrib-modbus | 本节点 | |------|--------------------------|--------| | 读 50 个寄存器 | 拖 50 个节点或配 Flex-Connector | 1 个节点,填表 | | FLOAT32 跨寄存器 | 自己写 function 拼接 | 表格选 FLOAT32,自动读相邻寄存器 | | 字节序不一致 | 全局配一个 | 每个标签独立选 AB/BA/ABCD... | | 原始值 2530 → 253.0℃ | 自己换算 | 填斜率 0.1,自动输出 | | PLC 返回异常码 | "Error" | [MB 0x02] Illegal data address |


特性

  • 表格编辑器 — 一个节点配置 N 个点位,自动按寄存器类型和地址聚类合并为批量读取
  • 长连接池 🆕 — TCP 连接持久复用,跨轮采集无需重复握手
  • 请求队列串行化 🆕 — 多节点共享同一设备时自动排队,防止读写交错
  • TCP Keepalive 🆕 — 30 秒探测保活,防止空闲连接被断开
  • 断线自动重建 🆕 — 连接断开或超时自动检测并重建
  • deviceId 归一化 🆕 — 输出始终为数字,兼容下游索引
  • 4 种寄存器类型 — 线圈(FC01)、离散输入(FC02)、保持寄存器(FC03)、输入寄存器(FC04)
  • 6 种数据类型 — INT16 / UINT16 / INT32 / UINT32 / FLOAT32 / BOOL
  • 6 种字节序 — AB / BA / ABCD / CDAB / BADC / DCBA,每个标签独立配置
  • 斜率偏移变换engValue = rawValue × slope + offset
  • 批量生成 — 起始地址 + 数量 + 类型,一键填表
  • 异常诊断 — 11 个 Modbus 异常码映射
  • 模拟模式RED.settings.mbSimulationMode = true 不连设备即可测试
  • 零依赖 — 仅使用 Node.js 内置 net + Buffer

安装

cd ~/.node-red
npm install node-red-contrib-edgelink-modbus

重启 Node-RED,左侧节点栏 edgelink 分类下出现 Modbus 读取 节点。配置节点在 config 侧边栏。


使用方法

1. 添加连接配置

拖入 Modbus 连接配置,填写:

| 参数 | 默认值 | 说明 | |------|--------|------| | IP 地址 | 192.168.1.10 | Modbus TCP 设备 IP | | 端口 | 502 | Modbus TCP 默认端口 | | 从站地址 | 1 | Modbus 从站 ID (1-247) | | 超时 | 3000 | TCP 读写超时(ms) |

2. 配置点位表格

拖入 Modbus 读取,关联配置,在表格中添加点位:

| 寄存器类型 | 地址 | 数据类型 | 字节序 | 斜率 | 偏移 | 名称 | |-----------|------|----------|--------|------|------|------| | 保持寄存器 | 0 | INT16 | AB | 0.1 | 0 | 温度 | | 保持寄存器 | 10 | FLOAT32 | ABCD | 1 | 0 | 压力 | | 线圈 | 0 | BOOL | — | — | — | 开关 |

连续批量:起始 0、数量 100、保持寄存器、INT16,一键生成。

3. 触发采集

inject 节点 → Modbus 读取节点,部署后点击 inject 即可。


输出格式

msg.payload = {
  success: true,
  deviceId: 1001,                      // 数字ID,兼容下游索引
  data: {
    "温度": {
      rawValue: 2530,          // 寄存器原始值
      engValue: 253.0,         // 解码后 × 斜率 + 偏移
      quality: 0,              // 0=正常 2=异常
      ts: "2026-07-04T08:00:00.000Z",
      regType: "holding"
    },
    "压力": {
      rawValue: 4123,
      engValue: 41.23,
      quality: 0,
      ts: "2026-07-04T08:00:00.000Z",
      regType: "holding"
    }
  },
  error: null,
  driverType: "driver-modbus-tcp",
  plcIp: "192.168.1.10",
  plcPort: 502,
  roundTimeMs: 12
}

与 EdgeLink 生态集成

┌──────────────────┐     ┌──────────────────────┐     ┌──────────────────┐
│ edgelink-modbus  │────→│ edgelink-pg-store    │────→│ PostgreSQL /     │
│ (本节点)         │     │ (PG 批量写入)        │     │ TimescaleDB      │
└──────────────────┘     └──────────────────────┘     └──────────────────┘

模拟模式

// Node-RED settings.js
mbSimulationMode: true

所有 Modbus 读取节点不连设备,返回随机仿真数据。


支持的设备

任何支持 Modbus TCP 协议的设备:PLC(西门子/施耐德/台达/汇川)、远程 IO 模块、传感器、变频器等。


限制

  • 仅 Modbus TCP(不包含 RTU/ASCII 串口)
  • 仅读取(不包含写入功能码 05/06/0F/10)

许可证

MIT