finds.dev

alejoseb/Modbus-STM32-HAL-FreeRTOS

Modbus TCP and RTU, Master and Slave for STM32 using Cube HAL and FreeRTOS

View on GitHub

★ 789CLGPL-2.1updated May 2026

// the take

A Modbus RTU/TCP master and slave library for STM32 microcontrollers, built on top of ST's Cube HAL and FreeRTOS. It's a port of the Arduino Modbus library, covering USART, DMA, USB-CDC, and TCP transports across a wide range of STM32 boards. Aimed at embedded developers who need Modbus in an industrial or PLC context without building from scratch.

Multiple concurrent instances per MCU — one UART per instance, limited only by hardware. DMA mode with idle-line detection handles up to 2 Mbps without burning CPU on every byte. The newer separate memory regions model maps coils/DI/HR/IR to independent arrays with configurable Modbus start addresses, which finally makes standard address space partitioning (0x, 1x, 3x, 4x) actually feasible. Pymodbus Jupyter notebooks for testing are a genuine timesaver — no need to stand up a separate test rig just to validate register reads.

Modbus.c is over 1200 lines and the author calls it out as a known mess in the TODO list — it's been that way for a while with no sign of a split happening soon. USB-CDC support is locked to the F103 Bluepill and explicitly not validated on anything else, which is an odd limitation to leave unfixed for a mature library. TCP relies on lwIP via CubeMX, and there's a known bug where the stack stops working if the Ethernet cable isn't connected at boot — requiring manual patches to generated code, which means your port is fragile across CubeMX regenerations. No unit tests anywhere in the repo; correctness is validated entirely through hardware examples, which makes it risky to adopt without your own validation harness.

We read the README, the directory tree and a key source file in June 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
789
Forks
231
Language
C
License
LGPL-2.1
Last commit
21 May 2026

// nearby

If Modbus-STM32-HAL-FreeRTOS isn't quite it.

All repos →