ESP32 vs STM32 vs RP2040: Choosing the Right Microcontroller for Your IoT Project

ESP32, STM32 and RP2040 are three different answers to what a microcontroller is for: wireless, deterministic control, and flexible I/O. This guide compares them on the factors that decide a student project, with a five-question decision framework and three worked choices.

Written by Projectech13 min readPublished
For Electronics, IoT and embedded students choosing between ESP32, STM32 and RP2040 for a project that needs wireless, control, or custom I/O Topics: ESP32, STM32, RP2040
Technical illustration of three microcontroller development boards side by side with a Wi-Fi symbol, a motor-control timer diagram and programmable I/O blocks, in blueprint line-art style.
Illustration generated for this guide.
In this guide

Picking a microcontroller feels like a small decision, and then it quietly decides everything else: whether your project gets Wi-Fi without an extra module, whether the motor control loop runs on time, how long the battery lasts, and how much of your semester goes into fighting the toolchain instead of building the project. ESP32, STM32 and RP2040 are the three chips students reach for most often, and they are not three versions of the same thing — they are three different answers to the question of what a microcontroller is for.

ESP32 is a connectivity chip: the radio is built in. STM32 is a control chip: a huge family built around deterministic timing and peripherals. RP2040 is a flexibility chip: cheap silicon with programmable I/O that can speak almost any digital protocol you can describe. This guide compares them on the factors that actually decide a student project, gives you a five-question decision framework, and walks through three worked choices so you can see the reasoning, not just the verdict.

Quick answer

Choose ESP32 when the project needs Wi-Fi or Bluetooth built in. Choose STM32 for deterministic real-time control or rich peripherals. Choose RP2040 when cost dominates or its programmable I/O fits an unusual protocol. Many real designs use two together — one chip for control, one for connectivity.

The three chips at a glance

Factor ESP32 (classic / S3) STM32 (family) RP2040 (Pico / Pico 2)
Core Dual-core Xtensa LX6 up to 240 MHz; LX7 on the S3 Cortex-M0/M0+/M3/M4/M7, depends on the part Dual-core Cortex-M0+ at 133 MHz; Cortex-M33 at 150 MHz on RP2350
Wireless Wi-Fi + Bluetooth/BLE built in None — add a module None on Pico; Pico W adds Wi-Fi only; Pico 2 W adds Wi-Fi + Bluetooth 5.2
Memory About 520 KB SRAM, external flash Varies widely by part 264 KB SRAM, 2 MB flash on Pico; 520 KB SRAM on Pico 2
ADC 12-bit, known non-linearity near the rails 12-bit on most parts, some 16-bit, generally better linearity 12-bit, 3 channels plus a temperature sensor
Special I/O Capacitive touch, Hall sensor (classic) Advanced timers, CAN, DAC, DMA on many parts PIO: 2 blocks × 4 state machines for custom protocols
Low power Deep sleep around 10 µA at the chip; the dev board usually draws far more Stop and standby modes; L-series parts reach very low currents Dormant mode exists but draws more than a true deep sleep
Toolchain Arduino, ESP-IDF STM32CubeIDE + HAL, Arduino via STM32duino C/C++ SDK, MicroPython, Arduino
Best for Connected devices, phone-paired gadgets Motor control, power electronics, industrial-style builds Cost-sensitive builds, custom I/O, USB devices

Treat the numbers as the common dev-board parts (ESP32-WROOM-32, STM32F103/F407, Raspberry Pi Pico). Every family has variants that break any single row, so confirm the exact part on its datasheet before you commit.

How to decide: five questions

Answer these in order, and the choice usually makes itself.

1. Does it need wireless? If the project must join Wi-Fi, pair with a phone over Bluetooth, or report to a dashboard, ESP32 is the fastest path — the radio, antenna matching and certified module are already done for you. STM32 and RP2040 can both do wireless, but only through an added module, which costs pins, board space, money and debugging time. The one exception is Pico 2 W, which covers Wi-Fi and Bluetooth at a low price for lighter workloads.

2. Does anything need to happen on a strict deadline? Motor control loops, power converters, precise PWM and fast interrupt handling want deterministic timing. STM32 is built for this: predictable interrupt latency, hardware timers and DMA that move data without waking the CPU. RP2040's PIO is also strong for timing-critical I/O. ESP32 is the weakest here, because its Wi-Fi and Bluetooth stack shares the cores and adds timing jitter a hard real-time loop cannot always tolerate.

3. How much power is available? For a battery project, look at sleep current, not headline clock speed. ESP32's deep sleep is good at the chip level, but most cheap dev boards leak milliamps through the USB chip and regulator — measure your actual board. STM32's low-power parts are the strongest of the three for long-life sensor nodes. RP2040's dormant mode is the least impressive; it keeps SRAM powered and draws more than a true deep sleep.

4. What I/O does the project really need? Count the peripherals before you count the pins: how many ADC channels, hardware PWM outputs, UARTs, I2C and SPI buses, and whether you need CAN, DAC or USB. STM32 usually wins on sheer peripheral count. RP2040 wins when the protocol is unusual — PIO state machines can implement WS2812 LEDs, custom sensor buses, VGA output or DShot motor signals in hardware, freeing the CPU entirely.

5. What can your team actually finish? A chip you cannot debug in week two is worse than a weaker chip you can ship. Arduino support exists for all three, but the depth differs: ESP32 and RP2040 are friendly first chips, while STM32's CubeIDE and HAL have a real learning curve that pays off only if someone on the team is willing to climb it, or a mentor can help.

ESP32 in detail

The ESP32's case is simple: it is the only one of the three with wireless built in, and its ecosystem is enormous — libraries, examples and forum answers for almost any sensor. Two cores help too: one can serve the network stack while the other runs your application, which is how most student IoT projects end up structured. Variants matter: the S3 adds USB OTG and instructions that speed up small on-device ML, the C6 adds Wi-Fi 6, Zigbee and Thread, and the C3 is a cheaper single-core RISC-V part.

The weaknesses are specific, not general. The 12-bit ADC is non-linear near 0 V and 3.3 V, so if your project is mostly precision analogue sensing, budget for an external ADC or pick another chip. Wi-Fi activity adds timing jitter, so do not plan a hard real-time control loop on the same core that serves the network. And deep-sleep figures on datasheets describe the chip, not the dev board — measure the board you actually bought.

STM32 in detail

STM32 is not one chip but a family of hundreds, from the low-power L0 to the high-performance H7, all sharing the Cortex-M architecture and the same CubeIDE toolchain. That breadth is the point: you can prototype on a cheap Blue Pill (STM32F103, 72 MHz Cortex-M3) and move the same code toward a faster part if the project grows. The peripheral set is the deepest of the three — advanced timers with complementary PWM for motor drives, CAN for vehicles and industrial buses, DACs, and DMA everywhere.

The cost is the learning curve. CubeMX generates initialisation code, HAL abstracts the registers, and both are genuinely useful, but the first week with STM32 is slower than the first week with an ESP32 or a Pico. That is a fair trade for a motor-control or power-electronics project, and a poor trade for a simple sensor node that just needs to post data to the cloud.

RP2040 in detail

RP2040 is the cheapest silicon of the three, and its trick is PIO: two programmable I/O blocks with four state machines each that run small programs independently of the CPU. Need to drive a strip of addressable LEDs, decode a rotary encoder at speed, or talk a sensor protocol no library supports? A PIO state machine does it in hardware while the cores do other work. It also has native USB, so it can present itself as a keyboard, mouse or serial device with no extra chip — genuinely useful for HID and data-logging projects.

The limits are honest ones: no wireless on the plain Pico (Pico W adds Wi-Fi only, no Bluetooth), modest processing power, and less RAM than an ESP32. The RP2350 in the Pico 2 fixes some of that — faster Cortex-M33 cores, 520 KB SRAM, and the Pico 2 W finally adds both Wi-Fi and Bluetooth — which makes the Pico 2 W the cheapest wireless option of the three families for light workloads.

Toolchains and getting started, compared

  • ESP32: Arduino IDE for the fastest start; ESP-IDF when you want the full feature set, FreeRTOS tasks and proper power management. Most students start in Arduino and move one or two features to ESP-IDF later.
  • STM32: STM32CubeIDE with CubeMX for configuration and HAL for drivers. Arduino support exists through STM32duino, but it hides the peripherals that are the reason to choose STM32 in the first place.
  • RP2040: MicroPython for the fastest first blink and quick sensor experiments; the C/C++ SDK for anything timing-sensitive or PIO-based; Arduino support exists and is improving.

A practical rule: if your team has never used any of the three, budget one full weekend to get the toolchain, a blinking LED, a serial print and one sensor reading working on your chosen chip before you write any project code. The chip that gets through that weekend fastest is usually the right one for your team.

Power and battery life

Battery life is decided by sleep current and wake frequency, not by the headline clock speed. As a rough guide: an ESP32 sensor node that wakes every ten minutes, reads a sensor and posts over Wi-Fi can run for weeks on a single 18650 cell if the dev board's power leaks are dealt with — and for days if they are not. STM32 low-power parts are the best of the three for multi-month sensor nodes. RP2040 nodes sit in the middle: fine for mains-powered or frequently charged builds, less suited to a deploy-and-forget battery node.

Whatever you choose, measure the real current with a multimeter or a USB power meter in each state — active, idle and sleep — and multiply by your duty cycle. Datasheet numbers describe the chip; your board, regulator and peripherals decide the battery.

Three worked decisions

A Wi-Fi plant monitor. Soil-moisture sensor, uploads every ten minutes, battery powered, phone dashboard. Pick the ESP32: built-in Wi-Fi removes an entire subsystem, deep sleep covers the battery budget, and the ADC's quirks do not matter for a slow moisture reading. A Pico W would work too, but the ESP32's ecosystem makes the dashboard half faster.

A BLDC gimbal controller. Three-phase motor, field-oriented control, current sensing, tight PWM timing. Pick STM32: advanced timers with complementary PWM, a fast ADC with DMA, and an FPU/DSP on the M4/M7 parts. An ESP32 could spin the motor, but the control loop would fight the Wi-Fi stack for timing.

A custom sensor bus plus USB logging. A legacy sensor speaks a timing-critical protocol no library supports, and the device must appear as a USB keyboard to a PC. Pick RP2040: one PIO state machine implements the sensor protocol, another handles timing, and native USB covers the HID side. No other chip in this comparison does all three jobs without extra hardware.

Common mistakes

  • Choosing by clock speed alone. A 240 MHz chip with a busy Wi-Fi stack can lose a timing race to a 72 MHz chip with hardware timers. Match the chip to the job, not the headline number.
  • Ignoring the ADC. If the project is mostly analogue sensing, read the ADC section of the datasheet first — the ESP32's non-linearity has sunk more than one sensor project.
  • Assuming Pico W has Bluetooth. It does not; the original Pico W is Wi-Fi only. Bluetooth arrives with the Pico 2 W.
  • Picking STM32 with no mentor and no time. The HAL learning curve is real. If nobody on the team has done it before, budget the learning time honestly or pick the friendlier chip.
  • Forgetting the antenna. A bare ESP32 module without proper antenna layout performs far worse than the same chip on a good dev board. For a first wireless project, buy a module or dev board, not bare silicon.
  • Designing for one chip when the project needs two. A control chip plus a connectivity chip is a normal, respectable architecture — not a failure of planning.

FAQ

Can I use the Arduino IDE with all three?
Yes. ESP32 and RP2040 have official Arduino cores, and STM32 works through STM32duino. Arduino gets you started fast, but it hides the features that make STM32 and RP2040 special — expect to move to CubeIDE or the Pico SDK for the advanced parts of the project.

Which is best for a first embedded project?
ESP32 if the project needs wireless, Raspberry Pi Pico if it does not. Both have huge beginner communities, cheap boards and MicroPython or Arduino support. STM32 is the better second chip, once you have one finished project behind you.

Can the RP2040 do Wi-Fi?
The plain Pico cannot. Pico W adds Wi-Fi only, and Pico 2 W adds Wi-Fi and Bluetooth 5.2. If your project needs Bluetooth on a Pico, make sure you are buying the Pico 2 W, not the original Pico W.

Is STM32 overkill for a college project?
Sometimes. For a sensor node that posts data to the cloud, yes — an ESP32 finishes it faster. For motor control, power electronics or anything with tight timing, STM32 is the right tool rather than overkill, and examiners recognise the difference.

Can I use two microcontrollers in one project?
Yes, and it is common: an STM32 or RP2040 handles control while an ESP32 handles connectivity, talking over UART, SPI or I2C. Split the jobs along the boundary each chip is good at, and keep the link between them simple.

What about the ESP32-C3, C6 and S3?
They are variants inside the ESP32 family, and the same decision logic applies: C3 is a cheaper single-core option, C6 adds Zigbee, Thread and Wi-Fi 6, and S3 adds USB and faster on-device ML. Choose the variant after you have chosen the family.

Limitations

This guide compares the common dev-board parts students actually buy; each family has variants that change individual numbers, so always confirm the exact part on its datasheet. Wireless range, power draw and ADC behaviour depend on the board and layout, not only the chip — measure your own hardware. No benchmark figures are quoted here because benchmark results depend heavily on compiler settings and test code, and a student's project is decided by peripherals and ecosystem far more than by a synthetic score. Finally, availability and board revisions change often; check that the board you order matches the chip and features described here.

Need help building it?

If you want this project built for you — the microcontroller chosen, the circuit designed and the firmware written — message Projectech on WhatsApp with your project idea, your branch and your deadline. The reply is a quotation stating the scope, the price and the delivery timeline, before any work starts.

More project guides

More in IoT & Embedded