The Raspberry Pi vs. the Arduino — How to decide which to use?
By: Diego Eguez
Tags: Raspberry Pi, Computers, Arduino, Microcontrollers

Legobots by Jelleke Vanooteghem

I grew up with the phrase let the tool make the job, which is an elegant way of saying choose the right tool. I’ve often heard arguments about why the Arduino is better or how the Raspberry Pi is superior. The truth is they’re different tools meant to solve different problems. It is no about which is better, but where is each one better? In this article I explore the cases where one platform outperforms the other, based on my personal experience.

The Arduino

The Arduino is a microcontroller. This implies that the RAM, Flash Memory and processor are all packed into a single package. In my experience Arduinos (microcontrollers), shine in the following scenarios:

Ease of use: The Arduino IDE provides a simple quick way to start developing. You need little (to no knowledge about it), to start running your first program; the IDE allows you to simply upload and test programs (without writing a line of code). Additionally, there are hundreds of libraries created for the Arduino, allowing effortless interfacing with external devices (sensors, communication modules, etc.). Manufacturers like SparkFun or Adafruit, even create and provide tutorials of these libraries. *If you’re looking for a better IDE, check out PlatformIO.

The Arduino IDE provides a simple quick way to start developing. You need little (to no knowledge about it), to start running your first program; the IDE allows you to simply upload and test programs (without writing a line of code). Additionally, there are hundreds of libraries created for the Arduino, allowing effortless interfacing with external devices (sensors, communication modules, etc.). Manufacturers like SparkFun or Adafruit, even create and provide tutorials of these libraries. *If you’re looking for a better IDE, check out PlatformIO. Low power consumption : Unlike a computer, a microcontroller consumes significantly less power, some gadgets can last years with AA bateries. Furthermore, alternatives like the ESP32 are fantastic when trying to save power, they can go down to 10µA in deep sleep mode. Note real power consumption will vary depending on the board you’re using (and the modifications you make).

: Unlike a computer, a microcontroller consumes significantly less power, some gadgets can last years with AA bateries. Furthermore, alternatives like the ESP32 are fantastic when trying to save power, they can go down to 10µA in deep sleep mode. Note real power consumption will vary depending on the board you’re using (and the modifications you make). Small data processing and throughput: Microcontrollers tend to have lower clock rates, memory, and communication interfaces than computers (SBCs). For example the Arduino Uno runs at 16MHz (clock speed) and has 2Kb of SRAM (memory), while the Raspberry Pi 4b comes with a quad-core 1.5GHz processor (clock speed) and at least 2Gb of RAM (memory). So if you want to read data (sensors), manage actuators (motors, LEDs, etc.), exchange a few kilobytes of data and perform a few mathematical operations, the Arduino is your best option.

Microcontrollers tend to have lower clock rates, memory, and communication interfaces than computers (SBCs). For example the Arduino Uno runs at 16MHz (clock speed) and has 2Kb of SRAM (memory), while the Raspberry Pi 4b comes with a quad-core 1.5GHz processor (clock speed) and at least 2Gb of RAM (memory). So if you want to read data (sensors), manage actuators (motors, LEDs, etc.), exchange a few kilobytes of data and perform a few mathematical operations, the Arduino is your best option. Do one thing at the time: In most applications it doesn’t matter if you waste a few milliseconds reading data, managing actuators or transmitting data; but sometimes time becomes a problem. For example you may be controlling a stepper motor based on a PID control; where the motor speed is regulated based on the PID feedback. To control the speed you need to reduce the time between the steps of the motor; however the sensor needs to be periodically read so the PID can work (See where I’m going?). There comes a point, where you cannot go faster, because the time to read the sensor takes longer than the time between steps. To solve this you can try using timer interrupts or a microcontroller (like the ESP32) which has multiple cores and allows multithreaded programming. Although in my experience, this quickly becomes a headache. You have to be extremely careful with the times in the interrupt routines; or protect against race-conditions when using a multi-core processor. My suggestion is to use an Arduino to do one thing at the time.

In most applications it doesn’t matter if you waste a few milliseconds reading data, managing actuators or transmitting data; but sometimes time becomes a problem. For example you may be controlling a stepper motor based on a PID control; where the motor speed is regulated based on the PID feedback. To control the speed you need to reduce the time between the steps of the motor; however the sensor needs to be periodically read so the PID can work (See where I’m going?). There comes a point, where you cannot go faster, because the time to read the sensor takes longer than the time between steps. To solve this you can try using timer interrupts or a microcontroller (like the ESP32) which has multiple cores and allows multithreaded programming. Although in my experience, this quickly becomes a headache. You have to be extremely careful with the times in the interrupt routines; or protect against race-conditions when using a multi-core processor. My suggestion is to use an Arduino to do one thing at the time. Price: You can buy a Raspberry Pi Zero for around $10, but an ATTiny85 costs around $2. In few words, microcontrollers are cheaper. The ATTiny85 belongs to the same family of microcontrollers, than those used by Arduino. They are practically the same, though you should be careful about the reduced number of pins and the method in which you upload the program.

The Rasberry Pi

The Raspberry Pi is a single board computer (SBC). It works as a regular computer (some just use it a computer) and allows interfacing with external devices through the 40 pin GPIO. I believe the Raspberry Pi performs better in the following situations:

Screens: Creating complex user interfaces (frontend development) is not easy. As a computer, the Raspberry Pi can run popular frontend technologies, like Electron (with Angular or React,), JavaFX, QT5, TkInter, etc. With these technologies it is posible to create outlandish interfaces. So while it is possible to use screens with the Arduino; if you need to do something more than to display data, the Raspberry Pi is a better option.

Creating complex user interfaces (frontend development) is not easy. As a computer, the Raspberry Pi can run popular frontend technologies, like Electron (with Angular or React,), JavaFX, QT5, TkInter, etc. With these technologies it is posible to create outlandish interfaces. So while it is possible to use screens with the Arduino; if you need to do something more than to display data, the Raspberry Pi is a better option. Versatility: In Arduino you’re tied to C++, Python and a few other alternatives (though it is better to stick with C++ due the available libraries). With the Raspberry Pi, you can choose virtually any language that provides support for the GPIO pins (if you’re planning to use them). You can even mix languages; I personally prefer to use Typescript for the front-end, and Python for GPIO manipulation (backend). Please note, the most popular GPIO libraries are written in Python.

In Arduino you’re tied to C++, Python and a few other alternatives (though it is better to stick with C++ due the available libraries). With the Raspberry Pi, you can choose virtually any language that provides support for the GPIO pins (if you’re planning to use them). You can even mix languages; I personally prefer to use Typescript for the front-end, and Python for GPIO manipulation (backend). Please note, the most popular GPIO libraries are written in Python. Machine learning (ML): Nowadays, ML has become ubiquitous in data science. Though you can find ML implementations for the Arduino, like TFLite; the Raspberry Pi shines in heavy workloads. If your application is centered around ML, you should check the NVIDIA Jetson Nano (it has a GPU).

Nowadays, ML has become ubiquitous in data science. Though you can find ML implementations for the Arduino, like TFLite; the Raspberry Pi shines in heavy workloads. If your application is centered around ML, you should check the NVIDIA Jetson Nano (it has a GPU). Multi-threading: If you need to do multiple tasks at the same time, the RaspberryPi is the perfect option. Java, Python, JavaScript and other languages allow a better asynchronous experience.

If you need to do multiple tasks at the same time, the RaspberryPi is the perfect option. Java, Python, JavaScript and other languages allow a better asynchronous experience. Cameras: Image and video consume lots of memory and CPU (when being manipulated). The Raspberry Pi has an easier time with them.

As with the Arduino, there are many alternatives to the Raspberry Pi. Be sure to check out the LattePanda, NVIDIA Jetson Nano, Rock Pi and other boards.

Final thoughts

The Arduino and the Raspberry Pi are optimized to solve different problems. I’ve laid out the base guidelines to determine where each platform performs best or is easier to use. I’m sure there are cases that go against what I’m suggesting, so please don’t take these guidelines as strict rules. I hope they can help you choose the right platform for your next project!