ESP32 and Arduino

ESP32 vs Raspberry Pi Pico W for IoT: Wi-Fi, MicroPython, Arduino and TLS Compared

A practical comparison of the ESP32 and Raspberry Pi Pico W for connected projects, covering hardware, Wi-Fi and Bluetooth, programming options, TLS performance, low-power modes and MQTT code on both.

ESP32 vs Raspberry Pi Pico W boards side by side, both publishing sensor data to an MQTT broker
Run this on your own MQTT brokerGet a private, managed MQTT broker on the Free plan and start from ready-made code samples.
Try it free Code samples No card required

ESP32 vs Raspberry Pi Pico W is one of the most common questions when starting a Wi-Fi IoT project, and both boards can publish sensor data to an MQTT broker in a few lines of code. This comparison looks at the things that actually matter for connected devices: the wireless stack, programming environments, TLS performance, power saving and ecosystem, and ends with a clear recommendation for each kind of project.

The Short Answer

Choose the ESP32 when the device is primarily a network device: it needs TLS, Bluetooth, deep-sleep battery operation, or mature Arduino and ESP-IDF libraries. Choose the Pico W when you value Raspberry Pi's excellent documentation, the RP2040's programmable I/O (PIO), or a gentle MicroPython learning path, and the device is mostly on mains power. Both are perfectly capable MQTT clients.

Hardware at a Glance

ESP32 (classic, e.g. ESP32-WROOM-32) Raspberry Pi Pico W
CPU Dual-core Xtensa LX6, up to 240 MHz Dual-core Arm Cortex-M0+ (RP2040), 133 MHz
SRAM 520 KB 264 KB
Flash Typically 4 MB on modules 2 MB
Wi-Fi 802.11 b/g/n, 2.4 GHz, integrated 802.11n, 2.4 GHz, Infineon CYW43439 over SPI
Bluetooth Classic and BLE Via the CYW43439: BLE in MicroPython, BLE and Classic in the C SDK (added after launch)
Crypto acceleration AES, SHA, RSA/big-number hardware None
Special I/O Touch sensing, DAC on classic ESP32, many peripherals PIO state machines for custom protocols
Low power Deep sleep with RTC memory, timer and GPIO wake Dormant and sleep modes, less turnkey for Wi-Fi devices
Board variety Hundreds of boards from many vendors Official board plus compatible third-party boards

The ESP32 family has many members: the S3 adds AI vector instructions and USB, the C3 and C6 are low-cost RISC-V parts, and the C6 adds Wi-Fi 6 and Thread. Raspberry Pi has also released the Pico 2 W, based on the RP2350 with faster Cortex-M33 cores, more SRAM and security features. If you are deciding today, compare the newer parts too; most of the trade-offs below still apply.

Wi-Fi Stack and Networking

On the ESP32, Wi-Fi is part of the chip and the networking stack (lwIP plus Espressif's drivers) has been used in a huge number of shipped products. Reconnects, multiple sockets, TLS and features like Wi-Fi provisioning are all well trodden. Espressif's own ESP-MQTT component supports MQTT 3.1.1 and MQTT 5 out of the box when you use ESP-IDF.

The Pico W connects its CYW43439 radio over an SPI-like bus and runs lwIP on the RP2040. It works reliably for typical sensor and control projects, and the Raspberry Pi SDK and MicroPython port are well maintained. The radio driver does consume part of the RP2040's resources, and you have fewer choices of mature networking libraries in C than on the ESP32.

Both boards are 2.4 GHz only, so neither will join a 5 GHz-only network.

Programming Options

Environment ESP32 Pico W
Arduino Official Espressif core, very large library ecosystem (PubSubClient, AsyncMqttClient, ArduinoJson) Community arduino-pico core by Earle Philhower; PubSubClient works
MicroPython Supported, umqtt.simple available Supported and officially documented by Raspberry Pi
CircuitPython Supported on many boards Supported
Native SDK ESP-IDF with FreeRTOS, built-in MQTT client Pico SDK with lwIP, MQTT client from lwIP apps

For MicroPython beginners, the Pico W's documentation is a genuine advantage: Raspberry Pi's guides walk through flashing, Wi-Fi and first programs with very few surprises. For Arduino users, the ESP32 has the deeper library ecosystem. If you are leaning towards MicroPython on the ESP32, the MicroPython umqtt ESP32 guide shows the equivalent setup.

MQTT on the Pico W with MicroPython

This script connects a Pico W to the public test area of broker.connectmq.com and publishes the on-chip temperature sensor every ten seconds. The same code runs on an ESP32 under MicroPython if you remove the temperature-sensor lines.

import time
import network
import machine
from umqtt.simple import MQTTClient   # install with: import mip; mip.install("umqtt.simple")

SSID = "YOUR_WIFI"
PASSWORD = "YOUR_WIFI_PASSWORD"
BROKER = "broker.connectmq.com"
CLIENT_ID = b"picow-5b2e"                      # must be non-empty and unique
TOPIC = b"connectmq/demo/picow-5b2e/telemetry"

wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(SSID, PASSWORD)
for _ in range(30):
    if wlan.isconnected():
        break
    time.sleep(1)
if not wlan.isconnected():
    machine.reset()
print("Wi-Fi OK:", wlan.ifconfig()[0])

sensor = machine.ADC(4)                        # RP2040 internal temperature sensor


def read_temp_c():
    volts = sensor.read_u16() * 3.3 / 65535
    return 27 - (volts - 0.706) / 0.001721


client = MQTTClient(CLIENT_ID, BROKER, port=1883, keepalive=60)
client.set_last_will(b"connectmq/demo/picow-5b2e/status", b"offline", retain=True, qos=1)
client.connect()
client.publish(b"connectmq/demo/picow-5b2e/status", b"online", retain=True, qos=1)

while True:
    try:
        payload = '{"temp_c":%.2f,"rssi":%d}' % (read_temp_c(), wlan.status("rssi"))
        client.publish(TOPIC, payload.encode())
        print("sent", payload)
    except OSError as e:
        print("MQTT error, reconnecting:", e)
        time.sleep(5)
        client.connect()
    time.sleep(10)

Verify it from any computer:

mosquitto_sub -h broker.connectmq.com -p 1883 -i picow-5b2e-viewer -t "connectmq/demo/picow-5b2e/#" -v

The Arduino equivalent for the ESP32 with PubSubClient is covered step by step in the ESP32 IoT tutorial.

TLS Performance: Where the Boards Differ Most

Production MQTT should run over TLS on port 8883, and this is where the hardware gap shows. A TLS handshake involves public-key operations (RSA or elliptic-curve) and certificate verification, which are computationally heavy for a microcontroller.

  • The ESP32 runs mbedTLS with hardware acceleration for AES, SHA and big-number arithmetic. Handshakes complete quickly enough that reconnecting after a Wi-Fi drop is barely noticeable, and there is enough RAM for TLS buffers alongside your application.
  • The Pico W performs the same operations in software on 133 MHz Cortex-M0+ cores, which lack some of the instructions that speed up this arithmetic. TLS works, but handshakes take noticeably longer and RAM is tighter with 264 KB to share.

In practice, this matters most for battery devices that wake, connect, publish and sleep: every wake-up pays for a full handshake, so a slower handshake directly costs battery life. For always-on devices, a slower first connection is rarely a problem.

Two tips apply to both boards: set the system clock (NTP) before connecting, because certificate validation needs the current date, and load only the root CA you need (ISRG Root X1 for Let's Encrypt-based brokers) to save memory. The ESP32 MQTT SSL guide shows the ESP32 side in detail.

Power Consumption and Battery Life

The ESP32's deep sleep is designed for exactly the "wake, measure, publish, sleep" pattern: the main cores power down, the RTC domain keeps a timer and a few bytes of memory, and the chip wakes on a timer or GPIO. Battery sensors running for months on a single cell are common. See ESP32 deep sleep with MQTT for a complete example.

The Pico W can enter sleep and dormant modes, but the Wi-Fi chip must be managed separately and the tooling is less turnkey. Many battery-powered Pico W projects instead cut power completely with an external timer chip. If your device runs on mains or USB power, the difference largely disappears.

Decision Checklist

  1. Battery-powered, publishing over TLS? ESP32.
  2. Needs Bluetooth Classic or a mature BLE stack? ESP32 has the longer track record.
  3. Learning MicroPython from scratch with official tutorials? Pico W is a very friendly choice.
  4. Custom timing-critical protocols (LED strips, odd serial formats)? Pico W's PIO is excellent.
  5. Large Arduino library needs? ESP32.
  6. Want the newest silicon? Compare ESP32-S3/C6 with Pico 2 W before deciding.

Coming from the ESP8266 instead? The ESP32 vs ESP8266 comparison covers that upgrade path.

The Broker Side Is the Same for Both

Whichever board you choose, the device is just an MQTT client. The broker handles authentication, fan-out to dashboards and backends, and retained state. That means you can mix ESP32 and Pico W devices on the same topics without any changes elsewhere. Start testing on the public MQTT test broker, and when the project goes live, move to a private, TLS-protected cloud MQTT broker so your devices get their own credentials. ConnectMQ supports both MQTT 3.1.1 (used by umqtt.simple and PubSubClient) and MQTT 5.

Get Started with ConnectMQ

Both boards work with ConnectMQ out of the box: TCP on 1883, TLS on 8883 with a Let's Encrypt certificate, and an in-browser MQTT client to test your messages. Create a free Serverless broker at app.connectmq.com without a credit card and connect your ESP32 or Pico W in minutes.

Frequently Asked Questions

Is the ESP32 or the Pico W better for beginners?

Both are beginner-friendly. The Pico W has outstanding official MicroPython documentation, while the ESP32 has a larger pool of Arduino tutorials and libraries.

Can the Raspberry Pi Pico W use MQTT over TLS?

Yes, through MicroPython's ssl module or the arduino-pico core's secure client. Expect slower handshakes than on the ESP32 because there is no crypto acceleration.

Which board uses less power?

For battery devices that sleep between readings, the ESP32's deep sleep is easier to use and very efficient. For always-on devices, the difference is smaller than the choice of sensors and publish interval.

Can I mix ESP32 and Pico W devices in one MQTT system?

Yes. MQTT is hardware-independent, so both can publish and subscribe on the same broker and topics.

Related articles

ESP-IDF MQTT Example: Build an esp-mqtt Client from Scratch

Build an ESP-IDF project from an empty folder with the esp-mqtt component: Wi-Fi station setup, the MQTT event handler, publish and subscribe, MQTT 5 properties and TLS with the certificate bundle.

8 min read

Using esp-mqtt MQTT 5 Features on ESP32 with ESP-IDF

A hands-on ESP-IDF project that enables MQTT 5.0 in esp-mqtt and uses user properties, message expiry, topic aliases, session expiry and response topics against a real MQTT 5 broker.

7 min read

All articles →

Your private MQTT broker is a few clicks away

Create an account, get your broker credentials and connect your first device — no servers to install, patch or scale.