Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 6814

MicroPython • Help with MQTT on Wiznet Pico board

$
0
0
I have a W5100S-EVB-Pico board, which has a Wiznet LAN chip, and I have the appropriate MP port flashed to it.
I have used Thonny to put the micropython umqtt.simple2 module on it, and then connected to an existing MQTT broker.
Then in the code I subscribed to "tasmota/discovery/+/config". I get a bunch of messages, and then I get an MQTT exception (1). This is apparently thrown when the host (broker) disconnects, I don't believe I get the number of messages that match what I am expected (as shown from a pi running mosquitto_sub.

I read that this can happen if your WLAN connection is flaky, but in this case, I am using a wired connection.
The connect/subscribe bit of the code looks like this:

Code:

    mqttClient = MQTTClient(CLIENT_ID, MQTT_BROKER, keepalive=20,user='barracus',password='fool')    mqttClient.set_callback(sub_cb)    mqttClient.connect()    mqttClient.subscribe(SUBSCRIBE_TOPIC)
My connect callback is relatively simple, it just dumps the topic, at present.

I am setting up the LAN connection as follows:

Code:

network.hostname('wiznet')nw = network.WIZNET5K()nw.active(False)nw.active(True)while not nw.isconnected():    time.sleep(1)print(nw.ifconfig())

Statistics: Posted by SteveSpencer — Wed Aug 20, 2025 5:17 pm — Replies 0 — Views 1



Viewing all articles
Browse latest Browse all 6814

Trending Articles