"If I can buy a Raspberry Pi so cheaply, why would I ever use an Arduino for an electronics project?"
I often hear this from people who are new to embedded programming and electronics. This post is the first of two, aimed at beginners in the embedded world. We'll go over some of the differences between a typical Arduino and a Raspberry Pi, and the reasons you might want to use one or the other for a project.
On The Surface
Let's look at the specs of the most common Arduinos (Arduino Uno or similar) and Raspberry Pi:
|Processor||16 MHz 8-bit||700MHz 32-bit|
|RAM||2 Kilobytes||512 Megabytes|
|Program Storage||32 Kilobytes||SD card, many gigabytes|
|Digital Pins||14 or more||17|
|Analog Pins||5 or more|
|Extra Interfaces||i2c, SPI, USB Serial device||i2c, SPI, USB host ports, camera, HDMI, composite video, audio output, ethernet|
|Price (approx)||$30AU (or more, or less)||$28.50-$35AU|
Seen at a glance like this, the choice seems to be simple. Except for the analog pins, a Raspberry Pi has dramatically more features than a typical Arduino for around the same price. But there are some differences.
The Fundamental Difference
An Arduino is a Microcontroller. It's a dedicated tiny computer that just runs your program when it starts up. It runs nothing else. This gives you simplicity. In terms of complexity, it's comparable to the controller in some microwave ovens or washing machines (although probably a bit more advanced.)
A Raspberry Pi is a Microprocessor System-on-a-Chip. In terms of complexity, Raspberry Pi is comparable to a desktop computer from the mid to late 1990s. It runs an entire operating system (Linux) and all of the functions built into that operating system, not just a single program. This gives you power and flexibility.
Power and flexibility are great, but there's almost always a trade-off. In this case, that tradeoff is added complexity.
Because the Raspberry Pi is a full featured Linux computer in a tiny package, it is exposed to whole categories of potential problems that simply couldn't occur on a microcontroller that just runs one simple program. For instance - configuration file errors, filesystem corruption, runaway processes locking up a system.
That's the largest fundamental difference, but there are lots of minor differences as well.
Can you spot the difference here? It's subtle, but if you spend a lot of time plugging in cables you'll notice it.
All of the pins on an Arduino are labelled clearly so you know what connector pin you're plugging in to. On the Raspberry Pi, you need to refer to a reference sheet each time. To make matters more confusing, there are least three different pin numbering schemes in active use for Raspberry Pi users!
The Raspberry Pi uses "3.3V Logic", which means that the digital pins are designed to work with no higher than 3.3 Volt levels. Most Arduinos use "5V Logic", so they can tolerate up to 5 Volt levels.
Depending on the devices you're attaching, this can be good or bad. Some devices are 3.3V, some are 5V.
There is some interoperability possible. A 5V input pin can also read from a 3.3V device's output pin, as 3.3V out is still "high enough" to count as a high level for a 5V input. The opposite isn't true though, a 5V output will damage a 3.3V input pin! You need level shifting circuitry to manage the difference.
This handy chart has a lot of information on it, but shows which families of input and output can work together.
Exceed the rated I/O voltage and you may see a puff of smoke as your device suddenly stops working! Raspberry Pis have a reputation for not tolerating 5V, even for a second.
This is a pretty clear cut difference. You can't read a variable (analog) voltage on a Raspberry Pi, without an external ADC (Analog to Digital Converter) device. The microcontroller on an Arduino has this built in.
DC Power Input
Both a Raspberry Pi and an Arduino can run on a 5V DC input, for example from a USB charger. Most Arduino models can also run on higher voltages using their onboard regulator, for example an Arduino Uno can run on anything in the range 6V-20V.
Unlike most Arduinos whie, are fairly accommodating about exactly what input voltage, Raspberry Pi is fussy. Pi boards have a reputation for needing a very good quality 5V input, to avoid random lockups and other problems.
A standard model Arduino uses less than 100mA of current (half a Watt of power), often much less. There are sleep mode software libraries like narcoleptic that give even lower consumption.
On the other hand, Raspberry Pi consumes substantially more current, 700mA-1200mA for model B. That's up six Watts of power! There are no sleep modes available to substantially reduce this.
Comparing arithmetic calculation speed, and the massively higher resources of the Raspberry Pi give it a very clear win.
In the following table, DMIPS stands for "Dhrystone Millions of Instructions per Second", and gives a rough estimate of the basic integer calculation speed of a device. MFLOPS stands for "Millions of Floating Point Operations per Second", and gives an estimate of the floating point calculation speed of a device.
|Mathematics Type||Arduino Performance||Raspberry Pi Performance|
|Integer||5.2 DMIPS||875 DMIPS|
|Floating Point||0.089 Linpack MFLOPS||280 Linpack MFLOPS|
Nearly 170 times faster at integer maths, and over 3000 times faster at floating point!
Remote Access, Encryption, USB Devices, HDMI, Video
These are all features the Raspberry Pi offers that typical Arduinos do not have.
Remote Access means you can use SSH and similar tools to login, check on, and update your programs remotely. There are some Arduino tools for remote bootloading via TFTP and the like, and you can serve up a web page over Ethernet or Wireless with the correct adapters, but there's nothing as flexible as a remote login.
Encryption, for example accessing HTTPS web pages, is only really possible with a Raspberry Pi's extra computing power.
Connecting USB devices is possible with the high end Arduino Due model (and compatibles), but you can still only connect mice and keyboards. You can connect nearly anything to a Raspberry Pi that you'd connect to full size desktop or laptop computer.
Both Arduino and Raspberry Pi are predominantly built around open source software. In the case of Raspberry Pi there are some closed source sofware components in the underlying hardware drivers.
Regarding hardware, Arduino designs are all offered under open source licenses. Most Arduino models have numerous compatible devices available in the marketplace, with different features and different price points.
Raspberry Pi hardware designs are proprietary, and the Broadcom System-on-a-chip is not available for purchase by the general public. So there are no 100% compatible Raspberry Pi compatible/clone devices.
In pragmatic terms, the closed source hardware probably won't have consequences for any one off project you build. It does mean that if you develop a prototype to eventually want to turn into a dedicated design, you can't use the Raspberry Pi design as a base to adapt on. However the new Raspberry Pi Compute Module somewhat solves that problem, as well.
Stay tuned for part 2 of this series, which will talk about the differences in "real time" operation between the two devices, and talk about some of the "best of both worlds" options out there.
Please leave a comment below if you know of other differences that people may want to consider when starting a project.
(NB: Due to some Creative Commons Non-Commercial licensed photos used - with gratitude - in this post, the content of this post is licensed Creative Commons Attribution Non-Commercial Share-Alike rather than just CC-BY-SA.)