Designing MQTT Topics for ESP-NOW + HiveMQ Integration

Hi everyone, I’m working on an IoT setup where ESP32 modules use ESPNOW to communicate locally (multi-node mesh). Then, one node publishes aggregated data to an MQTT broker via HiveMQ. I used this ESP‑NOW tutorial as a starting point for the local peer‑to‑peer protocol: https://www.theengineeringprojects.com/2022/01/esp-now-protocol-with-esp32-and-esp8266.html .It helped me grasp mesh setup and pairing logic.

My main question: how should I structure topics to clearly differentiate sensor-origin and mesh-node routing, while maintaining scalability and minimizing broker load? Any real-world examples or naming conventions you’d recommend?

Hello @ariaj

Welcome to the HiveMQ Community! While I’m not familiar with the ESPNOW protocol, sharing a sample of a topic layout that should scale well.

<layer>/<mesh_id>/<role>/<node_id>/<sensor>/<metric>

Sensor data: tele/greenhouse1/node/n05/soil/moisture
Mesh-link diagnostics: mesh/greenhouse1/node/n05/link/rssi

tele/# gives only the sensor readings, while mesh/# keeps routing chatter separate, so the broker isn’t forwarding unnecessary traffic.

Kind regards,
Diego from HiveMQ Team