Embedded MQTT Broker

Async MQTT Broker and sync MQTTS Broker over TCP/TLS (mTLS), websockets and secure websocekt for embedded systems, specifically ESP32/ESP8266. Use FreeRTOS to advanced multitasking capabilities and Arduino core.

Internet of Things (IoT)C++MIT

Abstract

Embedded MQTT Broker is an open-source Internet of Things (IoT) project. Async MQTT Broker and sync MQTTS Broker over TCP/TLS (mTLS), websockets and secure websocekt for embedded systems, specifically ESP32/ESP8266. Use FreeRTOS to advanced multitasking capabilities and Arduino core. The broker uses an async, non-blocking core for TCP and WebSocket connections, while secure modes (mTLS and WSS) are implemented as synchronous due to the constraints and overhead of TLS-based security. This design balances performance and security for embedded use cases. It is built using C++, ESP32, ESP8266. Key capabilities include: only QOS 0; You can store 2.828KBytes in topics; One character is 1 byte, so You can use 2.828K characters. The complete source code is publicly available on GitHub under the MIT License, making it a useful reference for students building an Internet of Things (IoT) mini project or final-year project.

1. Introduction

The broker uses an async, non-blocking core for TCP and WebSocket connections, while secure modes (mTLS and WSS) are implemented as synchronous due to the constraints and overhead of TLS-based security. This design balances performance and security for embedded use cases.

const char ssid = "YOUR_SSID"; const char password = "YOUR_PASSWORD";

while (WiFi.status() != WL_CONNECTED) { delay(500); }

2. Objective

Async MQTT Broker and sync MQTTS Broker over TCP/TLS (mTLS), websockets and secure websocekt for embedded systems, specifically ESP32/ESP8266. Use FreeRTOS to advanced multitasking capabilities and Arduino core.

This project demonstrates how C++, ESP32, ESP8266 can be applied to a real-world Internet of Things (IoT) problem.

3. Key Features / Modules

  • only QOS 0
  • You can store 2.828KBytes in topics
  • One character is 1 byte, so You can use 2.828K characters
  • Communication protocols support:
  • WebSockets
  • TCP with mTLS
  • Secure Websockets (wss)

4. Technology Stack

C++ESP32ESP8266

5. System Requirements

General requirements for this technology stack — check the README for exact versions.

  • Arduino IDE / PlatformIO or a C++ compiler (g++)
  • Target board (e.g. Arduino, ESP32) where applicable
  • Git (to clone the repository)

6. Installation & Setup

git clone https://github.com/alexCajas/EmbeddedMqttBroker.git
cd EmbeddedMqttBroker
  1. simple-tcp-MqttBroker.ino: It show how to create, instantiate and use, a MqttBroker object over TCP protocol.
  2. secure-tcp-MqttBroker.ino: It show how to create, instantiate and use, a MqttBroker object over TCP with mTLS protocol.
  3. simple-websocket-MqttBroker.ino: It show how to create, instantiate and use, a MqttBroker object over WebSocket protocol. It includes a HTML MQTT-WebSocket client dashboard, for easy testing directly in a web browser.
  4. You can install this, from arduino library manager, searching embeddedmqttbroker.
  5. From platformIO using alexcajas/EmbeddedMqttBroker@^2.1.12
  6. Or downloading this repo and WrapperFreeRTOS, AsyncTCP, ESPAsyncWebServer manually.

Full setup instructions are in the project README.

7. Future Enhancements

Suggested extensions you can add to make this your own project.

  • Add a mobile dashboard using Blynk or Firebase
  • Store readings in a cloud database for history charts
  • Add alerts via SMS / Telegram when thresholds are crossed

8. Viva / Review Questions

Common questions examiners ask for projects in this domain.

  1. Which microcontroller / board and sensors are used and why?
  2. How does the device send data (Wi-Fi, MQTT, HTTP, Bluetooth)?
  3. Where is the sensor data stored and visualised?
  4. How is power consumption managed?
  5. How would you secure the device and its communication?

9. Source Code & License

This project is developed by alexCajas and published on GitHub under the MIT License. Please follow the license terms and credit the original author when you use or modify this code.

Want to build this as your internship project?

Work on an Internet of Things (IoT) project like this with mentor guidance, weekly reviews and an internship certificate from Training Trains, Erode — online or offline.

Apply for Internet of Things (IoT) Internship