To exchange messages between two Raspberry Pi Pico W boards, connect both boards to Wi-Fi and have each run an MQTT client that connects to the same MQTT broker. One board publishes to a topic; the other subscribes to that topic. The broker—not Wi-Fi alone—routes matching messages between them.
How MQTT connects two Pico W boards
MQTT is a client-server publish/subscribe messaging protocol. Each Pico W acts as an MQTT client, while the broker is the server and rendezvous point. A publisher sends a message with a topic name, and the broker forwards it to clients whose subscriptions match that topic.
A typical arrangement looks like this:
- Pico A: joins Wi-Fi, connects to the broker, and publishes a message.
- Pico B: joins the same Wi-Fi network, connects to the same broker, and subscribes to the publisher’s topic.
- Broker: accepts both client connections and routes the published message to matching subscribers.
The boards do not need a direct radio link to one another. The OASIS MQTT Version 3.1.1 specification defines MQTT as “a Client Server publish/subscribe messaging transport protocol.”
What you need
- Two Raspberry Pi Pico W boards and a Wi-Fi network they can both reach. Pico W includes single-band 2.4 GHz Wi-Fi; the non-wireless Raspberry Pi Pico does not have that radio. See Raspberry Pi’s Pico-series documentation.
- An MQTT broker reachable from the network, plus its hostname or address, port, and any required username, password, or transport-security settings. These details depend on the broker you choose.
- Firmware and an MQTT client for each board. No sensor, debug probe, or special MQTT accessory is needed just to exchange messages.
The Pico W uses an RP2040 microcontroller and has 264 kB SRAM and 2 MB onboard flash, according to Raspberry Pi’s current Pico W documentation (accessed 2026). Pico WH is the header-equipped variant; headers are useful for wiring peripherals, but they do not change the basic MQTT architecture. Raspberry Pi describes the board variants in its Pico-series product documentation.
Recommended Free Tools
#1 Best Overall
- RPi Pico 2 W Microcontroller Board (pre-soldered header (color-coded)), Based on Official RP2350 Chip, Dual-core & Dual-architecture Design. Upgraded hardware from Pico 2 with wireless communication, onboard antenna, features 2.4GHz 802.11n WIFI and Bluetooth 5.2.
- Adopts unique dual-core and dual-architecture design: dual-core Arm Cortex-M33 processor and dual-core Hazard3 RISC-V processor, flexible clock running up to 150 MHz.
- Onboard Infineon CYW43439 wireless chip, supports WIFI 4 wireless and Bluetooth 5.2.
- 520KB of SRAM, and 4MB of on-board Flash memory.
- Castellated module allows soldering direct to carrier boards. USB 1.1 with device and host support. Low-power sleep and dormant modes. Drag-and-drop programming using mass storage over USB.
Choose a programming path
| Path | What the documented sources establish | What you will handle |
|---|---|---|
| C/C++ with the Pico SDK | Raspberry Pi’s SDK examples repository includes picow_mqtt_client, described as an MQTT client application. See the Pico examples repository. |
Build and adapt the example for your broker, Wi-Fi network, topics, and message behavior. |
MicroPython with umqtt.simple |
The documented lightweight client supports QoS 0 and QoS 1 for publishing and subscribing, and provides blocking and non-blocking message-processing methods. See the umqtt.simple documentation. | Connect Wi-Fi and MQTT separately, process incoming packets in your application, and decide how to recover from connection loss. |
These are practical choices, not a performance ranking: the cited sources do not establish a controlled comparison of speed or memory use. Choose based on whether you prefer the Pico SDK’s C/C++ example or MicroPython’s lightweight client and are comfortable implementing the required message loop and recovery behavior.
Set up the broker and topic plan
Before changing board code, obtain the broker connection details. The broker may require authentication or TLS, and its settings are not universal. Keep credentials private, and do not treat an unauthenticated public broker as suitable for real devices. The sources cited here do not provide a broker-specific TLS recipe for MicroPython’s umqtt.simple.
Rank #2
- IoT Starter Kit for Beginners: The SunFounder Raspberry Pi Pico W Ultimate Starter Kit offers a rich IoT learning experience for beginners aged 8+. With 450+ components, 117 projects, and expert-led video lessons, this kit makes learning microcontroller programming and IoT engaging and accessible, RoHS Compliant
- Expert-Guided Video Lessons: This kit includes 27 video tutorials by the renowned educator, Paul McWhorter. His engaging style simplifies complex concepts, ensuring an effective learning experience in microcontroller programming
- Wide Range of Hardware: The kit includes a diverse array of components like sensors, actuators, LEDs, LCDs, and more, enabling you to experiment and create a variety of projects with the Raspberry Pi Pico W
- Supports Multiple Languages: The kit offers versatility with support for three programming languages - MicroPython, C/C++, and Piper Make, providing a diverse programming learning experience
- Dedicated Support: Benefit from our ongoing assistance, including a community forum and timely technical help for a seamless learning experience
Choose a clear topic shared by both programs. For example, the publisher could send to home/pico-a/message, and the subscriber could subscribe to exactly that topic. This path is an example, not a required MQTT convention. If you use a broader topic filter, confirm that it matches the publisher’s topic and does not receive unrelated messages.
Connect each Pico W to Wi-Fi
Wi-Fi connectivity comes before MQTT connectivity. Raspberry Pi’s MicroPython guide uses the station interface, activates it, and calls connect() with the network name and password. Check the connection status before trying to contact the broker; joining Wi-Fi does not itself establish an MQTT session.
Rank #3
- With a large on-chip memory, symmetric dual-core processor complex, deterministic bus fabric, and rich peripheral set augmented with our unique Programmable I/O (PIO) subsystem, RP2040 provides professional users with unrivalled power and flexibility
- RP2040 is manufactured on a modern 40nm process node, delivering high performance,low dynamic power consumption, and low leakage, with a variety of low-power modes tosupport extended-duration operation on battery power
- Pi Pico W offers 2.4GHz 802.11 b/g/n wireless LAN support and Bluetooth5.2, with an on-board antenna, and modular compliance certification. It is able to operatein both station and access point modes. Full access to network functionality is available to both C and MicroPython developers
- Pi Pico W pairs RP2040 with 2MB of flash memory, and a power supply chip supporting input voltages from 1.8 -5.5V. It provides 26 GPIO pins, three of which can function as analogue inputs, on 0.1"-pitch through-hole pads with castellated edges
- A polished MicroPython port, and a UF2 bootloader inROM, it has the lowest possible barrier to entry for beginner and hobbyist users; Pi Pico W is available as an individual unit, or in 480-unit reels for automated assembly
- Load MicroPython firmware appropriate for the Pico W and open a REPL or your preferred MicroPython workflow.
- Use the station-mode pattern shown in Raspberry Pi’s MicroPython documentation: create
network.WLAN(network.STA_IF), activate it, then callconnect(ssid, password). - Wait for and verify a successful network connection before proceeding. If it fails, check the network name and password, the availability of a 2.4 GHz network, and whether the network permits the board to connect.
- Repeat the Wi-Fi setup on the second board. Each board must be able to reach the broker’s address and port.
Connect, publish, and subscribe
Once both boards have network access, configure each MQTT client with the broker details and a client identity accepted by that broker. Have the subscriber connect and subscribe to the intended topic; have the publisher connect and publish to that same topic. The precise constructor, connection parameters, and TLS options depend on the client library and broker, so do not assume one code listing or port applies to every setup.
Raspberry Pi’s Pico SDK repository provides picow_mqtt_client as a starting point for C/C++ users. In MicroPython, the umqtt.simple documentation describes publishing, subscribing, callbacks, and message-processing methods. Verify that the library is present and compatible with the firmware running on your board before relying on a particular installation procedure.
Rank #4
- Raspberry Pi Pico W: A tiny, fast, and versatile board built using dual-core Arm Cortex-M0+ processor with wireless LAN and Bluetooth (Comes with pinout card and stickers)
- Detailed Tutorial: Provides step-by-step guide with MicroPython, C and Processing (Java) Code (The download link can be found on the product box) (No paper tutorial)
- Example Projects: Each project has schematics, wiring diagrams, complete code and detailed explanations (Need extra items)
- Easy to Use: Just connect the board to your computer (installed IDE) with the USB cable to program it
- Get Support: Our technical support team is always ready to answer your questions
Handle incoming messages in MicroPython
A subscribed message can be handled by a callback when the client processes incoming packets. If your application has other work to do, use the client’s non-blocking check_msg() pattern regularly in its main loop so messages continue to be checked without stopping the rest of the program. The documented wait_msg() method blocks while waiting for a message, which may suit a program that can pause until one arrives.
Select a supported QoS
With umqtt.simple, use QoS 0 or QoS 1: those are the documented publish and subscribe levels. Do not request QoS 2 from this client. QoS describes MQTT delivery behavior; it does not replace application-level handling for duplicate messages or protect credentials and traffic.
Plan for disconnections
Wi-Fi or broker connectivity can be interrupted, so decide how the device should behave when that happens. The umqtt.simple documentation identifies a separate umqtt.robust module that adds automatic reconnect support. Check the module’s version and compatibility with your firmware, and verify its behavior for your connection conditions; automatic reconnect should not be taken to mean every outage is handled without application logic.
For a message exchange to work again after a disconnect, the client may need to restore its broker connection and the subscriber may need to subscribe again, depending on the client and broker behavior. Test a Wi-Fi interruption and a broker interruption separately, and ensure the application can tolerate a message arriving more than once if its chosen delivery behavior permits that.
Quick Recap
Check the message path when data does not arrive
- Wi-Fi is not connected: verify station-interface status on each board before diagnosing MQTT.
- The client cannot reach the broker: confirm the broker address and port, network reachability, and any credentials or security configuration required by that broker.
- The subscriber receives nothing: compare the publish topic with the subscription topic or filter, and confirm the subscriber has connected and processed incoming packets.
- Messages stop after an outage: check whether the client reconnected and whether the subscription was restored; add application recovery logic where needed.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

