Table of contents
If you've spent any time building smart home or IoT projects with ESPHome, you've probably noticed that most tutorials focus on the native Home Assistant API. For many makers, that's perfectly fine. The setup is simple, reliable, and works extremely well if Home Assistant is the center of your smart home.
But what happens when you want your ESP32 devices to communicate with more than just Home Assistant?
Maybe you're building a Node-RED workflow. Maybe you want to send sensor data to Grafana. Or perhaps you're creating a custom dashboard that needs to receive data from multiple devices. This is where MQTT enters the picture.
The good news is that ESPHome has built-in support for MQTT, allowing your devices to publish and receive data through an MQTT broker. Instead of being tied to a single platform, your devices can become part of a larger IoT ecosystem where different applications, dashboards, and automations all communicate using the same lightweight protocol.
In this guide, we'll explain how ESPHome MQTT integration works, how it differs from the native ESPHome API, and how to decide which approach makes the most sense for your project.
What is MQTT?
MQTT (Message Queuing Telemetry Transport) is a lightweight communication protocol designed for IoT devices and low-bandwidth networks. Instead of devices communicating directly with each other, they send and receive messages through an MQTT broker.
How MQTT works
MQTT follows a publish-subscribe model:
-
Publisher: Sends data (for example, an ESP32 temperature sensor)
-
Broker: Receives and distributes messages
-
Subscriber: Receives the data (such as Home Assistant, Node-RED, or a dashboard)
The flow typically looks like this:
ESP32 → MQTT Broker → Home Assistant / Node-RED / Dashboard
Why MQTT is popular for smart home projects
MQTT has become a standard in smart home and IoT environments because it is:
-
Lightweight and efficient
-
Reliable even on unstable networks
-
Compatible with multiple platforms
-
Easy to use for device-to-device communication
-
Well-suited for ESP32 and ESP8266 projects
This flexibility is one of the main reasons many makers choose MQTT when building larger or more complex automation systems.
What is ESPHome MQTT integration?
ESPHome supports two primary communication methods:
-
Native ESPHome API
-
MQTT
By default, most ESPHome devices communicate directly with Home Assistant using the native API. With MQTT enabled, the device publishes sensor data and status updates to an MQTT broker instead.
Other applications and devices can then subscribe to those MQTT topics and receive the data in real time.
For example, an ESPHome device can connect to an MQTT broker using the following configuration:
mqtt:
broker: 192.168.1.100
A temperature sensor might then publish data to topics such as:
home/livingroom/temperature
home/livingroom/humidity
This allows Home Assistant, Node-RED, dashboards, and other MQTT-compatible applications to access the same data through the broker.
ESPHome API vs MQTT
Both the ESPHome API and MQTT are reliable ways to connect ESPHome devices, but they are designed for slightly different use cases.
The native ESPHome API is optimized for Home Assistant and provides a simple setup experience. MQTT requires a bit more configuration but offers greater flexibility, especially if you're integrating multiple platforms or services.
|
Feature |
ESPHome API |
MQTT |
|
Home Assistant integration |
Excellent |
Excellent |
|
Setup complexity |
Easier |
Moderate |
|
Third-party platform support |
Limited |
Excellent |
|
Node-RED compatibility |
Good |
Excellent |
|
Cloud integrations |
Limited |
Strong |
|
Network traffic |
Low |
Low |
|
Flexibility |
Good |
Excellent |
When should you use the ESPHome API?
The native ESPHome API is usually the best choice if:
-
You primarily use Home Assistant
-
You want the simplest setup process
-
You don't need third-party integrations
-
You're new to ESPHome
When is MQTT the better option?
MQTT is often a better fit if:
-
You use Node-RED alongside Home Assistant
-
You want to connect multiple IoT platforms
-
You need cloud integrations
-
You're building a larger or more complex automation system
How to set up MQTT in ESPHome
Setting up MQTT in ESPHome is straightforward once you have an MQTT broker running on your network. The process typically involves connecting ESPHome to the broker, configuring your devices, and verifying that messages are being published correctly.
Step 1: Install an MQTT broker
Before ESPHome can send or receive MQTT messages, you'll need an MQTT broker.
Popular options include:
-
Mosquitto
-
EMQX
-
HiveMQ
Many Home Assistant users choose Mosquitto because it's easy to install and integrates well with existing smart home setups.
Step 2: Add MQTT to your ESPHome configuration
Next, add an MQTT section to your ESPHome YAML file:
mqtt:
broker: 192.168.1.100
username: mqtt_user
password: mqtt_password
Here's what each setting does:
-
broker: The IP address or hostname of your MQTT broker
-
username: MQTT username (if authentication is enabled)
-
password: MQTT password (if authentication is enabled)
After saving the configuration, upload it to your device.
Step 3: Configure sensors and devices
Once MQTT is enabled, ESPHome will automatically publish data from configured sensors and components.
For example, a temperature or humidity sensor can publish readings to MQTT topics that other applications can subscribe to.
The exact topics depend on your device name and configuration, but they typically follow a structured format such as:
home/livingroom/temperature
home/livingroom/humidity
Step 4: Verify MQTT messages
After uploading the configuration, confirm that your device is successfully publishing data.
Popular tools for monitoring MQTT traffic include:
-
MQTT Explorer
-
MQTTX
-
Home Assistant MQTT integration
If you can see your topics and sensor values updating, your ESPHome MQTT integration is working correctly. From there, you can begin using the data in Home Assistant, Node-RED, dashboards, or other MQTT-compatible applications.
Best ESP32 boards for ESPHome MQTT projects
While ESPHome and MQTT work with a wide range of ESP32 boards, choosing the right hardware can make your projects more reliable, efficient, and easier to expand in the future.
NULA Mini ESP32-C6
For makers building smart home devices, sensors, dashboards, and other connected projects, the is an excellent choice.
The board combines the flexibility of the ESP32 platform with modern connectivity features, making it well-suited for ESPHome and MQTT-based deployments.
Some of its key advantages include:
-
Wi-Fi 6 support for improved wireless connectivity
-
Low power consumption for always-on IoT devices
-
Compact form factor for space-constrained projects
-
Excellent compatibility with ESPHome
-
Reliable MQTT communication for smart home automation
Whether you're building a temperature sensor, energy monitor, environmental station, or a larger network of connected devices, the NULA Mini ESP32-C6 provides the performance and wireless capabilities needed to keep your MQTT ecosystem running smoothly.
Why Soldered boards are ideal for ESPHome MQTT projects
For many makers, the native ESPHome API is the easiest way to connect devices to Home Assistant. It requires minimal configuration and works exceptionally well in Home Assistant-focused smart homes.
However, MQTT becomes a powerful alternative when you want greater flexibility. By using an MQTT broker, ESPHome devices can share data with Home Assistant, Node-RED, dashboards, cloud services, and other MQTT-compatible applications at the same time.
The good news is that you don't have to choose one approach forever. ESPHome supports both communication methods, allowing you to start with a simple setup and expand as your smart home or IoT projects become more advanced.
With maker-friendly boards such as the , Soldered provides a flexible platform for experimenting with ESPHome, MQTT, and modern IoT development. Whether you're building your first smart sensor or a larger automation system, you have the hardware, documentation, and support needed to bring your ideas to life.
ESPHome MQTT: FAQs
Does ESPHome support MQTT?
Yes. ESPHome includes built-in MQTT support, allowing devices to publish and receive messages through an MQTT broker such as Mosquitto, EMQX, or HiveMQ.
Should I use ESPHome API or MQTT?
If you're only using Home Assistant, the native ESPHome API is usually the easiest option. If you want to integrate Node-RED, custom dashboards, cloud services, or multiple platforms, MQTT is often the better choice.
What is ESPHome MQTT integration?
ESPHome MQTT integration allows ESPHome devices to communicate through an MQTT broker instead of relying solely on the native ESPHome API. This enables sensor data and device states to be shared across multiple applications and services.
How do I connect ESPHome to MQTT?
You can connect ESPHome to MQTT by adding an MQTT section to your ESPHome configuration and specifying your broker address, username, and password.
What MQTT broker should I use with ESPHome?
Mosquitto is the most popular MQTT broker for ESPHome projects due to its simplicity and strong Home Assistant integration. Other popular options include EMQX and HiveMQ.
Can ESPHome work without Home Assistant?
Yes. ESPHome devices can communicate directly through MQTT, making them suitable for Node-RED, custom dashboards, cloud platforms, and other IoT systems without requiring Home Assistant.
Is MQTT faster than the ESPHome API?
For most smart home projects, the performance difference is negligible. The choice is usually based on flexibility and integration requirements rather than speed.