Skip to content
Tutorials Center
My learning

Topics

Lesson 10 of 36 ยท Microcontrollers and Boards

Microcontrollers vs Microprocessors

Compare microcontrollers, microprocessors, SoCs and single-board computers for IoT, with memory, power and cost trade-offs and a simple board chooser.

Every IoT device needs a brain: a chip that reads the sensors, runs your logic and talks to the network. The choice of brain decides battery life, cost, what software you can run and how hard the device is to build and secure. Two families dominate: microcontrollers (MCUs) and microprocessors (MPUs). This lesson explains the difference, introduces the common architectures and gives you a method for choosing.

The key difference

A microprocessor is a CPU core that needs external parts to work: RAM, storage, power management and peripherals. It usually runs a full operating system such as Linux. A microcontroller puts the CPU, RAM, program flash and peripherals (GPIO, ADC, timers, UART, I2C, SPI) on one chip. You switch it on and it runs your single program, directly on the hardware.

Feature Microcontroller (MCU) Microprocessor (MPU / SoC)
Example ATmega328P, ESP32, STM32, nRF52, RP2040 Raspberry Pi's Broadcom chip, i.MX, Snapdragon
Clock 8 MHz to a few hundred MHz 500 MHz to several GHz
RAM 2 KB to a few MB 256 MB to many GB (external)
Storage KB to a few MB of on-chip flash SD card, eMMC, SSD
OS None ("bare metal") or an RTOS Linux, Android, Windows
Power Microwatts asleep, milliwatts running Hundreds of milliwatts to watts
Boot time Milliseconds Seconds to a minute
Real-time timing Excellent and predictable Harder (needs real-time Linux)
Cost $0.30 to $10 $5 to $100+

Rule of thumb: if the job is "read sensors, apply simple logic, send small messages, run on a battery", choose an MCU. If it needs heavy computation, a screen UI, a camera with machine learning or a standard server stack, choose an MPU or single-board computer.

Inside a microcontroller

flowchart LR
    CPU["CPU core"] --- BUS(("System bus"))
    BUS --- FL["Flash<br/>program + constants"]
    BUS --- RAM["SRAM<br/>variables + stack"]
    BUS --- GPIO["GPIO pins"]
    BUS --- ADC["ADC"]
    BUS --- TIM["Timers / PWM"]
    BUS --- COM["UART, I2C, SPI"]
    BUS --- RF["Radio (Wi-Fi / BLE)"]

Everything on one chip. Peripherals are controlled by writing to memory-mapped registers.

Important memory facts:

  • Flash (non-volatile) stores your program and constants. It survives power loss but wears out after about 10,000 to 100,000 erase cycles.
  • SRAM (volatile) holds variables, the stack and buffers. It is the scarce resource: running out causes crashes.
  • EEPROM or flash emulation stores settings, such as Wi-Fi credentials and calibration.
  • Peripherals do work in hardware (timers, PWM, ADC) so the CPU can sleep or do something else.

Architectures and families you will meet

Family Core Notes
AVR (ATmega328P, ATtiny) 8-bit Classic Arduino Uno and Nano; 2 KB RAM, 5 V or 3.3 V
ARM Cortex-M0/M4/M33 32-bit STM32, nRF52, RP2040: powerful, low power
ESP32 / ESP8266 Xtensa or RISC-V Built-in Wi-Fi and Bluetooth; the hobbyist and product favourite
PIC, MSP430 8/16-bit Very low power families used in industry
RISC-V MCUs 32-bit Open instruction set, growing quickly

A SoC (system on chip) integrates the CPU with radios and more. A module (such as ESP32-WROOM) is a SoC on a tiny board with antenna and flash, certified for radio use, so products can use it without redesigning RF hardware. A development board adds USB, a voltage regulator and pin headers so you can program it.

Bare metal, RTOS or Linux?

  • Bare metal: one loop() runs everything. Simple, tiny, fine for simple devices.
  • RTOS (FreeRTOS, Zephyr): lets you run several tasks with priorities, timers and queues, keeping deadlines even when work gets complicated. ESP32 firmware always runs FreeRTOS underneath.
  • Linux: file systems, networking stacks, Python and containers, at the price of boot time, power and a larger attack surface.

Memory budgeting

On a small MCU you count bytes. A float takes 4 bytes; a String of 100 characters takes about 100; a JSON document buffer can take 1 KB. The next simulation checks a firmware plan against a chip's limits.

Python Does this firmware fit in the chip?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The 8-bit AVR cannot hold TLS, which is why it is mostly used for simple sensor and control tasks, or paired with a separate Wi-Fi chip.

Power: the strongest argument for MCUs

A coin-cell sensor that wakes for a second every ten minutes can run for years on an MCU. A Linux computer cannot sleep that deeply. The calculation below compares average current.

Python Average current and battery life: MCU vs Linux board

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The Linux board cannot truly sleep, so its battery lasts hours or days instead of years.

A simple chooser

Python A toy board chooser

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What distinguishes a microcontroller from a microprocessor?

    MCUs are self-contained single-chip computers; MPUs rely on external RAM, storage and peripherals.
  2. 2. Which resource is usually the scarcest on a small MCU?

    Variables, stack and buffers live in SRAM, which may be only a few kilobytes.
  3. 3. Why does an MCU-based sensor last years on a battery while a Linux board does not?

    Deep sleep currents of an MCU are thousands of times lower than the idle power of a Linux board.
  4. 4. What does an RTOS such as FreeRTOS provide?

    An RTOS schedules several tasks predictably on a small chip.

Summary

  • MCUs integrate CPU, flash, SRAM and peripherals; MPUs run Linux with external memory.
  • Pick MCUs for low power, low cost and real-time; pick MPUs or SBCs for heavy compute and standard software.
  • Common families: AVR, ARM Cortex-M, ESP32, RP2040, nRF52, STM32.
  • Count flash and RAM, and choose bare metal, RTOS or Linux to match the job.

Next: Arduino Programming Basics