A tour of Arduino, ESP32 and STM32 boards
About this lesson
You rarely program a bare chip: a development board puts a microcontroller on a small card with a USB socket, a USB helper chip, a regulator and pin headers. Meet three common boards, the Arduino Uno R3, the ESP32-DevKitC and the STM32F4DISCOVERY, compare their clocks, memory and pin voltages, then choose one for a worked example: a plant sensor that must report over Wi-Fi. Finally follow the firmware down the USB cable into each chip. The Hardware lesson “Microcontrollers: a whole computer on one chip” explains what is inside the chip, and the C++ basics lessons cover the language.
A chip plus its helpers
A development board puts a microcontroller on a small card with helpers: a USB socket, a chip that speaks USB, a power regulator and rows of pins. Plug it into a laptop and you can program it with no other tools.
development board = microcontroller + helpers USB socket power and data from the laptop USB helper chip turns USB into something the MCU understands regulator steady supply voltage for the chip pin headers where your wires go one cable, no extra programmer needed
Read the lesson step by step
A chip plus its helpers
A development board puts a microcontroller on a small card with helpers: a USB socket, a chip that speaks USB, a power regulator and rows of pins. Plug it into a laptop and you can program it with no other tools.
development board = microcontroller + helpers USB socket power and data from the laptop USB helper chip turns USB into something the MCU understands regulator steady supply voltage for the chip pin headers where your wires go one cable, no extra programmer neededArduino Uno R3: the classic
The Uno R3 carries an ATmega328P: an 8-bit chip at 16 MHz with 32 KB of flash for the program and 2 KB of SRAM for variables. It has 14 digital pins and 6 analog inputs, all working at 5 volts.
board Arduino Uno R3 MCU ATmega328P, 8-bit AVR clock 16 MHz flash 32 KB SRAM 2 KB pins 14 digital, 6 analog, 5 V logic radio noneESP32: Wi-Fi built in
The ESP32-DevKitC carries an ESP32: two 32-bit cores at up to 240 MHz and 520 KB of SRAM, with Wi-Fi and Bluetooth inside the chip. The program sits in a separate 4 MB flash chip under the module's metal lid.
board ESP32-DevKitC (module ESP32-WROOM-32E) MCU ESP32, 32-bit Xtensa LX6, 2 cores clock up to 240 MHz flash 4 MB, a separate chip in the module SRAM 520 KB radio Wi-Fi 802.11 b/g/n, Bluetooth 4.2 and LESTM32: speed and a debugger
The STM32F4DISCOVERY carries an STM32F407: a 32-bit Arm Cortex-M4 at 168 MHz with 1 MB of flash and 192 KB of SRAM. A second chip, the ST-LINK, is a debugger: it can pause your running code and show its values.
board STM32F4DISCOVERY MCU STM32F407, 32-bit Arm Cortex-M4 clock 168 MHz flash 1 MB SRAM 192 KB (+4 KB backup) debugger ST-LINK/V2 on the board radio noneSide by side
Put the numbers together. Clocks: 16, 240 and 168 MHz. SRAM for variables: 2, 520 and 192 KB, so the ESP32 holds 260 times as much as the Uno. Bigger is not always better: a small job runs fine on a small chip.
clock flash SRAM Uno R3 16 MHz 32 KB 2 KB ESP32 240 MHz 4 MB 520 KB STM32 168 MHz 1 MB 192 KB SRAM 520 / 2 = 260 times5 volts or 3.3 volts
A HIGH pin on the Uno is 5 volts. The ESP32 and STM32 boards run on 3.3 volts or less. An ESP32 pin takes at most 3.6 volts, so lower a 5 V signal first: a later lesson on level shifting shows how.
Uno R3 HIGH = 5 V ESP32 HIGH = 3.3 V STM32 3.3 V or less (chip supply 1.8 to 3.6 V) ESP32 pin input max = supply + 0.3 V = 3.6 V so 5 V into an ESP32 pin is out of specThe job: a Wi-Fi plant sensor
Our worked example: a plant-pot sensor that reads soil moisture and sends it over Wi-Fi. Test each board against that one hard need. The Uno and this STM32 have no radio. The ESP32 has Wi-Fi on the chip.
job: plant sensor read: 1 analog pin send: over Wi-Fi power: USB, 5 V hard need: Wi-Fi Uno R3 no radio ESP32 yes, on the chip STM32 no radioPick the ESP32
The ESP32 wins: Wi-Fi is built in, it has analog inputs for the sensor, and the Arduino IDE can program it with Espressif's Arduino core. The other boards would need an extra Wi-Fi board wired on.
chosen ESP32-DevKitC Wi-Fi on the chip analog inputs for the sensor Arduino core for ESP32 (by Espressif) 520 KB SRAM: room for the Wi-Fi code others would need an add-on Wi-Fi boardGetting code onto the ESP32
The laptop compiles the sketch into a firmware image and sends it down the USB cable. The bridge chip turns USB into serial and resets the ESP32 into download mode. A bootloader in the chip's ROM writes the image into flash.
laptop sketch -> firmware image USB cable image to the bridge chip bridge USB -> serial, up to 3 Mbps holds GPIO0 low during reset: download mode ROM loader built into the ESP32, writes flash reset the new firmware startsEach board has its own route
On the Uno, the ATmega16U2 passes the image to a 512-byte bootloader kept in the ATmega328P's own flash. On the STM32 board, the ST-LINK writes flash directly through the chip's debug port, called SWD. The next lesson follows compile, link and flash.
Uno USB -> ATmega16U2 -> serial 115200 baud -> bootloader (512 bytes of flash) -> flash ESP32 USB -> bridge -> ROM bootloader -> flash STM32 USB -> ST-LINK/V2 -> SWD -> flash no bootloader needed; it can also debug
5 quick questions
Choose one answer per question. You can change your choices before checking them.
01What does a development board add to a bare microcontroller?
The board carries the helpers you need to power and program the chip from a laptop with one USB cable. Your program still runs on the microcontroller.
02Your project must send readings over Wi-Fi with no extra parts. Which of the three boards fits?
The ESP32 has Wi-Fi and Bluetooth built into the chip. The ATmega328P and the STM32F407 have no radio, so they would need an add-on Wi-Fi board.
03The Uno has 2 KB of SRAM and the ESP32 has 520 KB. How many times as much is that?
520 ÷ 2 = 260. More SRAM means room for more variables, such as the buffers Wi-Fi code needs.
04Why must you be careful when you wire an Uno output to an ESP32 input?
The ESP32 datasheet allows a high input of at most its supply plus 0.3 V, which is 3.6 V on 3.3 V. A 5 V signal has to be lowered first; a later lesson on level shifting shows how.
05How does the STM32F4DISCOVERY write your firmware into its chip?
The ST-LINK is a debugger and programmer on the same board. It writes flash directly over SWD and can also pause the running code so you can look at its values.
Glossary
- Development board
- A small card that carries a microcontroller plus the helpers needed to power and program it from a laptop: a USB socket, a USB helper chip, a regulator and pin headers.
- Pin header
- A row of metal pins along the edge of a board where you plug in wires to sensors, LEDs and other parts.
- USB-to-serial bridge
- A chip that turns USB from the laptop into the simple serial signals a microcontroller's bootloader understands.
- Bootloader
- A small program on the chip that receives new firmware over a cable and writes it into flash. The ESP32 keeps one in ROM; the Uno keeps one in its flash.
- Debugger (ST-LINK)
- A tool that can write flash and also pause, step and inspect a running program. The STM32F4DISCOVERY has one built in.
- SWD
- Serial Wire Debug: the debug connection the ST-LINK uses to program and debug the STM32 chip.
- Logic level
- The voltage that counts as HIGH on a pin: 5 V on the Uno, 3.3 V on the ESP32 and STM32 boards.
- Arduino core
- An add-on that teaches the Arduino IDE to build code for one chip family, such as AVR, ESP32 or STM32.
Notes and sources
- Each family has many boards. We use one common board for each: the Arduino Uno R3 (ATmega328P), the ESP32-DevKitC V4 with an ESP32-WROOM-32E module (4 MB flash; WROVER versions have 8 MB), and the STM32F4DISCOVERY (STM32F407VG). Other boards in the same family have other numbers.
- The STM32F407's 192 KB of SRAM includes 64 KB of core coupled memory, and it has 4 KB of backup SRAM on top. The ESP32 also has 16 KB of SRAM in its real-time clock domain and 448 KB of ROM, which holds the bootloader.
- The ESP32 datasheet gives a high-level input of at most supply + 0.3 V, which is 3.6 V on a 3.3 V supply, and says stresses above the absolute maximum ratings may cause permanent damage. For an STM32, check each pin in its own datasheet before wiring 5 V to it.
- The Arduino IDE reaches all three families through add-on "cores": the AVR core from Arduino, Arduino-ESP32 from Espressif and STM32duino. Espressif's own framework, ESP-IDF, runs the FreeRTOS kernel on both ESP32 cores and calls your app_main() from a task.
- The Uno's sketch may use at most 32,256 of the 32,768 bytes of flash: the other 512 hold the optiboot bootloader, and avrdude talks to it at 115,200 baud. On the ESP32 the auto-reset uses the bridge's DTR and RTS lines; you can also hold Boot and press EN by hand.
- Arduino UNO R3 product datasheet (A000066)
- Arduino AVR core: boards.txt (Uno upload speed, flash size and bootloader)
- Espressif ESP32 Series datasheet v5.3
- Espressif ESP32-DevKitC V4 user guide
- Espressif esptool: boot mode selection
- Espressif Arduino-ESP32: getting started
- Espressif ESP-IDF programming guide: FreeRTOS
- Zephyr Project: ST STM32F4 Discovery board (hardware summary)
- STM32duino: Arduino core for STM32
Quiz Unlocks after the last step.