STM32 vs ESP32: which should your product use?
The short answer
Use an ESP32 when the product's main job is to connect, because Wi-Fi and Bluetooth come on the chip. Use an STM32 when its main job is to control something on an exact schedule, such as a motor. When a product needs both, use one of each and join them with a serial link.
By the engineers at WhiteHat Design Studio. Published .
The short comparison
| What matters | STM32 | ESP32 |
|---|---|---|
| Made by | STMicroelectronics | Espressif Systems |
| Processor | 32-bit Arm Cortex-M | Xtensa on the ESP32 and ESP32-S3, RISC-V on the ESP32-C3 |
| Wireless on the chip | Not on most parts | Wi-Fi and Bluetooth |
| Best at | Control with hard timing | Devices that have to connect |
| Usual software | C with ST’s own tools, or the real-time system of your choice | ESP-IDF, Espressif’s framework, built on FreeRTOS |
| Long-term supply | A rolling 10-year longevity programme | A 12-year commitment on most chips and 15-year on the original ESP32, from dates Espressif lists |
| Radio approval | Yours to arrange if you add a radio | Espressif publishes certificates, such as FCC and CE, for its modules |
Choose an ESP32 when the product has to connect
If the device needs Wi-Fi or Bluetooth anyway, an ESP32 puts the radio and the processor on one chip, with one firmware to write. There is room for real work beside the radio: the ESP32-S3 has two Xtensa LX7 cores at up to 240 MHz, and the ESP32-C3 has one RISC-V core at up to 160 MHz. Espressif publishes radio certificates for its modules, which can shorten the approval of your product. Ask your test house what your market still needs from you.
SceneScribe shows the pattern. Its cane carries an ESP32 that joins a Wi-Fi access point the headset creates, and handles obstacle detection, so the two pieces find each other without any other equipment.
Choose an STM32 when timing is the job
If the device has to turn a motor, close a control loop or sample a sensor on an exact schedule, start with an STM32. On an ESP32 the Wi-Fi stack shares the processor with your code, so a busy radio can move your timing. On a chip with no radio, the only code competing for time is your own.
SKYLOCK’s physical system uses STM32 control hardware. A gimbal that has to stay on a moving drone is exactly the kind of job this chip family is chosen for. Many flight controllers for drones run on STM32 chips too, for the same reason.
When to use both
For many products the answer is one of each. The STM32 runs the control loop, the ESP32 runs the network, and a serial link such as UART or SPI joins them. A Wi-Fi fault then cannot stall a motor. The price is two firmwares, two update paths and a message format you have to define and test. Espressif also publishes AT firmware, which lets a host chip use an ESP32 like a modem, with simple text commands.
Where a Raspberry Pi fits
A Raspberry Pi is a small Linux computer, not a microcontroller. A Raspberry Pi 5 has four Arm Cortex-A76 cores at 2.4 GHz, which is the right tool when a system needs a camera pipeline, a full operating system or AI on board. HARP is built around a Raspberry Pi 5, and ReFlex runs its grip model on one. A Raspberry Pi usually sits above a microcontroller rather than in place of one: Linux decides what to do, and the microcontroller does it on time.
Five questions that settle it
- Does the product need a radio at all?
- What is the tightest deadline in the system, in microseconds or milliseconds?
- Does it run from a battery, and how many hours does it need between charges?
- How long must you keep buying this exact part? Check the part number, not only the family.
- Who will maintain the firmware, and which tools do they already know?
If you are not sure, send us the answers. Choosing the chip is part of our hardware work, and the firmware source is yours at handover.
Questions people ask next
Is STM32 better than ESP32?
Neither is better in general. An STM32 is the stronger choice for control with hard timing, and an ESP32 for a device that has to connect. Many products use one of each.
Which is better for robotics?
Most robots use more than one chip. A microcontroller such as an STM32 drives the motors and reads the sensors on time, an ESP32 can carry a wireless link, and a Linux computer such as a Raspberry Pi handles vision and planning.
Can an STM32 and an ESP32 work together?
Yes. The usual way is a serial link such as UART or SPI, with the STM32 running the control loop and the ESP32 running the network. You then have two firmwares to maintain and a message format to define and test.