finds.dev← search

// the find

debevv/nanoMODBUS

★ 861 · C · MIT · updated Feb 2026

A compact MODBUS RTU/TCP C library for embedded/microcontrollers

nanoMODBUS is a single-file C99 MODBUS RTU/TCP library targeting microcontrollers and embedded systems. At ~2000 lines with no dynamic allocation, it fits on bare-metal targets like STM32 and RP2040. If you're wiring a microcontroller to industrial sensors or PLCs, this is a practical starting point.

Zero dynamic allocation — the entire state lives in a caller-provided nmbs_t struct, which is the right call for MCUs where heap fragmentation is a real problem. Transport layer is fully user-supplied via function pointers, so it works equally on UART, TCP, or anything else without ifdefs inside the library. Fine-grained compile-time stripping via preprocessor defines lets you shave every unused function code off the final binary, which matters on 32KB flash targets. The examples actually cover real hardware (STM32, RP2040, Arduino) with working CMake and platform port files, not just toy Linux demos.

No thread-safety story — the library is explicitly single-instance-per-context, so multi-threaded use (e.g. FreeRTOS tasks) requires external locking the user has to figure out themselves, with no guidance in the docs. The server model is callback-based and synchronous; there's no async dispatch or queuing, which means a slow server callback blocks the entire receive loop and can cause RTU timeouts in practice. Exception codes beyond the standard set are not configurable — if your target device returns vendor-specific exception codes, you'll get a generic error with no way to distinguish them. The test suite runs only on Linux with a loopback transport; there are no hardware-in-the-loop tests, so timing-sensitive RTU edge cases on actual UARTs are essentially untested by the project itself.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →