Getting Started with MQTT on Raspberry Pi Pico W - Connect to the Internet of Things!

Hey all, I’ve just shared a new guide for Raspberry Pi Pico W: “Getting Started with MQTT on Raspberry Pi Pico W - Connect to the Internet of Things!”



1 Like

Helllo Jacob, Good afternoon. I am following your guide to use uMQTT on pico. When I try to install uMQTT on pico using the Tools/Manage Packages, the following error occurs:

‘–upgrade-strategy’, ‘only-if-needed’, ‘micropython-umqtt.simple’, ‘–index-url’, ‘http://127.0.0.1:36628’]’ returned non-zero exit status 1.

This error is incured by me on multiple Picos, and others, see micropython-umqtt.simple does not install · Issue #2524 · thonny/thonny · GitHub which I have used to resolve this issue previously, but I am puzzled by why it works for Core Electronics but not for others? I would prefer to simply install from Manage Packages so welcome your advice?

Many thanks

1 Like

Hi @Peter45110,

Thanks for letting us know about this issue! This might be related to the Thonny version you have installed, can you let me know which version you have (via Thonny > Help > About Thonny)? For reference, we’re using v4.0.2.

thonny-version

Cheers,

Jacob

1 Like

Great write-up Jacob.

Thanks for making life easier!

1 Like

Hi Jacob,
Tried several methods of getting to this guide.They all end up with an error indicating the page doesn’t exist. Any suggestions?

Hi @Greg175980

Thanks for letting me know that the link to guide isn’t working! I’ve fixed the issue and the link should be working now: Getting Started with MQTT on Raspberry Pi Pico W - Connect to the Internet of Things! - Tutorial Australia

Please let me know if you continue to have issues accessing it.

Cheers,

Jacob

2 Likes

This drove me completely nuts.
I was ripping out software and configs left and right trying to solve it.
I LOST HAIR OVER IT! :smiley:

Oh no, I hope you didn’t lose too much hair @evan225047!!!

Did you end up solving the problem? And if so was it the Thonny version, or something else?

Cheers,

Jacob

1 Like

I’m getting an error 'NamError: name ‘mqtt_receive_topic’ isn’t defined for the subscribe module.

I’ve checked the syntax for all my code and it seems accurate, is anyone else receiving the same error? Note its only the subscribe code which isnt working, my publish code is operating without error.

Found it.

This section of the adafruit auth and feed topic details:

*# Fill in your Adafruit IO Authentication and Feed MQTT Topic details*
*mqtt_host = "io.adafruit.com"*
*mqtt_username = ""  # Your Adafruit IO username*
*mqtt_password = ""  # Adafruit IO Key*
*mqtt_publish_topic = ""  # The MQTT topic for your Adafruit IO Feed*

Should have
mqtt_receive_topic
NOT
mqtt_publish_topic

Welcome to the forums @Cameron43716, and thanks for letting us know about the typo in the guide!

I’ve fixed the incorrect variable name in the guide, the update will be reflected on the website shortly.

Thanks again!

2 Likes

Regarding the receive topic example I get as fas as waiting to receive from adafruit but that’s as far as I get. Toggling the switch and refreshing the page doesn’t help. Is there anything else that I should try? I’ve checked the code for syntax errors but it looks good.

Thanks for this guide - it is very useful for those of us getting started with MQTT on the Pico W. I’ve adapted you code to run on a local broker and it works well.
A quick suggestion re combining the functions of publishing and subscribing: your comments in the code mention using multiple threads. But it seems easier to use the mqtt_client.check_msg() function, which is just a non-blocking version of mqtt_client.wait_msg(). This allows both sending and receiving in one loop.

1 Like

Thanks for this guide but I’m stuck on downloading the umqtt.simple library using theThonny Manage Packages tool.
I get this error when I sellect “Install”:

ERROR: micropython-umqtt.simple from https://files.pythonhosted.org/packages/bd/cf/697e3418b2f44222b3e848078b1e33ee76aedca9b6c2430ca1b1aec1ce1d/micropython-umqtt.simple-1.3.4.tar.gz does not appear to be a Python project: neither ‘setup.py’ nor ‘pyproject.toml’ found.
Error: process returned with code 1

I’m using Thonny 4.1.2

I get the same error trying to download micropython-umqtt.simple2

Wish I could try it. Unfortunately, I have a Pico, not pico W.

Hi All,

I’ve just gone through this process, new pico w from the shop. installed thonny (v 4.1.4) and all that jazz. used Thonny to update the firmware and it looked good but had the exact same issue installing umqtt simple through the Thonny package manager.

have managed to find this page;
https://forums.raspberrypi.com/viewtopic.php?t=343443
where user HGRAUS supplied these commands which worked for me.

import mip
mip.install(‘umqtt.simple’)

upip used in other tutorials is superceeded by mip (upip to mip migration · micropython · Discussion #9565 · GitHub)

hope this helps!

2 Likes

Thanks for sending that through Ben!

We’ll update the guide with those changes, happy making!
Liam