cancel
Showing results for 
Search instead for 
Did you mean: 

What is the easiest way to implement MQTT communication on STM32?

_AdamNtrx
Associate III

Hello!
I have a custom board with STM32F746VGT6 MCU, LAN8742A Eth PHY and Ethernet socket. I would like to implement MQTT communication in my project with my board as a client. I am familiar with LwIP and FreeRTOS and use both of these libraries in my current program.

I already tried using WolfSSL and WolfMQTT (and succeeded to some degree), but it wasn't very pleasant experience and I had to manually copy and change many files to make it work. I want to rewrite the MQTT implementation as the current one doesn't work very efficiently, but I don't really know where to start. 

I'm grateful for all suggestions!

3 REPLIES 3
MStackDev_376
Associate III

Hi,

You could consider using Mongoose. It is a networking library, designed to be used in embedded systems, with a focus on the STM32 devices, including the STM32F746 MCU. It has support for a considerable amount of networking protocols, including MQTT (up to version 5.0). The MQTT API is well documented and integrating Mongoose into your project is straightforward: you just need to copy the 2 source files, along with a few other simple tweaks and configurations and it will work! Also, there is no need to use LwIP (although Mongoose can work with it as well), since Mongoose comes with its own built-in TCP/IP network stack.

To get a better understanding on how to use Mongoose, you can try having a look at any of these tutorials. Simply run them in your Linux/Windows environment and inspect the code to get a feel on how to use the MQTT API in your applications.

Or if you want to test it directly on your board, there is this example of a Mongoose project running on the Nucleo-F746ZG board (auto-generated by the Mongoose Wizard tool), it also includes a simple MQTT client to which you can add your own logic to it. To download it to your computer, simply go to the Settings tab, select an empty directory where you want it to be stored and click the blue "Generate C/C++ button" in the upper corner. You can then build it and flash it to your board.

Heads up: I am part of the Mongoose development team, I hope this helps you with your project.

Andrew Neil
Super User

Some suggestions here from @STea:

https://community.st.com/t5/stm32-mcus-products/implementing-mqtt-in-stm32f407g/m-p/708959/highlight/true#M257880

 

PS:

From the MQTT.org website:

Getting started - Basic Concepts & Tutorials

MQTT Software - including loads of clients

 

#MQTT

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
_AdamNtrx
Associate III

Thank You for suggestions. I will read Your replies in the near future when I have more free time.