MQTT Client Firmware Example Code for Raspberry Pi Pico W
This project was built using Visual Studio Code running on Windows 11. Since the project builds x86 utilities, it is highly recommended that you install Visual Studio 2019 Build Tools (or later) and launch VS Code from a Visual Studio Developer command window by typing "code" at the command prompt. It may be necessary to delete the build directory that is generated by default and restart VS Code before attempting to build this project.
I based this example code off of some code originally written by Dirk Ziegelmeier. Since I couldn't really find any adequate example Pi Pico W code that publishes data, I added code that publishes a heartbeat counter to a Mosquitto MQTT server running on my Raspberry Pi 3B. I verified the published data using the MQTT Explorer client.
I highly recommend both the Mosquitto MQTT server and the MQTT Explorer client software.