esp-modbus-skill

Guides creation and debugging of Modbus RTU, ASCII, and TCP firmware on ESP-IDF.

28|3|Updated Jun 24, 2026
One-click install
npx skills add https://github.com/JasonYANG170/esp-dev-skill --skill esp-modbus-skill-jasonyang170
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: esp-modbus-skill
Source: https://github.com/JasonYANG170/esp-dev-skill/tree/main/repos/esp-modbus
Command: npx skills add https://github.com/JasonYANG170/esp-dev-skill --skill esp-modbus-skill-jasonyang170

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developing Modbus master or slave firmware with the Espressif esp-modbus v2 library involves many failure-prone details: handle-based APIs, Data Dictionary CID mapping, register-area descriptors, RS485 UART setup, Kconfig flags, and cryptic error codes. This Skill grounds every answer in the real esp-modbus repository headers, docs, and examples so the AI never invents APIs and produces working firmware. ## Core Features & Use Cases - Scenario Recipes: Step-by-step guides with real code for serial master/slave, TCP master/slave, Data Dictionary authoring, register-area mapping, custom function-code handlers, extended endianness types, and slave event loops. - API & Config Reference: Verbatim function signatures from esp_modbus_master.h / esp_modbus_slave.h and a full CONFIG_FMB_* Kconfig table with defaults and ranges. - Pitfall Checklists: 14+ documented mistakes with WRONG vs CORRECT code, plus an esp_err_t diagnosis table (0x103/0x106/0x107/0x108) and failure-recovery strategies. - Use Case: Ask the AI to build a Modbus RTU slave on an ESP32-S3 exposing temperature as a holding register over RS485; it will produce the correct create → set_descriptor → uart_set_pin → uart_set_mode(RS485 half-duplex) → start sequence with matching Kconfig and build commands. ## Quick Start Ask the AI to create a Modbus RTU serial master on ESP32 that polls a holding register from slave address 1, and it will follow the serial_master recipe to generate the complete ESP-IDF project.

Frequently Asked Questions about esp-modbus-skill

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a Modbus RTU master on ESP32 with esp-modbus?

Call mbc_master_create_serial with an mb_communication_info_t config, then register the Data Dictionary via mbc_master_set_descriptor before mbc_master_start. The app must also call uart_set_pin and uart_set_mode(UART_MODE_RS485_HALF_DUPLEX) itself, since the library does not configure RS485 pins.

How do I map CIDs to Modbus registers in the Data Dictionary?

Define a mb_parameter_descriptor_t array where each entry pairs a unique CID with slave address, register type, start, and size. Note mb_size is in registers (2 bytes) for Holding/Input and bits for Coil/Discrete, while param_size is in bytes.

Does esp-modbus v2 support Modbus TCP and IPv6?

Yes, esp-modbus v2 supports Modbus TCP over Wi-Fi or Ethernet with IPv4 or IPv6 via mbc_master_create_tcp and mbc_slave_create_tcp. The network interface must be up first, and the master's slave IP address table must end with a NULL entry.

Why does my Modbus master read fail with ESP_ERR_TIMEOUT 0x107?

ESP_ERR_TIMEOUT means the slave did not respond within the master's response timeout. Raise CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND or the per-instance response_tout_ms above the worst-case round-trip time, and verify RS485 wiring, RTS direction, and matching baud/parity settings.

Why is PARAM_TYPE_FLOAT_CDAB undeclared when building esp-modbus?

The extended PARAM_TYPE_*_ABCD/CDAB family and the mb_set_*/mb_get_* endianness helpers only exist when CONFIG_FMB_EXT_TYPE_SUPPORT=y. Enable it in sdkconfig or menuconfig, after which mb_endianness_utils.h is included automatically.

When should I not use esp-modbus for serial communication?

esp-modbus only implements the Modbus protocol on ESP-IDF with FreeRTOS, UART, and lwIP. It is not suitable for plain UART protocols, bare-metal projects without ESP-IDF, or non-Espressif platforms where stacks like libmodbus apply.