Hello,
following your lessons in the ebook “MicroPython Programming with ESP32 and ESP8266”, in the chapter MQTT – Establishing a Two-way Communication you present code for a MQTT broker without authentication (no username, no password). Could you please provide a code snippet for the case with authentication? I tried it by myself but my python skills are not good enough. I didn’t find the place where to insert the information.
Thanks in advance!
Hi.
When initializing an MQTT client, instead of:
client = MQTTClient(client_id, mqtt_server)
You use:
client = MQTTClient(client_id, mqtt_server, user=YOUR_USERNAME, password=YOUR_PASSWORD)
replace with your username and password. For example:
client = MQTTClient(client_id, mqtt_server, user="sara", password="12345")
Let me know if this works.
Regards,
Sara
Hello Sara,
thank you very much for your prompt answer.
Btw: I tried the scripts (without authentication) for ESP #1 importing from umqtt.simple (the built in module included in micropython) instead of using umqttsimple.py and it worked!. Just for your information.
Regards.
Ok.
Thanks for letting me know.
Tell me if you need help with anything else.
Regards,
Sara
Hello Sara,
the statement with credentials (user, password) for the MQTT broker works, thanks again.
Regards.