Download FreeRTOS

Quality RTOS & Embedded Software

Simplifying Authenticated Cloud Connectivity for Any Device.
Designing an energy efficient and cloud-connected IoT solution with CoAP.
Introducing FreeRTOS Kernel version 11.0.0:
FreeRTOS Roadmap and Code Contribution process.
OPC-UA over TSN with FreeRTOS.
The menu on the left links to demo projects suitable for learning to use the IoT MQTT library. Separately, the IoT Reference Integrations section demonstrates the library integrated into an application.

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


The coreMQTT library is a client implementation of the MQTT standard. The MQTT standard provides a lightweight publish/subscribe 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.1 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 C90 and MISRA C:2012. The library has no dependencies on any additional libraries other than the standard C library. The library has proofs 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)
File With -O1 Optimization With -Os Optimization
core_mqtt.c 4.1K 3.5K
core_mqtt_state.c 1.7K 1.3K
core_mqtt_serializer.c 2.8K 2.2K
Total estimates 8.6K 7.0K
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.