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-modbus-rtu

v1.1.33

Published

Node-RED function build content modbus_rtu - Code by DoDuyCop

Readme

node-red-contrib-modbus-rtu

Một node mạnh mẽ và linh hoạt để xây dựng gói tin Modbus RTU, tự động tính toán CRC16, và giải mã dữ liệu số thực (Float) trực tiếp trong Node-RED.

A robust Node-RED node for building Modbus RTU frames, automatic CRC16 calculation, and decoding Floating-point data.


🌟 Tính năng nổi bật / Key Features

  • Tự động tính CRC16: Không cần viết code để tính checksum, node sẽ tự động chèn 2 byte CRC vào cuối Buffer.
  • Xử lý số thực (Float): Hỗ trợ chuyển đổi mảng byte nhận về thành số thực với định dạng ABCD hoặc CDAB (đặc biệt hữu ích cho các dòng đồng hồ năng lượng như Selec, Elmeasure...).
  • Cấu hình động (Dynamic): Cho phép thay đổi Slave ID, mã hàm, địa chỉ thanh ghi ngay trong quá trình chạy thông qua msg.payload.
  • Kiểm tra gói tin (Check CRC): Hỗ trợ xác thực gói tin nhận về từ thiết bị ngoại vi có toàn vẹn hay không.
  • Hỗ trợ đa dạng mã hàm: 01, 02, 03, 04, 05, 06, 15, 16.

🛠 Cấu hình / Configuration

Trong cửa sổ cài đặt node, bạn có các tùy chọn tại mục Function:

| Function | Mô tả (Description) | Cách dùng (Usage) | | :--- | :--- | :--- | | ADD CRC (0) | Chỉ thêm CRC | Thêm 2 byte CRC16 vào cuối msg.payload (Buffer). | | DYNAMIC (-1) | Cấu hình động | Lấy thông số từ msg.payload = {id, fn, addr, count}. | | CHECK CRC (-2) | Kiểm tra lỗi | Kiểm tra và bóc tách dữ liệu nếu CRC của gói tin nhận về là đúng. | | FLOATs ABCD (-3) | Chuyển đổi số thực | Chuyển mảng byte nhận về thành mảng số thực định dạng ABCD. | | FLOATs CDAB (-4) | Chuyển đổi số thực | Chuyển mảng byte nhận về thành mảng số thực định dạng CDAB (Selec Meter). | | Mã hàm (1-16) | Mã hàm cố định | Xây dựng gói tin dựa trên Slave ID, Address, Count trên giao diện. |


📖 Ví dụ / Examples

1. Tạo gói tin Modbus từ giao diện (GUI)

Cấu hình: Slave ID: 1, Function: 3, Address: 0, Count: 2.

  • Input: Bất kỳ gói tin nào kích hoạt node.
  • Output (Buffer): 01 03 00 00 00 02 C4 0B

2. Cấu hình động (Dynamic Mode)

Sử dụng một node function trước node này:

msg.payload = {
    id: 2,
    fn: 4,
    addr: 10,
    count: 1
};
return msg;

3. Giải mã dữ liệu đồng hồ Selec (NA111)

Nối đầu ra của node TCP/Serial vào node này, chọn Function: FLOATs CDAB (-4) và cài đặt Làm tròn (Decimal).

Kết quả: msg.payload trả về mảng số thực đã giải mã (Ví dụ: [220.5, 49.9, 0.98]).

🚀 Cài đặt / Installation

Chạy lệnh sau trong thư mục dữ liệu Node-RED (thường là ~/.node-red):

Bash npm install node-red-contrib-modbus-rtu

👤 Thông tin tác giả / Author

Tác giả: Do Duy Cop

Dự án: S-Connect IoT System

GitHub: node-red-contrib-modbus-rtu

Email: [email protected]

📄 Bản quyền / License

Dự án được phát hành dưới giấy phép MIT. 2026 © Do Duy Cop.