The robotics has gotten me very involved using Arduino systems which I had little experience with previously. That got me to thinking that a comparison of Arduino to Raspberry Pi would be good at this point.
Microcontroller vs General Purpose Computer
This is the big difference in the two. The Pi is a fully fledged general purpose computer capable of performing most of the tasks that a PC performs. It has a complete operating system, much more memory, a storage device, and a monitor and USB devices are supported. The Pi can easily multitask, running several programs at once. It also has excellent networking support, both wired and wireless.
The Arduino is a microcontroller. It has only a small amount of memory (2K RAM and 32K Flash) and runs a single program. This allows it to provide true real-time response. There is no USB support and adding networking is difficult and very limited. The advantage is that it starts up as soon as power is supplied and won’t be corrupted if power is lost. It also uses far less power and can easily run on batteries. An Arduino will happily run on 7-12 volts while the Pi must have a regulated 5V supply.
GPIO Capabilities
This is where the Arduino really shines. The Raspberry Pi provides 28 GPIO pins, but only one that provides PWM output and none that provide analog input. The typical Arduino also has 28 GPIO pins, but six of those can provide PWM output and another six can be analog inputs as well.
The Pi provides RS-232 as well as I2C, SPI, and 1-wire buses. The Arduino supports these as well.
Form Factors
Example Arduino Boards |
If we ignore the original version of the Pi (which I tend to do now) there are only two form factors available – the model 2 and the zero. The Arduino, however, is open-source, and comes in many sizes. The Uno is by far the most common, but my preferred version is the nano. I have also become quite fond of the ESP8226-01 Arduino compatible board. It may only have 2 GPIO pins, but it is extremely cheap, low power, and has built in wifi. I am starting to use it for IoT projects with great success.
Which to Choose
There is a fair amount of overlap in the capabilities of both systems, so many tasks could be performed by either device. However, there are some things that at best done with one or the other.
If you need:
- More than 2KB of RAM
- A very large program or multiple programs
- A network interface that can handle multiple clients or support more than one protocol
If you need:
- True real-time response to inputs
- Analog inputs
- PWM output for motors or servos
- Extremely low cost solution
- Battery powered
Then you should use an Arduino.
Yes, you can get analog input and PWM output on a raspberry Pi, but it requires additional hardware, which adds to the cost and complexity.
Sometimes you need the best of both worlds and will use a Pi and and Arduino. I have done this on one commercial project already and it worked very well.