What Is a Microcontroller? Parts, Examples and ESP32
A microcontroller is one chip with a CPU, RAM and programmable pins that runs a single program. How it works, how it differs from a Raspberry Pi, what to buy.
- Author
Mauro Brambilla- Published
- Reading time
- 8 min
- Category
- Guides

In short
A microcontroller is a single chip with a CPU, RAM and programmable pins that runs one firmware program. An ESP32 is one; a Raspberry Pi is a computer built on a microprocessor.
A microcontroller (MCU) is a computer shrunk onto one chip: a processor, working memory (SRAM) and programmable input/output pins that run a single firmware program, which reads sensors and drives LEDs, motors or displays. The ESP32 is a microcontroller. A Raspberry Pi is not, even though both fit in your hand.
This guide shows what is inside the chip, what runs when you power it on, how it differs from a microprocessor, and how to pick a first board. The numbers come from the datasheets and vendor pages linked at each claim, and the examples come from the code of OpenGizmo, three open-source gadgets that run on an ESP32-S3 or an ESP32-CAM.
- A microcontroller puts a CPU, SRAM and I/O pins on one chip and runs one firmware program
- The program lives in flash: inside the chip on an ATmega328P, on the module next to the chip on an ESP32
- A Raspberry Pi is a computer on an application processor: Linux, gigabytes of RAM, a microSD card
- ESP32 pins are 3.3 V logic and are not 5 V tolerant
What is inside a microcontroller?
A microcontroller is a complete small system, so a handful of blocks cover it. Each one maps to something you will touch in your first sketch.
CPU
The CPU executes your instructions one after another. Cores come in 8, 16 or 32 bits, from a few MHz to hundreds of MHz. The original ESP32 has two 32-bit Xtensa LX6 cores at up to 240 MHz, and Espressif's SoC page lists the ESP32-P4 at 400 MHz. An ATmega328P, the chip of the Arduino Uno R3, is an 8-bit AVR core that the Uno clocks at 16 MHz.
Flash: where the program lives
Flash is non-volatile memory that keeps your compiled firmware when the power is off. Where it sits depends on the chip. The ATmega328P has 32 KB of flash on the die. The ESP32 chip ESP32-D0WD-V3 has none: only the ESP32-U4WDH variant carries 4 MB in the package, according to the ESP32 datasheet (v5.3, ordering table). Most boards use a module that adds an external flash chip, so the flash size you see on a product page belongs to the module, not to the ESP32 silicon.
SRAM: working memory
SRAM holds variables, buffers and the stack while the program runs, and it is wiped at every reset. The Uno R3's ATmega328P has 2 KB. The original ESP32 has 520 KB. That is still thousands of times less than a Raspberry Pi 5 with its 1 GB to 16 GB, which is why you check the size of a library before you add it, and why a long-running program that allocates and frees memory can fragment its heap.
GPIO pins
GPIO stands for general-purpose input/output. A GPIO is a pin your code sets as a digital input (a button), a digital output (an LED or a relay driver), or, on pins wired to the converter, an analog input. The original ESP32 has 34 programmable GPIOs; the Uno R3 has 14 digital I/O pins and 6 analog inputs. Which pins are safe to use differs per chip and board: the XIAO ESP32-S3 pinout guide lists them for the board the OpenGizmo gadgets use.
Built-in peripherals
Peripherals are hardware blocks that do a repetitive job without the CPU:
- ADC: turns a voltage into a number
- PWM: pulses that set LED brightness or motor speed
- UART: serial link to a computer, a GPS or another chip
- I2C: two-wire bus for sensors, small displays and clocks
- SPI: faster bus for displays and SD cards
- Timers: exact delays, counters and pulses
The original ESP32 also integrates two 8-bit DACs, 10 capacitive touch inputs, Wi-Fi and Bluetooth (datasheet linked above). These extras differ by chip, so read the datasheet of the exact one you buy. One more note: older write-ups mention an ESP32 Hall sensor, but Espressif removed it from the datasheet in 2023 (revision history, PCN20221202).
How does a microcontroller run your code?
When power arrives, the chip runs a boot ROM, then a bootloader, then your firmware from flash. Arduino-style firmware has two functions: setup() runs once to configure pins and peripherals, and loop() runs again and again to read inputs, decide and write outputs. ESP-IDF, Espressif's own framework, starts at app_main() instead and expects you to create tasks.

Is there an operating system?
Small 8-bit chips such as the ATmega328P usually run bare metal: your code is the only thing running. The ESP32 is different. Its firmware runs on FreeRTOS, a small real-time kernel that schedules tasks. In the Arduino core for ESP32, app_main() creates a task named loopTask, and that task calls your setup() once and then loop() forever. A real-time kernel is not Linux, though: there is no file system, no user accounts and no process isolation unless you add them.
What is an interrupt?
An interrupt is a hardware signal that makes the CPU pause the current code, run a short function (the interrupt service routine, or ISR) and then resume. It lets a pin edge or a timer be handled without polling. A mechanical button bounces, so one press can fire several interrupts. Keep the ISR short and set a flag for loop() to act on. On the ESP32, the Arduino-ESP32 GPIO docs mark their example handlers with ARDUINO_ISR_ATTR, which keeps the handler in internal RAM.
Microcontroller vs microprocessor: what is the difference?
A microcontroller integrates the CPU, SRAM and I/O on one chip and runs one firmware program. A microprocessor is a CPU that relies on separate RAM, storage and I/O chips and usually runs an operating system such as Linux.

Be careful with the examples. A chip is not a board: a Raspberry Pi is a single-board computer built around a Broadcom SoC with an application-class CPU, and an ESP32 dev board is a board built around a microcontroller. The comparison below puts the two real products side by side.
| ESP32 (original) | Raspberry Pi 5 | |
|---|---|---|
| CPU | 2 × Xtensa LX6, up to 240 MHz | 4 × Arm Cortex-A76, 2.4 GHz |
| RAM | 520 KB SRAM | 1 GB to 16 GB LPDDR4X |
| Program storage | Flash on the module, typically 4 MB or more | microSD card or PCIe SSD |
| Software | One firmware on FreeRTOS | Raspberry Pi OS (Linux) |
Sources: ESP32 datasheet v5.3 and Raspberry Pi's Pi 5 page. The short version: pick a microcontroller to control hardware on little power, and a Pi when you need a browser, a database or a Linux service. Many products use both, with a microcontroller handling the real-time part beside the main processor.
How much power does a microcontroller use?
It depends on what is switched on, and the spread is huge. The ESP32 datasheet (Table 5-4, measured with a 3.3 V supply) gives about 240 mA while transmitting 802.11b, 180 mA for 802.11n MCS7, and 95 to 100 mA while receiving. At 3.3 V that works out to roughly 0.3 to 0.8 W with the radio working (my arithmetic, not a datasheet figure). In deep sleep the datasheet lists 10 µA with the RTC timer and RTC memory on, because only the RTC memory and its peripherals stay powered.
So a battery gadget lives or dies by its duty cycle: how long it sleeps between Wi-Fi bursts. The figures above are for the chip alone. A development board adds a USB-serial chip and regulator, so measure the whole board, as the deep-sleep current guide does.
What does the microcontroller do inside Gizmo Ticker?
The Gizmo Ticker uses a Seeed Studio XIAO ESP32-S3, which Seeed lists with a dual-core Xtensa LX7 up to 240 MHz and 8 MB of flash. Its firmware follows the pattern above. In main.cpp, setup() loads the saved settings, starts the Wi-Fi setup and the web server, and initializes the LED matrix. loop() checks the Wi-Fi, waits until the matrix finishes the current animation, then renders the next price message.
The pins are plain GPIO configured for hardware SPI. config.h sets DIN on GPIO 9, CS on GPIO 8 and CLK on GPIO 7 for the MAX7219 matrix. The display only receives data, so the firmware passes no MISO pin. Price requests run in a separate FreeRTOS task (marketDataFetch, created with xTaskCreate in api.cpp), so a slow network call does not freeze the scrolling. The other two gadgets follow the same shape: Gizmo Reolink Switch reads a button and drives a buzzer and an LCD, and Gizmo Camera serves photos from an ESP32-CAM.
Which microcontrollers are worth knowing?
Five chips are worth knowing. Numbers are from the vendors' pages as of November 2026.
| Chip | Core and clock | SRAM | Program flash |
|---|---|---|---|
| ESP32 (original) | 2 × Xtensa LX6, up to 240 MHz | 520 KB | External, on the module |
| ESP32-S3 (XIAO) | 2 × Xtensa LX7, up to 240 MHz | 512 KB | 8 MB on the XIAO ESP32-S3 |
| ATmega328P (Uno R3) | 8-bit AVR, 16 MHz on the Uno | 2 KB | 32 KB on the chip |
| RA4M1 (Uno R4) | Arm Cortex-M4, 48 MHz | 32 KB | 256 KB on the chip |
| RP2040 (Pico) | 2 × Arm Cortex-M0+, up to 133 MHz | 264 KB | 2 MB on the Pico board |
Sources: Arduino Uno R3, Uno R4 Minima, Raspberry Pi Pico the ESP32 and ESP32-S3 datasheets, and Seeed's XIAO ESP32-S3 page.
For connected projects, an ESP32 is my default, and which ESP32 chip to buy explains the variants: what the ESP32 is covers the family and ESP32 vs ESP8266 covers the older chip. For a learning board without Wi-Fi, an Uno is still fine. Note the Uno changed: the R3 uses the 8-bit ATmega328P, while the current Uno R4 uses a 32-bit Arm Cortex-M4.

Can I connect a 5 V sensor to an ESP32?
Not directly to a pin. The ESP32 runs its I/O at 3.3 V and the datasheet's high-level input limit is the supply voltage plus 0.3 V. A 5 V output, such as an Uno R3 pin (its IOREF is tied to 5 V), can damage the chip. Use a level shifter or a resistor divider on any signal that comes from a 5 V part, and check the sensor's own voltage range first: many I2C sensors accept 3.3 V.
How do you start programming a microcontroller?
- Pick a board. For a connected first project, an ESP32 dev board with a USB port works. Note that the on-board LED pin differs per board and some boards have none.
- Install a toolchain. The Arduino IDE 2 with the Espressif board package is the quickest start, and PlatformIO suits larger projects. The Arduino IDE vs PlatformIO comparison helps you choose.
- Upload a blink sketch. If your board defines
LED_BUILTIN, this blinks it once per second:
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
}- Add libraries. Install them with the Arduino IDE's Library Manager, or list them in
platformio.iniunderlib_deps. The Gizmo Ticker pins its versions that way inplatformio.ini:
lib_deps =
majicdesigns/MD_Parola@3.7.5
majicdesigns/MD_MAX72XX@3.5.1
bblanchon/ArduinoJson@7.2.2Every library costs flash and SRAM, so check the size after each one you add.
Where to go from here
A microcontroller is one chip with a CPU, SRAM and pins that runs one program, and on an ESP32 that program sits on FreeRTOS beside the Wi-Fi stack. Its limits are the point: kilobytes of RAM, 3.3 V pins and a radio that can draw 240 mA in a burst. This post did not run measurements of its own: the numbers are the vendors', and the exact figures change per chip and board revision.
Next, read what the ESP32 is to pick a variant, or follow the Gizmo Ticker build to see a finished firmware from setup() to the LED matrix.
Frequently asked questions
Find quick answers to the most common questions about this topic.
A microcontroller is a small chip that holds a processor, working memory (SRAM) and programmable input/output pins, and runs one program called firmware. It reads sensors and buttons, makes a decision and drives outputs such as LEDs, motors and displays. An ESP32 and an ATmega328P are both microcontrollers.
Author
Mauro BrambillaReady to build your own gizmo?
Pick an open-source ESP32 project and follow its step-by-step guide, from the parts list and wiring to the firmware and the first boot.






