debevv/nanoMODBUS
FreeA compact MODBUS RTU/TCP C library for embedded/microcontrollers
About debevv/nanoMODBUS
nanoMODBUS is a compact C library that implements the Modbus protocol, designed specifically for embedded and resource-constrained systems like microcontrollers. It comprises only ~2000 lines of code, supports both RTU and TCP transports, and can operate as a client or server. The library offers a wide range of Modbus function codes, including read/write coils, registers, file records, and device identification. It is platform-agnostic, requiring only C99 and its standard library, and allows users to implement custom data transport read/write functions and CRC routines. The library avoids dynamic memory allocations and supports broadcast requests and responses. Installation is straightforward: copy the two source files (nanomodbus.c and nanomodbus.h) into the project, or integrate via CMake using FetchContent.
Key Features
Pros & Cons
- Extremely compact and lightweight (~2000 lines)
- No dynamic memory allocation makes it suitable for bare-metal systems
- Platform-agnostic; works with any C99-compatible compiler
- User-defined transport and CRC provide flexibility for various hardware
- Supports both RTU and TCP transports
- Broadcast message support
- Open-source and free (MIT license implied)
- Requires users to implement transport read/write functions (adds integration effort)
- Only supports RTU and TCP; no Modbus ASCII support
- Not a full-featured Modbus stack (e.g., no built-in device simulation beyond basic functions)