The example on using MQTT for ESP32 does not incorporate any security. How do I incorporate some security in the messages so that only the authorized subscribers are allowed to read the messages.
I have a thread on the Forum that you can use as a reference: https://rntlab.com/question/how-to-use-cloud-mqtt-broker-with-esp32-using-async-mqtt-client-library/
In summary, you need to do the following. In the setup() function, you need to call the .setCredentials() method with your own username and password (MQTT broker):
I hope that helps.