LiamBindle/MQTT-C
FreeA portable MQTT C client for embedded systems and PCs alike.
FreeFree tier
About LiamBindle/MQTT-C
MQTT-C is a portable MQTT v3.1.1 client library written in C, designed for embedded systems and PCs. It provides a transparent Platform Abstraction Layer (PAL) for easy porting to new platforms, is completely thread-safe while also suitable for single-threaded systems, and has a small footprint of less than 2000 lines of code across two source files. The library supports publish/subscribe messaging with quality of service (QoS) levels, and is ANSI C (C89) compatible, making it ideal for resource-constrained environments.
Key Features
Portable MQTT v3.1.1 client library written in C
Transparent Platform Abstraction Layer (PAL) for easy porting to new platforms
Thread-safe design, also suitable for single-threaded systems
Small footprint: two source files totaling less than 2000 lines
ANSI C (C89) compatible, compiles with any C compiler
Supports publish/subscribe messaging with quality of service (QoS) levels
Includes examples and pre-built documentation
Pros & Cons
Pros
- Lightweight and small codebase, easy to integrate
- Portable across many platforms with minimal effort
- Thread-safe but works on single-threaded systems
- Open source with permissive license
- Well-documented with API and PAL references
Best For
IoT and embedded systems requiring lightweight MQTT communicationMicrocontrollers and resource-constrained devicesPC applications needing a simple MQTT clientNetworking applications with high-latency or low data-rate links
FAQ
What is MQTT-C?
MQTT-C is a portable MQTT v3.1.1 client written in C, designed for embedded systems and PCs. It provides a transparent Platform Abstraction Layer (PAL) and is thread-safe with a small footprint.
How do I build MQTT-C?
MQTT-C consists of two source files (mqtt.c and mqtt_pal.c) that are ANSI C (C89) compatible. You can compile them with any C compiler and include mqtt.h. Alternatively, CMake or the provided Makefile can be used.
Is MQTT-C thread-safe?
Yes, MQTT-C is completely thread-safe, but it can also run on single-threaded systems.