Arduino vs. Raspberry Pi: Which Board Is Best?
Two devices dominate the world of hobbyist electronics: The Arduino and the Raspberry Pi. Both can be found in workshops across the world. To the uninitiated, they might seem similar: they’re both circuit boards with resistors, capacitors and ICUs soldered to the top, and connections sprouting from the sides.
A closer look, however, reveals that the Arduino and the Raspberry Pi differ from one another in both architecture and purpose. We’ve written this guide to shed light on these differences and help you decide which will suit your purposes.
What’s a Raspberry Pi?
The first generation of the all-conquering Raspberry Pi came to market in 2012 and was devised as an educational tool that could help teach children to code. Since then, it’s gained traction outside of the classroom; amateur inventors across the world incorporate the RPi into a wide range of projects.
The latest version of the Raspberry Pi 3, the Model B+, comes with a 1.4Ghz quad-core processor and dual-band wireless LAN, along with an HDMI output to which you can connect your monitor or television, and various USB inputs that’ll accept mice, keyboards, and your mobile-phone charger. To learn more about the Raspberry pi, visit our post Getting Started with Raspberry Pi.
What’s an Arduino?
The Arduino first hit shelves in 2008 and was marketed as an open-source prototyping board for Atmel microcontrollers. A microcontroller, as we’ll discover, is something quite different from the microprocessor that powers the Raspberry Pi.
Arduinos can be easily connected to breadboards and augmented with specialized expansion boards called shields. Since the Arduino hardware is open-source, there are scores of variants to choose from. The most popular, the UNO Rev 3, is based on Atmel’s ATmega328. Included is everything needed to connect to the MCU, along with additional components like LEDs, voltage regulators, and a reset button.
A glance at each device’s significant specs is our first clue that they’re very different from one another. We’ve used the latest examples from each line, but others could just have easily have illustrated the point:
Arduino UNO Rev3
Clock 16Mhz
Memory 32kb
GPIO pins 14
Operating Voltage 5V
Raspberry Pi Model 3 B+
Clock 1.4Ghz
Memory 1 GB
GPIO pins 40
Operating Voltage 5V
The first thing that might leap out at you is that the Raspberry Pi’s Broadcom BCM2837 is clocked at 1.4Ghz while the Arduino’s Atmel microcontroller is clocked at 16Mhz. Some simple arithmetic should tell you that one is around hundred times faster than the other.
You’ll find similar discrepancies in other areas. A Raspberry Pi boasts 1 GB of RAM, while the Arduino offers just a few kilobytes. An Arduino has a single USB port, while the Raspberry Pi has several, along with HDMI, an RJ45 connector, and built-in wireless connectivity.
So why, you might wonder, is the Arduino so popular when the Raspberry Pi has the better of it in so many key areas? To find the answer, we need to explore the differences between a microprocessor and a microcontroller.
So what’s the difference between a microcontroller and a microprocessor?
As we’ve mentioned, at the center of every Arduino is a black IC unit called a microcontroller. Whether it’s an older 28 pin DIP (dual-inline-pin) package or a more modern SMD (surface-mounted-device) one, this little chip contains everything needed to actually compute stuff: there’s a microprocessor, a timer, some memory, and the I/O ports through which the MCU communicates with the outside world. It’s this component that actually does the work of the Arduino; the rest of the board and the Arduino software is there to help you interface with it.
The Raspberry Pi works very differently, and shares much in common with a desktop PC. At its core is a Broadcom CPU, which is connected to RAM, external storage and ports elsewhere on the board. It runs an operating system that handles the computer’s basic functions, runs programs, controls the HDMI, USB and RJ45 ports, and renders a graphical interface to display to the user.
This architecture allows the Raspberry Pi to do things that the Arduino and its microcontroller could never do. But for some applications, a full-fledged computer of this sort would be cumbersome and unnecessary. Consider the circuitry in your computer keyboard. It’s there to monitor a set of switches for activity, and report keystroke events to your computer. You’ll find scores of devices around the home containing tiny microcontroller units which, unburdened by resource-hungry features like operating systems or GUIs (or even bootloaders), are able to their jobs cheaply and efficiently.
Operating System
As standard, Raspberry Pi runs a specialized version of Linux known as Raspbian. It’s been optimized for the Pi, with the aim of making the best use of the architecture of the board and thereby delivering the slickest possible user experience. With that said, there’s nothing to stop creative Pi users from installing an entirely different operating system onto their unit. There are dozens to choose from, including Ubuntu, OSMC and RetroPie; as such, each Raspberry Pi unit is just a fresh distro away from becoming a games console or a media center.
Though around 2KB of the Arduino’s flash storage is devoted to a special piece of firmware called a bootloader, it lacks a full-fledged operating system, and thus doesn’t run programs in the same way as Raspberry Pi. Instead, it’ll boot up and perform the instructions you’ve provided using the Arduino IDE, which will run on Windows, Mac or Linux-based machines (including the Raspberry Pi).
Consequently, you’ll be doing your actual programming on a separate machine. Which brings us to another important consideration: cost!
Costs
In terms of cost, the two devices are comparable, with the latest RPI weighing in at $35 and the Arduino UNO coming in at a relatively svelte $20. Each family of devices is relatively broad, however; the smallest Raspberry Pi, the Raspberry Pi Zero, costs only $5.
In the case of Arduino in particular, the investment probably won’t stop there. Your ambitions might necessitate the purchase of a stackable shield or two, or a collection of resistors, sensors, patch cables and IC units. What’s more, as soon as you’ve finished one project and begin to comprehend the possibilities unfolding before you, you’ll probably order more and more components, along with the tiny little drawers in which to conveniently store them. On top of this, there’s the cost of a device capable of hosting the Arduino IDE.
By contrast, the software-driven approach of Raspberry Pi requires just a few extra components: you’ll need a monitor, a mouse and a keyboard, along with the cables necessary to hook everything together.
Getting your first programs written
Before you can get going with the Raspberry Pi, you’ll need to get your operating system installed and configured. Fortunately, there’s a handy zip file that makes doing this quite straightforward: it’s called, appropriately enough, NOOBS.
To get started with Arduino, you’ll need to install the IDE on a computer or tablet that’s connected to your Arduino over USB. Then you’ll be able to create your first project, which will probably involve making an LED flash. You’ll cram the legs of the LED into the header and compile a program that’ll make it switch on and off. To prevent your LED from burning out, you might attach a small resistor and a breadboard.
Given its purpose as an educational tool for would-be coders, you’d expect the Raspberry Pi to support a healthy range of programming languages. And so it does.
For first-time coders, the obvious choice is Python (from which the ‘Pi’ in Raspberry Pi is drawn). It’s high-level and intuitive, boasting a syntax that even beginners can easily pick up. Moreover, it’s an ‘interpreted’ language, which is translated as it runs (as opposed to a ‘compiled’ language that must be written into machine-code beforehand).
Raspbian comes preloaded with a Python IDE known as IDLE 3, which is powerful enough to create sophisticated programs. It’s not the only game in town, however: very young programmers might want to get started with Scratch (with a capital S), while more experienced ones can eventually make the leap to C, C++ or Java.
Since the Arduino lacks an interpreter, its code must be written, compiled and uploaded onto the Atmel chip before it’ll run. When you’re happy with your code, you press upload. The IDE will run an error check before compiling the code and the attached library files and sending the result to the Arduino. On its way to the compiler, your code will be processed to turn it into a C++ program, and then machine-readable instructions.
The interpretive nature of something like Python makes debugging less painful. Whenever errors crop up, you’ll be able to see them in real-time. While the Arduino IDE does come with tools like the Serial Monitor which help to identify bugs, it still presents considerable potential for frustration. In the case of a complex Arduino project, you might spend hours looking for a missing semicolon!
High-level versus low-level
If you’re new to the world of programming, it might not be clear what the terms ‘low-level’ and ‘high-level’ really mean. Let’s take a moment to consider them.
When you’re trying to visualize the goings-on inside a computer, it’s useful to imagine a hierarchy of abstraction. At the bottom, you’ll find the machine-code that allow computers to work. At the top, you’ll find the graphical user interfaces with which users can easily interact.
Between these two extremes you’ll find imaginary ‘levels’ of abstraction, whose lower tiers are inhabited by low-level ‘assembly’ languages, and whose higher tiers house more abstract languages like Python. Arduino tends to sit toward the bottom of this hierarchy, while the Raspberry Pi, with its support for a range of high-level languages, sits closer to the top.
Since low-level languages more closely approximate machine code, they tend to be more efficient. But this comes at the cost of ease of understanding. If you’re a total newcomer to the world of programming, then this might be something to consider.
With that said, that doesn’t mean that the Arduino is unsuitable for absolute beginners. If you have a little patience, a basic understanding of the principles of coding, and you’re the sort of person who can take satisfaction in finding and eliminating those niggling problems, then the Arduino might well be for you.
Graphics
Having more computational resources allows the Raspberry Pi to tackle large amounts of data, and present that data in interesting ways. If you’d like to draw a bar chart whose contents are constantly evolving, then a Raspberry Pi might be the best means of doing so. It’s even great for driving complex real-world machinery with multiple moving parts. If your project involves complex calculations, video and touchscreens then it’s likely beyond the capabilities of a low-powered microcontroller like that of the Arduino.
If your data-processing needs are simpler, however, then Arduino is probably a better match for your requirements. It’ll happily sit and read the voltage on a given pin over and over again until it reaches a certain threshold, only then performing the associated action. For such applications, operating systems and fancy graphical displays are overkill. But that doesn’t necessarily imply that Arduino-powered projects are always small and simple – by plugging in a few shift registers, LED drivers and multiplexers, you can expand the connective potential of the humble Arduino, and have it fulfill all kinds of roles. All you need to do is connect the pins in the right way.
Connectivity
The two systems both come with an array of General-Purpose-Inputs-and-Outputs (or GPIOs). Newer Raspberry Pi devices come with forty pins, while the Arduino UNO boasts fourteen. These pins can be set to high or low, or to read an incoming voltage. On each device, specific pins can be configured to deal with specific serial protocols, including SPI, I2C and UART.
You’ll even be able to simulate a voltage between 0 and 5 by instructing a pin to rapidly switch on and off. This technique is known as Pulse-Width Modulation. By modulating the length of each ‘on’ signal, you’ll be able to digitally control the apparent brightness of an LED, or the speed of a motor.
The Raspberry Pi boasts on-board connectivity modules that make it suitable for Internet-of-Things projects. There’s no need to mess around with Bluetooth and WiFi expansions; everything’s incorporated into a single device. So, if you’d like to be able to turn the lights on and off with an email (which you obviously want to do), the Raspberry Pi will allow you to do it.
With that said, snapping an ESP8266-equipped WiFi shield onto the top of an Arduino isn’t terribly difficult. Moreover, there exist Arduino variants which incorporate wireless internet, such as the MKR1000, which combines 2.4Ghz 802.11 b/g/n Wi-Fi with a low-power MCU. A range of manufacturers have created specialized Arduino devices to suit just about every purpose – and once you’ve mastered Arduino on one of them, you’ll be able to apply that knowledge to the others.
How much power?
Power consumption is a big deal for many projects. If you’re building a remote-controlled car, for instance, then you’ll need a board that can receive signals, activate motors and perform all the associated computing without the aid of a wall adapter, and which doesn’t drain batteries flat within a few hours.
The Raspberry Pi 3 Model B+ idles at around 1.7W. If you’re using the smaller Raspberry Pi Zero, then this drops to around 0.4W. Compare this to the Arduino UNO, which will run code at around 0.14W, and you start to see that the Arduino naturally suits stripped-down, battery-driven projects.
Whichever device you opt for, you’ll be able to improve its energy-efficiency in several ways. Not only are there multiple variants of both the Arduino and the Raspberry Pi to choose from, but you’ll be able to adjust your system for maximum power-efficiency. If you no longer need the display on your RPI, for example, then you can save power by disabling the HDMI ports. Tailor your Raspberry Pi to the needs of your project, and it might well run for considerably longer on the same battery.
Another complication comes in the form of power interruptions. When an operating system like Windows or Raspbian is denied power without warning, the result can be corrupted code and software problems. If you’re midway through writing to a particular memory location and the power is suddenly removed, the result is likely to be messy. That’s why desktop operating systems tend to insist upon being shut down properly. Older readers might recall the orange text on a black background which advised us all when it was safe to turn off the computer.
Since Arduino doesn’t run an operating system, this isn’t a problem. It will simply recommence running code as soon as it’s plugged back in. If you’d like to keep your Arduino device running constantly and wirelessly, you need only connect a 5v battery across the ground and 5v pins. You can either do this directly, or with the help of a battery-pack shield.
Finally, we should also consider that projects don’t tend to exist in isolation. If you’re going to have your Arduino activating servo motors, or driving scores of LEDs, then the power consumed by the microcontroller will pale into insignificance. The same applies to Raspberry Pis connected to enormous plasma televisions.
So which one is best?
If there’s one single conclusion to be drawn from all of this, it’s that while the two devices share superficial characteristics, they’re built to achieve vastly different ends.
Let’s consider an analogous comparison: that of a container truck and a moped. Like the Arduino and the Raspberry Pi, these vehicles share superficial commonalities: they both come with wheels, and they can both be used to transport things. But the truck comes with a more powerful engine, larger wheels, and the enormous fuel tank needed to carry heavy cargoes over long distances. Haulers looking to transport dozens of porcelain bathtubs across hundreds of miles will probably favor the power of the truck. By contrast, restaurants looking to deliver a dozen pizzas to a dozen different city-center addresses in a short timeframe will surely prefer the relative nimbleness of the moped.
But there’s no meaningful sense in which a truck is ‘better’ than a moped, any more than a Raspberry Pi is ‘better’ than an Arduino. They each have their relative strengths, which suit different purposes.
Generally speaking, the Arduino is built more for hardware-oriented projects, while the Raspberry Pi is geared more toward software. If you want to control circuitry, then the hands-on fun offered by the Arduino is difficult to beat. If you’d like to learn to code, then the Raspberry Pi makes the better option.
It might be that your project requires data-processing power and hardware control. That being the case, there’s nothing to stop you incorporating both a Raspberry Pi and an Arduino. The two can play nicely with one another with a bit of persuasion. What’s more, there exist several devices which bridge the gap between them. The UDOO family of single-board computers incorporate a Raspberry Pi and an Arduino onto the same device, while the Beaglebone Black is an effective rival for the Pi that comes equipped with an enormous amount of GPIO pins.
Both devices we’ve discussed here have had an explosive impact on the world of hobbyist electronics, helping millions of would-be inventors and amateur coders realize their visions. Whichever you choose, you’ll find resources out there to guide you on your quest – including some on these very pages!