Off-The-Shelf Hacker: Arduino or Raspberry Pi?
An Arduino is a microcontroller, too.
What gives? If they’re both microcontrollers, why would you use a Raspberry Pi in one situation and an Arduino in another? Clearly, they aren’t the same thing.
I get this question during my conference tech talks. Knowing the similarities, differences, function and capabilities of each microcontroller is definitely important when you’re hacking some “brains” into your off-the-shelf physical computing projects. Keep that term “physical computing”, in mind.
Exploring where you’d use one or the other is the subject of this week’s column.
Apples And Oranges
Summarizing similarities is a good place to start.
Both the Arduino and Raspberry Pi run on a microprocessor core, have some amount of on-board memory and storage, are certainly programmable, and have general purpose input/output (GPIO) pins that are accessible for the off-the-shelf hacker. They can be both easily purchased on the Web. Both modules also have huge developer communities, lots of support and proven track records of reliability.
From that description, you’d think the two are pretty similar and probably could do many of the same jobs.
You’d be correct.
But they also do some things, particularly physical computing tasks, in fairly markedly different ways.
Take a look at this chart of the Pi vs. Arduino features and capabilities.
|read inputs, calculations, set outputs
|7-12 volt input
|General Purpose I/O pins
|40 (digital only)
|14 (mixture of analog and digital)
|1 GB RAM
|Mainstream programming languages
|Integrated development environment(IDE)
|100 MB/s Ethernet
|No built-in networking
The function model line gives the first hint of why you might use an Arduino instead of a Raspberry Pi or vice-versa.
The fundamental concept of physical computing is to read some inputs, do a few calculations, then adjust some outputs, based on the inputs and resultant calculations.
Common sense suggests that a single-minded device, such as an Arduino, whose sole focus is performing those tasks, will be considerably faster in executing those jobs than a multitasking, multiuser operating environment device, such as the Raspberry Pi.
Use the following tips to get you started on how to pick a board and then expand your knowledge as you get experience prototyping projects.
Selection Tip #1 — The Need For Speed
If your project needs to read sensors, compare input values or calculate some results and change outputs at or near real-time, an Arduino type microcontroller is a good candidate for the project. Using an Arduino in a UAV (unmanned aerial vehicle) is a possible application. You might sense data from accelerometers or a GPS then change the speed of the rotors to keep the craft in stable flight.
If your project needs to read sensors, compare input values or calculate some results and change outputs at or near real-time, an Arduino type microcontroller is a good candidate for the project.
This job wouldn’t really be suitable for a Raspberry Pi. The multitasking nature of the Pi’s operating environment (Linux) doesn’t lend itself very well to keeping an eye on how an accelerometer reacts to movement then instantly adjusting rotor speed. Sure, the general purpose input and outputs are important to the Pi and can be optimized for speed. Today, they simply can’t react as quickly as an Arduino.
Selection Tip #2 — Sophisticated Interfaces
Say you want to run videos on your wearable to attract attention when talking to potential customers at your conference booth.
While an Arduino can light up a TFT color display and cycle through bit-mapped pictures stored on its micro-SD card, there’s no way it will ever be able to run your custom-made, full-color, 5 MB mp4 video at 30 frames per second, on that little LCD screen.
The Pi can perform that feat without even breaking a sweat.
Not only can you set the Pi up to show the video, you can also use the GPIO pins to read switches or light up LEDs and run motors, via pulse width modulation (PWM). Add a USB WiFi module or esp8266 module and your wearable can consume data and interact with other programs over the Internet.
You might also just run the Pi attached to an HDMI display with a wireless keyboard/mousepad hooked up to one of the USB ports. There are quite a few desktops that will run on a standard load of Raspbian Linux, the typical default operating system. The Arduino has no video output, much less a cool desktop on an HDMI big-screen.
Bottom line, if your project needs a sophisticated user interface, the Pi is your device.
Selection Tip #3 — Clones Support Minimum Viable Projects (MVP)
Suppose you want to simply flash a few LEDs on a festive little Christmas pendant. Both the Pi and an Arduino can easily take care of that menial task.
Readers may have seen the recent news about the $5 Raspberry Pi Zero board. It features many of the capabilities of a full-sized Pi and is roughly half the size of a credit card. That’s a lot of power for the money.
Even the Pi Zero is overkill for a simple LED flashing project. An Arduino clone, like the Digispark, would be just the ticket. Yes, I know a Digispark costs roughly $8. Stick with me on this one.
The Digispark also uses a lot less power than even the Pi Zero, so a tiny battery will run it for a long time. It’s about 1/2” x 1/2” when you remove the USB printed circuit board header, making your pendant size and weight manageable for pinning on your shirt. Lastly, there are a couple of analog pins. The Pi only has digital pins, no analog. If there are any kind of analog inputs needed, like a potentiometer or strain gauge, the Digispark has you covered. You’ll need additional circuitry to make that happen with a Pi.
Not only that does it make sense for you to have to wait for your Pi powered pendant to boot up, where an Arduino clone will just start flashing the LEDs after a couple of seconds.
The message here is to match the microcontroller to the complexities of the job, not the other way around.
Arduino vs. Pi — It’s Up To You
I’ve given you a few ideas on how to select that “microcontroller” for your next physical computing project.
We’ve seen an avalanche of new microcontrollers appear in the last couple of years. Guess what…it isn’t slowing down a bit. New models are coming out all the time. Check out the ESP8266 and Pine64. Wow, where will those boards fit in? Be sure to share your ideas.
Off-the-shelf hackers have a tremendous selection of hardware choices, these days. And, it just keeps getting better.
Pick an appropriate board for your project and go build something cool.
BTW, I usually get a microcontroller or two as a Christmas present from a loved one. It’s not too late to drop a few hints of your own.