Home / Learn / Code for makers

Arduino vs Raspberry Pi: which should you use?

New to this? Read from the top. Already know the basics? Jump to Going deeper for intermediate and advanced detail.

An Arduino board and a Raspberry Pi side by side: a microcontroller for direct hardware control and a Linux computer for bigger jobs
Beginner

Arduino and Raspberry Pi are the two names everyone hears first, and they're often compared as if they're the same kind of thing. They aren't. One is a microcontroller and one is a full computer, and that difference decides which suits your project.

The short answer

  • Arduino (and other microcontroller boards, including the Raspberry Pi Pico) runs one program, starts instantly, uses very little power and is excellent at reading sensors and controlling hardware precisely.
  • Raspberry Pi (the Pi 4, Pi 5 and similar) is a small Linux computer. It can run a desktop, a web server, Python with large libraries, a camera and AI models, but uses more power and takes time to boot.

Note the naming trap: the Raspberry Pi Pico is a microcontroller board, much more like an Arduino than like a Raspberry Pi 5.

Side by side

Microcontroller (Arduino, Pico, ESP32)Single board computer (Raspberry Pi 5)
RunsOne program, no operating systemLinux, many programs at once
Start-upInstantTens of seconds
Power useMilliamps, and microamps when asleepSeveral watts
Analogue inputsYes, built inNo, needs an add-on ADC chip
TimingPrecise and predictableCan be interrupted by the operating system
LanguagesC/C++ (Arduino), MicroPython, CircuitPythonAlmost anything, usually Python
StorageKilobytes to a few megabytesA memory card or SSD
Switching it offJust pull the powerBest shut down properly to protect the card

Choose a microcontroller when…

  • It runs on batteries for weeks or months.
  • You're reading sensors, driving motors or LEDs, or need precise timing.
  • It should work the moment it's powered on.
  • You're learning electronics. Fewer layers between your code and the hardware makes it easier to understand.

Choose a Raspberry Pi when…

  • You need a screen, a desktop, a camera or a web interface.
  • You want to run AI models locally, such as image recognition or small language models.
  • Your program needs lots of memory, storage or Python libraries.
  • It needs a full network stack: file sharing, a database, a home server.

What about AI projects?

For AI, the line is fairly clear. A Raspberry Pi 5 can run real models: image classifiers, object detection, speech recognition, and small language models (slowly). Add-on accelerator boards make vision models much faster.

Microcontrollers can run tiny models too, a field called TinyML, for jobs like recognising a wake word or a gesture from sensor data. Many projects combine both: a microcontroller handles the sensors and motors, and talks to a Pi or a cloud API that does the heavy AI work.

Using both together

A common pattern for robots and smart devices is a Raspberry Pi as the "brain", connected by USB or serial to a microcontroller that handles real-time hardware control. You get the best of both.

Not sure which microcontroller board to pick? See the best microcontroller boards for beginners.

Intermediate and advanced

Going deeper

Real-time behaviour

Linux on a Raspberry Pi shares the processor between many tasks, so a program that toggles a pin every millisecond may occasionally be delayed much longer while the system does something else. That's fine for most jobs, but not for generating precise pulses or reading fast signals. A microcontroller running one program, especially using hardware timers and interrupts, responds within microseconds every time.

Talking between a Pi and a microcontroller

The simplest link is USB: the microcontroller appears as a serial port. On the Pi, the pyserial library sends and receives lines of text:

import serial   # pip install pyserial

with serial.Serial("/dev/ttyACM0", 115200, timeout=1) as port:
    port.write(b"LED ON\n")
    reply = port.readline().decode().strip()
    print("Board replied:", reply)

The microcontroller reads each line and acts on it. Keep messages short and simple, and add a reply so the Pi knows the command arrived. The port name varies by board: list ports with python -m serial.tools.list_ports.

Other options include a UART connection on the GPIO pins, I²C (good for several devices on two wires) and SPI (faster, for displays and data-heavy sensors).

Voltage levels

Raspberry Pi GPIO pins use 3.3 V logic and are not 5 V tolerant. Connecting a 5 V Arduino's output straight to a Pi input can damage the Pi. Use a level shifter or a simple resistor divider on signals going into the Pi.

Power budgets

A Raspberry Pi 5 is designed to use its official 5 V, 5 A USB-C supply, especially when powering USB devices. A microcontroller can run for months on batteries if it spends most of its time in deep sleep and wakes only to take readings. That difference often decides the design: a battery-powered sensor is usually a microcontroller, sending data to a Pi or server that's plugged in.

Sources

The main references behind this guide. Numbers we worked out ourselves, such as the code outputs, come from running the code.