Saturday, February 4, 2017

Can Raspberry Pi Zero Take Arduino Projects to New Greatness?

Although Arduino prices have gone down from their $35 price a couple years ago, they are still in the $20 range. This affects the cost of projects built with Arduino.

The Raspberry Pi Zero was introduced a few months back at an affordable $5 price point. Many, many articles have been published trying to compare the Raspberry Pi boards with Arduino. It is mostly apples vs. oranges. Why?

The Raspberry Pi boards are full Linux computers in affordable packages. Arduino is a microcontroller platform with great ease of use. Each has their strengths and weaknesses.

What I'd like to focus on is the Raspberry Pi Zero. We are starting to see more projects that use the Zero where previously you might have used an Arduino. Why would people do this? Is it appropriate everywhere? No. Let's see where a Pi might be more applicable than an Arduino.

1) Memory is more plentiful on a Pi. Doing some large number of things or controlling a large number of RGB LEDs for example, you can run out of memory on many Arduinos. Not so on a Pi.

2) Displays on Arduino tend to be small as it requires buffering in the microcontroller (memory intensive) or via a separate display with memory buffer (expensive). All Raspberry Pis support both HDMI and composite video.

3) Networking via wired or wireless is available on Arduino. But it isn't straightforward and the user must process a lot of things. Linux was born in the network world so there is a great deal of software built in to handle communications. All Pi models except Zero have a network jack, The Pi 3 has wireless. Pi wireless via USB us fine as software is usually available.

4) Audio is possible on Arduino with separate add-ons. It is built into the Pi. Recording audio is near impossible for any length of time due to memory but replay of wav files on SD card works fine as long as you are not doing much else.  If you use a Pi Zero, the best audio takes an add-on board also.

5) Size matters, and the Pi Zero is smaller than many Arduino boards.

6) Software: nearly any software package that has been written on a Linux system (apart from large server applications) often will run on a Pi, It is harder writing some complex specialized input/output programs or drivers that may not be available already. Use of Python easy, C and C++ is ok, specialized languages like Javascript, Perl, Ruby, PHP are all available. BASIC, FORTRAN, etc. can be found but they are not Pi optimized.

Where the Arduino wins over the Pi:

1) Analog input/output - the Pi series has no built-in analog inputs.

2) Real-time control - the Pi has Linux overhead so anything needing strict timing is better on Arduino if it fits.

3) Software: a huge amount of real-time software libraries have been written, mostly in C/C++. There are other languages like Micropython available but they are not widespread.

I'm a firm believer in taking a look at all available hardware and software to be informed on what is best for the application. I know something like the Pi 3 or Pi Zero will not be a replacement for an Arduino for some applications. But the Pi price point and capabilities makes sense for some projects that might take an Arduino with several add-ons or a more expensive variant.