How to connect 3 esp32 use Mqtt Broker HIveMQ

i have a final project from my camus,
the project is about make a otomatic irigation in a large field using 3 esp32 as a slave who are connect with a relay and a pump. and than there is one esp32 as a master to control all of the esp32.
and in this case i want to use hiveMQ as my broker.
can you help me about how to make the coding as master and slave and how to get the cloud from the hiveMQ ?

Hi @NurulMagfirah ,

It is great to see your interest in MQTT. Please be welcome to our community!

Have you decided if you want to host a HiveMQ broker on your own or you would first want to try the free HiveMQ Cloud version? You can create a free account here: https://console.hivemq.cloud

Once you have created a free account please follow to the “Getting Started” section where you find code examples for different platforms.

We do not have a ESP32 example, but we have one for Arduino here: HiveMQ Cloud

I hope this helps,
Dasha from HiveMQ Team

You don’t have ESP32 example but does it work with HiveMQ? how ?

Hi @shararku ,

Thanks for your question: The ESP8266 example will not work with ESP32. You can only look at it as a reference, but to work with ESP32 you will need to replace all ESP8266-specific libraries with ESP32-specific ones.

Kind regards,
Dasha from HiveMQ Team

thank you for your answer,
i will try your tips

Hello HiveMQ,
I will try to replace all ESP8266-specific libraries with ESP32-specific ones.
Best wishes
Sharar

Hello HiveMQ,
So i tried to “replace all ESP8266-specific libraries with ESP32-specific ones.” but i started to get more errors and more searches and google has no clue on how to go about it !
I hope you could clarify which #include to replace with which or some pointer to where the solution could be found .
Best wishes
Sharar

if i were you id look at ESPNOW

send the data collected by the slave to the master then connect the master to your broker and publish what ever you need!

Espnow is fairly easy to use and if you want check on the forum i did a small “how to” to connect the esp32 to HiveMQ and use NodeRed with it

Keep on coding my friend !

2 Likes