MQTT library, version 2.0.0 - FreeRTOS

MQTT library, version 2.0.0


You can use the FreeRTOS MQTT library to create applications that publish and subscribe to MQTT topics, as MQTT clients on a network. The FreeRTOS MQTT library implements the MQTT 3.1.1 standard for compatibility with the AWS IoT MQTT server. The library is also compatible with other MQTT servers.

The source files for the FreeRTOS MQTT library are located in freertos/.../mqtt. These files implement version 2.0.0 of the FreeRTOS MQTT library. FreeRTOS also includes a backward-compatibility layer for version 1.0.0 of the FreeRTOS MQTT library. For information about FreeRTOS MQTT version 1.0.0, see MQTT library, version 1.0.0.

Dependencies and requirements

The FreeRTOS MQTT library has the following dependencies:

The diagram below illustrates these dependencies.


The FreeRTOS MQTT library has the following features:

  • By default, the library has a fully asynchronous MQTT API. You can opt to use the library synchronously with the AwsIotMqtt_Wait function.

  • The library is thread-aware and parallelizable for high throughput.

  • The library features scalable performance and footprint. Use the configuration setting to tailor the library to a system's resources.

API reference

FreeRTOS and the AWS IoT Device SDK for Embedded C have the same MQTT v2.0.0 library APIs. For a full API reference, see MQTT (v2.0.0) C SDK API Reference.

Example usage

For example usage of the FreeRTOS MQTT library, see MQTT demo application defined in iot_demo_mqtt.c.

The MQTT demo demonstrates the subscribe-publish workflow of MQTT. After subscribing to multiple topic filters, the application publishes bursts of data to various topic names. As each message arrives, the demo publishes an acknowledgement message back to the MQTT server.

To use the MQTT demo, you must create a thing in AWS IoT, including a certificate and policy. For more information, see AWS IoT Getting Started.

Global demo configuration parameters

You must set values for the following constants in the freertos/demos/include/aws_clientcredential.h file:


Your AWS IoT endpoint.


The name of your IoT thing.


The SSID for your Wi-Fi network.


Your Wi-Fi password.


The type of security used by your Wi-Fi network.

You must also set values for the following constants in the freertos/demos/include/aws_clientcredential_keys.h file:


The certificate PEM associated with your thing.


The private key PEM associated with your thing.

MQTT demo configuration parameters

These configuration parameters apply to the MQTT demo.


The number of messages to publish in each burst.


The number of publish bursts in this demo.