News How to Send and Receive Data Using Raspberry Pi Pico W and MQTT

Aug 1, 2022
1
0
10
For the last subscribe loop, aren't you just subscribing over and over? Don't you only want to do that once? Shouldn't you be calling client.wait_msg() instead?
 
Sep 2, 2022
2
0
10
Hi, I'm following this guide trying to connect to HiveMQ Cloud. But to be able to do this, in MQTTClient(...) the username, password, and SSL are required. Were you able to achieve this, or did you connect to a local HiveMQ where this is not required?
 
Oct 12, 2022
1
0
10
Looks like you need to use mip instead of upip for package management in MicroPython now.
 
Oct 30, 2022
2
0
10
For the last subscribe loop, aren't you just subscribing over and over? Don't you only want to do that once? Shouldn't you be calling client.wait_msg() instead?

I agree, the subscription before the loop and then wait_msg or check_msg. The only thing then is to ping the broker once in a while (if you set a keep alive interval)
 
Nov 14, 2022
1
0
10
Hi there,

I'm facing the following problem using a Pico W with firmware v1.19.1 (2022-06-18) .uf2 (latest stable version).
Eeach time I try to install the module, I'm facing a error message (AssertionError) that seems to be related to the fact that I can't download the package.

Code:
...
AssertionError
----------------------------------------
  WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))': /micropython-umqtt-simple/micropython-umqtt.simple-1.3.4.tar.gz/
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 50406)
Traceback (most recent call last):
  File "C:\Users\david\AppData\Local\Programs\Thonny\lib\socketserver.py", line 316, in _handle_request_noblock
    self.process_request(request, client_address)
  File "C:\Users\david\AppData\Local\Programs\Thonny\lib\socketserver.py", line 347, in process_request
    self.finish_request(request, client_address)
  File "C:\Users\david\AppData\Local\Programs\Thonny\lib\socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "C:\Users\david\AppData\Local\Programs\Thonny\lib\site-packages\thonny\vendored_libs\pipkin\proxy.py", line 204, in __init__
    super().__init__(request, client_address, server)
  File "C:\Users\david\AppData\Local\Programs\Thonny\lib\socketserver.py", line 747, in __init__
    self.handle()
  File "C:\Users\david\AppData\Local\Programs\Thonny\lib\http\server.py", line 432, in handle
    self.handle_one_request()
  File "C:\Users\david\AppData\Local\Programs\Thonny\lib\http\server.py", line 420, in handle_one_request
    method()
  File "C:\Users\david\AppData\Local\Programs\Thonny\lib\site-packages\thonny\vendored_libs\pipkin\proxy.py", line 211, in do_GET
    self._serve_file(*path.split("/"))
  File "C:\Users\david\AppData\Local\Programs\Thonny\lib\site-packages\thonny\vendored_libs\pipkin\proxy.py", line 245, in _serve_file
    tweaked_bytes = self._tweak_file(dist_name, file_name, original_bytes)
  File "C:\Users\david\AppData\Local\Programs\Thonny\lib\site-packages\thonny\vendored_libs\pipkin\proxy.py", line 312, in _tweak_file
    assert normalize_dist_name(wrapper_dir).startswith(normalize_dist_name(dist_name))
AssertionError
----------------------------------------
ERROR: Could not install packages due to an OSError: HTTPConnectionPool(host='127.0.0.1', port=36628): Max retries exceeded with url: /micropython-umqtt-simple/micropython-umqtt.simple-1.3.4.tar.gz/ (Caused by ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')))

Error Command '['C:\\Users\\david\\AppData\\Local\\pipkin\\cache\\workspaces\\1cfce2a77f6f02c67b4668b85385fc05\\Scripts\\python.exe', '-I', '-m', 'pip', '--no-color', '--disable-pip-version-check', '--trusted-host', '127.0.0.1', 'install', '--no-compile', '--use-pep517', '--upgrade-strategy', 'only-if-needed', 'micropython-umqtt.simple==1.3.4', '--index-url', 'http://127.0.0.1:36628']' returned non-zero exit status 1.

I've tried to install related packages (simple2, robust, robust2) but I'm still facing the same problem...

Does anybody has an idea on how to deal with this problem ?

Regards,
David
 
Oct 30, 2022
2
0
10
Hi there,

I'm facing the following problem using a Pico W with firmware v1.19.1 (2022-06-18) .uf2 (latest stable version).
Eeach time I try to install the module, I'm facing a error message (AssertionError) that seems to be related to the fact that I can't download the package.

Code:
...
AssertionError
----------------------------------------
  WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))': /micropython-umqtt-simple/micropython-umqtt.simple-1.3.4.tar.gz/
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 50406)
Traceback (most recent call last):
  File "C:\Users\david\AppData\Local\Programs\Thonny\lib\socketserver.py", line 316, in _handle_request_noblock
    self.process_request(request, client_address)
  File "C:\Users\david\AppData\Local\Programs\Thonny\lib\socketserver.py", line 347, in process_request
    self.finish_request(request, client_address)
  File "C:\Users\david\AppData\Local\Programs\Thonny\lib\socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "C:\Users\david\AppData\Local\Programs\Thonny\lib\site-packages\thonny\vendored_libs\pipkin\proxy.py", line 204, in __init__
    super().__init__(request, client_address, server)
  File "C:\Users\david\AppData\Local\Programs\Thonny\lib\socketserver.py", line 747, in __init__
    self.handle()
  File "C:\Users\david\AppData\Local\Programs\Thonny\lib\http\server.py", line 432, in handle
    self.handle_one_request()
  File "C:\Users\david\AppData\Local\Programs\Thonny\lib\http\server.py", line 420, in handle_one_request
    method()
  File "C:\Users\david\AppData\Local\Programs\Thonny\lib\site-packages\thonny\vendored_libs\pipkin\proxy.py", line 211, in do_GET
    self._serve_file(*path.split("/"))
  File "C:\Users\david\AppData\Local\Programs\Thonny\lib\site-packages\thonny\vendored_libs\pipkin\proxy.py", line 245, in _serve_file
    tweaked_bytes = self._tweak_file(dist_name, file_name, original_bytes)
  File "C:\Users\david\AppData\Local\Programs\Thonny\lib\site-packages\thonny\vendored_libs\pipkin\proxy.py", line 312, in _tweak_file
    assert normalize_dist_name(wrapper_dir).startswith(normalize_dist_name(dist_name))
AssertionError
----------------------------------------
ERROR: Could not install packages due to an OSError: HTTPConnectionPool(host='127.0.0.1', port=36628): Max retries exceeded with url: /micropython-umqtt-simple/micropython-umqtt.simple-1.3.4.tar.gz/ (Caused by ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')))

Error Command '['C:\\Users\\david\\AppData\\Local\\pipkin\\cache\\workspaces\\1cfce2a77f6f02c67b4668b85385fc05\\Scripts\\python.exe', '-I', '-m', 'pip', '--no-color', '--disable-pip-version-check', '--trusted-host', '127.0.0.1', 'install', '--no-compile', '--use-pep517', '--upgrade-strategy', 'only-if-needed', 'micropython-umqtt.simple==1.3.4', '--index-url', 'http://127.0.0.1:36628']' returned non-zero exit status 1.

I've tried to install related packages (simple2, robust, robust2) but I'm still facing the same problem...

Does anybody has an idea on how to deal with this problem ?

Regards,
David

umqtt.simple is literally one file. Download and save on the pico and you are good to go.
 
Dec 15, 2022
1
0
10
I tried to install umqtt.simple with an ubuntu laptop and with a raspberry pi 4, for use with Thonny.
Both attempts failed for different reasons.
The following steps worked for me:
  1. Visit https://pypi.org/project/micropython-umqtt.simple/#files
  2. Download micropython-umqtt.simple-1.3.4.tar.gz
  3. Extract simple.py from micropython-umqtt.simple-1.3.4/umqtt in the tar.gz file
  4. Copy simple.py to your Thonny project, and save it to your pico w board
  5. Use the following import in your mqtt-pub.py and mqtt-sub.py files:
from simple import MQTTClient
I hope this might be useful to other readers.