How do I connect my ESP32 to the broker using "Your Clusters" section?

I have this section in my Arduino IDE code, but I’m experiencing problems to maintain connected the ESP32 it is connecting and disconnecting in an intermittent way, so I was wondering if I can use “Your Clusters” section to maintain connected the ESP32 to the broker.

// Protocol Variables

const char* ssid = “INFINITUM”;

const char* password = “aaaaaaaaaa”;

const char* mqttUserName = “user”;

const char* mqttPwd = “user2024”;

const char* clientID = “username2024”;

const char* topic = “ESP32/data”;

const char* topic2 = “ESP32/signals”;

char* mqttServer = “broker.hivemq.com”;

int mqttPort = 1883;

Hello @caveadventurer,

Greetings and a warm welcome to the HiveMQ Community! We sincerely appreciate your enthusiasm for MQTT and the HiveMQ broker. It’s wonderful to have new users like yourself on board.

I recommend giving the example provided a try, as it has been successfully confirmed by other members of our community. You can find the details here: Link to ESP32 example

Should you have any further questions or if there’s anything else you need assistance with, please feel free to let me know. We’re here to help.

Warm regards,
Dasha from HiveMQ Team

Hello,
I installed the following code you suggested me “Connecting ESP 32 CAM with Hive MQ Cloud” in my ESP32 through Arduino IDE, and it worked. So I wonder if what is missing to connect my ESP32 using my own code, I need to include the “HiveMQ Cloud Let’s Encrypt CA Certificate”?

I already got connected to the MQTT broker, thank you.
WiFi connected

IP address:

192.168.1.64

MQTT Connected

Topic Subscribed