今日已更新 396 条资讯 | 累计 20866 条内容
关于我们

标签:#modbus

找到 1 篇相关文章

AI 资讯

Getting Started with Modbus RTU on ESP32

Modbus RTU over RS-485 is the serial workhorse of industrial field wiring — the variant you'll meet when connecting an ESP32 directly to an energy meter, PLC, VFD, or temperature transmitter over a wired bus. This tutorial walks through wiring the hardware, installing a library, and flashing working RTU master code. What You'll Build A Modbus RTU master on ESP32 that polls holding registers from an RS-485 slave device over a wired bus. An understanding of register types, addressing, and the reliability practices that separate a demo from a production deployment. Prerequisites Arduino IDE (or PlatformIO) with the ESP32 board package installed. An ESP32 dev board, or an industrial ESP32 controller with a built-in RS-485 transceiver such as the NORVI X — this saves you from wiring a separate MAX485 module. A Modbus RTU slave device (energy meter, sensor, or PLC). Basic familiarity with the Arduino C++ syntax and serial monitor debugging. A 60-Second Modbus Primer Modbus is a master–slave protocol dating back to 1979. One master polls up to 247 slave devices, each with a unique address (1–247). Data lives in four register types, and knowing which one you need is half the battle: Register Type Access Width Typical Use Coils (0x) Read/Write 1-bit Relay outputs, digital controls Discrete Inputs (1x) Read only 1-bit Digital sensor inputs, switch states Input Registers (3x) Read only 16-bit Analog sensor values, process data Holding Registers (4x) Read/Write 16-bit Setpoints, configuration parameters Modbus RTU over RS-485 Step 1 — Wire the Hardware The ESP32's UART pins output 3.3V TTL logic, but RS-485 uses a differential voltage signal — so you need a TTL-to-RS-485 transceiver (typically a MAX485 or MAX3485 chip) between the ESP32 and the bus. UART TX → transceiver DI (driver input) UART RX ← transceiver RO (receiver output) A spare GPIO → transceiver DE and RE tied together (direction control) Transceiver A/B terminals → the RS-485 A+/B− pair on your slave device Skip th

2026-07-17 原文 →