Comments on: MicroPython – Getting Started with MQTT on ESP32/ESP8266 https://randomnerdtutorials.com/micropython-mqtt-esp32-esp8266/ Learn ESP8266, ESP32, Arduino, and Raspberry Pi Fri, 18 Jul 2025 15:25:08 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Sara Santos https://randomnerdtutorials.com/micropython-mqtt-esp32-esp8266/#comment-1070810 Fri, 18 Jul 2025 15:25:08 +0000 https://randomnerdtutorials.com/?p=78497#comment-1070810 In reply to ram.dev.

Hi.
Yes.
We also have our ESP-NOW getting started guide with MicroPython: https://randomnerdtutorials.com/micropython-esp-now-esp32/
We already have more tutorials planned about this subject.
Regards,
Sara

]]>
By: ram.dev https://randomnerdtutorials.com/micropython-mqtt-esp32-esp8266/#comment-1070777 Fri, 18 Jul 2025 14:22:51 +0000 https://randomnerdtutorials.com/?p=78497#comment-1070777 In reply to Sara Santos.

If what you need is a two way com between two ESP32, you may also consider using the ESPNow protocol… please refer to the doc
docs.micropython.org/en/latest/library/espnow.html#module-espnow

]]>
By: Jose Barbosa https://randomnerdtutorials.com/micropython-mqtt-esp32-esp8266/#comment-1001390 Mon, 20 Jan 2025 14:16:00 +0000 https://randomnerdtutorials.com/?p=78497#comment-1001390 In reply to Sara Santos.

Hi Sara, yesterday after some time reviewing it I found the missing piece:
MQTT_SSL = True # set to False if using local Mosquitto MQTT broker
I had understood “local” as being in the same machine, so I had this as True. Changed to False and it worked.

This was in here:
https://randomnerdtutorials.com/raspberry-pi-pico-w-mqtt-micropython/#:~:text=the%20umqtt%20folder.-,Publishing%20MQTT%20Messages,-In%20this%20example

Thank you !

]]>
By: Sara Santos https://randomnerdtutorials.com/micropython-mqtt-esp32-esp8266/#comment-1001344 Mon, 20 Jan 2025 09:46:47 +0000 https://randomnerdtutorials.com/?p=78497#comment-1001344 In reply to Jose Barbosa.

Hi.
I mean that you need to check if you’ve allowed the broker to receiver packets from other devices (you can do it with or without authentication). It’s explained in this section: https://randomnerdtutorials.com/how-to-install-mosquitto-broker-on-raspberry-pi/#mosquitto-no-authentication
Regards,
Sara

]]>
By: Jose Barbosa https://randomnerdtutorials.com/micropython-mqtt-esp32-esp8266/#comment-1001209 Sun, 19 Jan 2025 22:23:28 +0000 https://randomnerdtutorials.com/?p=78497#comment-1001209 In reply to Sara Santos.

Hi Sara, I have the same issue. Following your tutorials and get same error. I am using authentication and if I use two terminal windows in the main pi i get communication and no error.
When you mention “check if you allowed remote access to the broker” what do you mean exactly?

]]>
By: Sara Santos https://randomnerdtutorials.com/micropython-mqtt-esp32-esp8266/#comment-998340 Wed, 08 Jan 2025 15:04:59 +0000 https://randomnerdtutorials.com/?p=78497#comment-998340 In reply to Ramasamy.

Hi.
What exactly is not working?
You need to be more specific.
Regards,
Sara

]]>
By: Ramasamy https://randomnerdtutorials.com/micropython-mqtt-esp32-esp8266/#comment-998257 Wed, 08 Jan 2025 07:27:11 +0000 https://randomnerdtutorials.com/?p=78497#comment-998257 Below code is not working:

client_id = ubinascii.hexlify(machine.unique_id())

mqttClient =MQTTClient(
client_id=client_id,
server=”host goes here”,
port=12104,
user=”default”,
password= “password goes here”

)

topic_sub = b’notification’
topic_pub = b’hello’

def on_message_received(topic, msg):
print((topic, msg))

mqttClient.set_callback(on_message_received)
print(“trying connect”)
try:
mqttClient.connect()
client.subscribe(topic_sub)
print(“Connected with robust client!”)
except Exception as e:
print(“Connection failed:”, e)

]]>
By: Sara Santos https://randomnerdtutorials.com/micropython-mqtt-esp32-esp8266/#comment-843519 Wed, 28 Jun 2023 18:03:45 +0000 https://randomnerdtutorials.com/?p=78497#comment-843519 In reply to Allen.

Thanks for the tip.
Regards,
Sara

]]>
By: Allen https://randomnerdtutorials.com/micropython-mqtt-esp32-esp8266/#comment-843455 Wed, 28 Jun 2023 12:18:58 +0000 https://randomnerdtutorials.com/?p=78497#comment-843455 In reply to Bill.

I know this is old but I had this issue too. Here’s the fix: set keepalive to a nonzero number in the constructor in umqttsimple.py.

def init(self, client_id, server, port=0, user=None, password=None, keepalive=1 <<– THIS

github.com/micropython/micropython-lib/issues/466

]]>
By: Ozgur Karaaslan https://randomnerdtutorials.com/micropython-mqtt-esp32-esp8266/#comment-832866 Mon, 01 May 2023 15:56:12 +0000 https://randomnerdtutorials.com/?p=78497#comment-832866 If you take error with esp8266, you can add parameter “keepalive=60” while initilization of MQTTClient() class.

Like this: client = MQTTClient( [..other parameters..] , keepalive=60)

]]>