- edited description
- changed title to MQTT on PicoW
Add MQTT support for PicoW
The wiki HTTP server page states: to access the server on http://127.0.0.0/6437. It should be http://127.0.0.0:6437.
I also tried the MQTT library with MQTT example on a PicoW…which gives the following error.
Comments (17)
-
repo owner -
repo owner - changed title to MQTT not supported on PicoW
-
repo owner Thanks for noticing the URL error on the Wiki page. That's now fixed.
MQTT is not yet supported on the Pico W.
When I last checked (in July) there was not yet an Arduino C++ library for MQTT that we could use to add MicroBlocks support. However, I see that MicroPython now has MQTT support for the Pico W so things may have changed since then. I'll take another look.
-
repo owner - changed title to Add MQTT support for PicoW
-
reporter John, thank you.
-
reporter Sorry…has to be: http://127.0.0.0/6473 instead of http://127.0.0.0:6473
-
repo owner I don't think so. The 6473 is the port number, not a path.
In Chrome, this URL:
http://127.0.0.1:6473/
Shows the HTTP server web page:
but this one:
http://127.0.0.1/6473
Says the site cannot be reached. Does the second URL work for you? If so, what browser are you using?
-
repo owner But you were correct -- there was a typo on the Wiki page, now fixed.
-
reporter In my case it is just the opposite: http://192.168.1.27/6473 works from Chrome. This http://192.168.1.27:6473 is not working “site can’t be reached”
-
repo owner We may be talking about two different HTTP servers.
I am talking about running the HTTP server in the MicroBlocks IDE using this menu command:
Is that the one you are talking about?
It is also possible to run an HTTP server on a WiFi enabled board. In that case, the default port is port 80, so using ":6473" would give a "site cannot be reached".
-
reporter The start HTTP SERVER confuses me, I didn’t have to start a server on my setup (PicoW, DHT11 connected to a power bank). I think it has something to do when components are using the same wifi network. Could the PicoW create or have its own web address? Still have to use: http://127.0.0.0/6473 with a slash and it even works with http://127.0.0.0. MQTT would be more straightforward and more save.
-
repo owner Ahh, I think I see.
I believe you are not actually connecting to your Pico W when you fetch http://127.0.0.0/6473. As a test, if you disconnect and power down your Pico W, do you still get a response to that URL?
I think you may be connecting to an HTTP server running on your local machine. MacOS has a built-in Apache server that is sometimes enabled by default. At least, it was on my recently purchased MacBook, which was very confusing! If you are running MacOS, that could be what you are connecting to. Windows and Linux may have similar built-in HTTP servers.
The PicoW can run an HTTP server written in MicroBlocks using the HTTP library. Here's a simple example:
If you download the above image to your desktop, you can then drag-and-drop it onto the MicroBlocks window to import that script. (Note: It doesn't work to drag the image directly from the web browser; you need to download it.)
If you run the above script on your Pico, you should be able to connect to it. You will need to add the name and password for your WiFi network, of course. You will also need to know the IP address of the PicoW. That will be displayed in the MicroBlocks window when it first connects to the WiFi network. You can also click the:
block from the WiFi library to get the address. That is the IP address you should use in the URL. You do not need to use the port number, so your URL will look something like this:
http://192.168.12.17/
but with your Pico W's IP address.
-
repo owner Good news! MQTT support for the Pico-W was easier than expected. It will be in the next Pilot release which should be out next week.
-
reporter Very nice, making sensors on a distance more easily accessible. Looking forward to try this new release.
-
repo owner MQTT support for the Pico-W is included in the latest MicroBlocks Pilot release. (It is also in the stable webapp release.) You'll need to update your Pico-W firmware to v171 to use the MQTT library.
-
repo owner - changed status to resolved
-
reporter I gave it a try, thanks John now I can publish my sensor with MicroBlocks mqtt and subscribe to it from Snap!
- Log in to comment