Skip to content
Tutorials Center
My learning

Topics

Lesson 13 of 36 ยท Microcontrollers and Boards

ESP32, ESP8266 and Raspberry Pi

Compare the main IoT boards: ESP32, ESP8266, Raspberry Pi, Pico and Arduino, with their features, Wi-Fi code, GPIO on Linux and a board-selection guide.

You now know what a microcontroller is. This lesson looks at the boards most IoT builders actually use, what makes each one suited to a job, and how code for each looks. The goal is not to memorize pinouts but to know which board to reach for.

The ESP32 family

The ESP32, from Espressif, became the default IoT microcontroller because it combines a fast dual-core CPU, Wi-Fi, Bluetooth Low Energy, many peripherals and low cost on one chip.

Feature Typical ESP32
CPU Dual-core Xtensa LX6 at up to 240 MHz (variants use RISC-V)
RAM About 320 KB SRAM (more with external PSRAM on some boards)
Flash 4 MB or more, external to the chip
Radio 2.4 GHz Wi-Fi, Bluetooth Classic and BLE
ADC Two 12-bit ADCs (non-linear; calibrate; ADC2 conflicts with Wi-Fi)
Extras Touch pins, DAC, I2S audio, hardware encryption, CAN, deep sleep, ULP co-processor

Newer variants: ESP32-S3 (AI acceleration, USB), ESP32-C3 and C6 (RISC-V, cheaper; C6 adds Wi-Fi 6, Thread and Zigbee), ESP32-H2 (Thread/Zigbee without Wi-Fi). The older ESP8266 is a single-core chip with Wi-Fi only and about 80 KB RAM: cheaper but limited, still common in plugs and bulbs.

A Wi-Fi sensor on ESP32 (Arduino framework)

C++
#include <WiFi.h>
#include <HTTPClient.h>

const char* SSID = "my-network";
const char* PASS = "my-password";        // never hard-code real secrets in shared code

void setup() {
  Serial.begin(115200);
  WiFi.begin(SSID, PASS);
  while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); }
  Serial.println(WiFi.localIP());
}

void loop() {
  float t = temperatureRead();           // on-chip sensor, just as a demo
  HTTPClient http;
  http.begin("http://example.local/api/readings");
  http.addHeader("Content-Type", "application/json");
  http.POST(String("{\"temp\":") + t + "}");
  http.end();
  delay(60000);
}

Use the manufacturer's tools: Arduino core, ESP-IDF (official C framework with FreeRTOS), PlatformIO or MicroPython. Provisioning (giving the device its Wi-Fi password) is handled in products by BLE or a captive portal rather than hard-coded text.

Raspberry Pi: a small Linux computer

The Raspberry Pi is a single-board computer (SBC). It runs Linux, has USB, Ethernet or Wi-Fi, HDMI, a camera connector and 40 GPIO pins. Use it as a gateway, a local server, a camera or AI node, or a prototype environment. It is overkill and power-hungry for a simple battery sensor.

Models: the Pi 4 and 5 are powerful desktops-in-miniature; the Pi Zero 2 W is tiny and cheap; compute modules go into products. GPIO is 3.3 V only and not 5 V tolerant. Python is the usual language:

Python
from gpiozero import LED, Button
from signal import pause

led = LED(17)
button = Button(2)
button.when_pressed = led.toggle
pause()

On Linux, GPIO is not real-time: the OS may delay your code by milliseconds, so use hardware PWM or a microcontroller for precise timing, and use libraries such as gpiozero, libgpiod or pigpio.

Raspberry Pi Pico (RP2040/RP2350)

The Pico is a microcontroller (not a Linux computer) with a dual-core ARM Cortex-M0+ at 133 MHz, 264 KB RAM, many GPIO pins and PIO state machines that implement custom protocols in hardware. The Pico W adds Wi-Fi and Bluetooth. It is a friendly, cheap board programmed in MicroPython, C/C++ or Arduino.

Other boards worth knowing

  • Arduino Uno/Nano (AVR): simple, 5 V, great for learning, no networking.
  • Arduino Nano 33 IoT / Nano ESP32 / Portenta: Arduino-branded boards with radios.
  • STM32 Nucleo: ARM boards for professional development with huge peripheral choice.
  • nRF52 and nRF5340 boards: ultra-low-power BLE, Thread and Zigbee.
  • Particle, Adafruit Feather, SparkFun Thing Plus: convenient ecosystems with battery chargers and add-on boards.
  • Jetson Nano / Coral: SBCs with machine-learning accelerators.
  • BeagleBone: Linux SBC with real-time co-processors.

Comparing boards by the numbers

Python Board comparison table with a filter

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.

Note how the sleep current spans four orders of magnitude, which is why a Pi is a poor choice for battery sensors.

Voltage and power practicalities

  • Check logic level: ESP32 and Pi are 3.3 V. Do not connect 5 V signals directly.
  • Power from USB for development; products use regulators or batteries (LiPo with a charger board).
  • An ESP32 draws peaks over 300 mA when Wi-Fi transmits. A weak supply causes random resets ("brownouts").
  • Add a bulk capacitor close to the module and use short thick power wires.
Python Will this supply cope with Wi-Fi peaks?

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.

Which board for which job?

Picking a board

Wi-Fi sensor ESP32 or ESP32-C3
Years on battery nRF52, STM32L, ESP32 deep sleep
Gateway or camera Raspberry Pi
Learning basics Arduino Uno or Pico

Start with the job, then pick the cheapest board that does it.

1 / 2

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which statement about the ESP32 is true?

    Built-in Wi-Fi and BLE are the main reasons for the ESP32's popularity.
  2. 2. Why is a Raspberry Pi a poor fit for a coin-cell sensor?

    Linux boards draw far too much power at idle for multi-year battery operation.
  3. 3. What is the logic level of Raspberry Pi GPIO pins?

    Applying 5 V to a Pi GPIO pin can damage the board.
  4. 4. What does the Raspberry Pi Pico offer that a full Pi does not?

    The Pico is a microcontroller board with predictable timing and PIO state machines.

Summary

  • ESP32 (and variants) is the default Wi-Fi/BLE microcontroller; ESP8266 is the older, cheaper cousin.
  • Raspberry Pi is a Linux computer for gateways, cameras and prototyping; Pico is a microcontroller.
  • Compare boards on CPU, RAM, radios, sleep current, price, logic level and ecosystem.
  • Provide enough supply current for radio peaks, and mind 3.3 V logic.

Next: MicroPython and Low-Power Design