Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Updated Mar 2025

coreMQTT

MQTT C client library for small IoT devices (MCU or small MPU)

Introduction

The coreMQTT library is a client implementation of the MQTTexternal_link standard. The MQTT standard provides a lightweight publish/subscribeexternal_link messaging protocol that runs on top of TCP/IP and is often used in Machine to Machine (M2M) and Internet of Things (IoT) use cases.

The coreMQTT library is compliant with the MQTT 3.1.1external_link protocol standard. This library has been optimized for a low memory footprint. The design of this library embraces different use-cases, ranging from resource-constrained platforms using only QoS 0 (Quality of Service level 0) MQTT PUBLISH messages, to resource-rich platforms using QoS 2 MQTT PUBLISH over TLS (Transport Layer Security) connections. The library provides a menu of composable functions, a combination of which can be chosen to precisely fit a specific use case.

The library provides a high-level API to connect to an MQTT broker, subscribe or unsubscribe to a topic, publish a message to a topic and receive incoming messages. The library also exposes a low-level serializer/deserializer API. This low-level API handles formatting and parsing messages, leaving the application full, zero-overhead control over the network connection to the MQTT broker.

The library is decoupled from the underlying network drivers through a two-function send and receive transport interface. The application writer can select an existing transport interface or implement their own, as appropriate for their application.

The library is written in C and designed to be compliant with ISO C90external_link and MISRA C:2012external_link. The library has no dependencies on any additional libraries other than the standard C library. The library has proofsexternal_link showing safe memory use and no heap allocation, making it suitable for IoT microcontrollers, but also fully portable to other platforms.

When using MQTT connections in IoT applications, we recommend that you use a secure transport interface, such as one that uses the TLS protocol as demonstrated in the MQTT TLS demo.

This library can be freely used and is distributed under the MIT open source license.

Code Size of coreMQTT (example generated with GCC for ARM Cortex-M)

FileWith -O1 OptimizationWith -Os Optimization
core_mqtt.c4.0K3.4K
core_mqtt_state.c1.7K1.3K
core_mqtt_serializer.c2.8K2.2K
Total estimates8.5K6.9K