Hi all,
I’m currently working on a DIY smart thermostat project using RT-Thread on an STM32 board. I’m able to handle temperature sensing and simple relays fine, but now I want to add Wi-Fi connectivity and MQTT support to integrate it with Home Assistant. I’m a bit unsure how best to manage multiple tasks like sensor polling, display updates, and MQTT messaging without running into timing issues or blocking calls.
Has anyone here built something similar using RT-Thread? Would love to hear how you structured your threads or used message queues/events for real-time responsiveness. Also curious which Wi-Fi modules play nicely with RT-Thread and are relatively easy to get up and running.
Here are a few resources I’ve been looking at:
https://www.youtube.com/watch?v=5v6zZLt-e-4
https://www.theengineeringprojects.com/2023/04/iot-based-smart-home-automation-using-esp32.html
https://www.rt-thread.io/document/site/#/getting_started/connectivity/mqtt/mqtt
https://www.emqx.io/blog/build-smart-home-with-mqtt-and-home-assistant
That sounds like a great project! For RT-Thread, a common approach is to separate responsibilities into different threads—for example, one thread for sensor polling, one for UI/display updates, and another dedicated to network/MQTT communication. Using message queues or event flags between threads can help avoid blocking and keep timing predictable. Also try to keep the MQTT client in its own thread so reconnects or network delays don’t interfere with sensor timing.
For Wi-Fi modules, many developers find ESP8266 or ESP32 modules fairly easy to integrate since there are plenty of examples and AT firmware options that work well with RT-Thread. You might also find this MQTT + Home Assistant guide useful for structuring your topics and automation:
https://www.home-assistant.io/integrations/mqtt/ basketball stars
I've seen https://www.youtube.com/watch?v=5v6zZLt-e-4/snake game
https://www.theengineeringprojects.com/2023/04/iot-based-smart-home-automation-using-esp32.html
I’ve experimented with a similar setup using RTOS-based IoT devices, and one pattern that works well is structuring the system around producer–consumer threads. For instance, the temperature sensor thread can act as the producer, pushing readings into a message queue, while an MQTT thread consumes that data and publishes it to Home Assistant.
A possible layout could be:
Nice setup—this kind of producer–consumer structure makes a lot of sense for keeping things responsive. Splitting tasks into separate threads like that is a clean approach, especially for MQTT and sensor handling https://www.youtube.com/watch?v=5v6zZLt-e-4/space waves