Raspberry Pi or Arduino?

05 Nov

Raspberry Pi or Arduino?

Many people ask me if they should get an Arduino or a Raspberry Pi and the answer is quite simple: if you are a beginner, you should get an Arduino first and THEN get a Raspberry Pi. If not, it'll be an expensive and probably frustrating learning experience for most.

Purpose built

An Arduino is built as a learning platform. It has a very well thought out layout. It is very solid, so connecting incorrectly will very seldom destroy the hardware. Even with a full short circuit, the Arduino will just turn off and take the USB connection with it. Once you remove the short and replug the USB, the Arduino will happily keep running it's program.

With a Raspberry Pi it's quite different. The layout of the Raspberry Pi is crowded and the connector for hardware (the GPIO port) has a "male" connector. This means that the pins are not protected in any way, so if you accidentally short the wrong two pins you will kill the Pi. In most cases, you will not kill the processor itself, but you will most likely destroy the GPIO ports. There is no protection and no safety net.

A Raspberry Pi is also not made to be running 24 hrs a day, all year and it's not very suited for permanent installations. Arduino's on the other hand are pretty much made for this. They will do their job day and night for years without requiring any updates. A RasPi can't really be modified or shrunk in any way. An Arduino on the other hand is very easy to shrink down to a tiny board - perfect for permanent installations.

Playing with hardware

When you set out to learn to control hardware such as LED strips, sensors and robots, your life will be much easier with an Arduino. The Raspberry Pi can only supply a very limited amount of power, so even a simple task such as lighting a LED can be difficult if you don't have the right hardware.

The Arduino can use both 3.3V and 5V devices, but the Pi is a pure 3.3V device. This means that if you connect a 5V device to your Pi, you will probably damage it. I have however heard of many that are successfully using 5V devices with a Raspberry. YMMV but be aware that many things that you may want to connect to your Pi will require 5V. You can solve this by using a Level Shifter that changes the 5V signals to 3.3V, but this introduces complexity and cost.

Power is another issue. A Raspberry Pi requires a nice and steady power source. It is possible to power it with a battery, but it's nothing a beginner should attempt. The Arduino on the other hand has a battery connector that happily accept anything from 4.5V up to 12V. Since the Arduino regulates the power to what it needs, you can even use high power LIPO batteries.

Speed and RAM

If this is what you are after, the Raspberry Pi wins easily. Basically, a Raspberry Pi can run everything an Arduino can, but much faster. Since it's also multi-tasking, it can also do many things at once. I've made projects that has one program that downloads data off the web while another program handles the processing and display of this on hardware. To give you an idea of how much faster it is, check the video below.

This shows the same display running on both platforms. 6fps on Arduino vs 70fps on the RasPi. Both platforms runs the "same" code directly in C.

Differences

The chart below spells out the major differences.

  Raspberry Pi Arduino UNO
Price $39.95 $29.95
Size 85.60 × 53.98 mm 75 x 53 mm
CPU speed 700 16
Ram 512Mb 0.002Mb
     
External power no, but possible yes
Easy to add hardware no yes
Multi-tasking yes no
Network yes no, but possible
I2C and SPI comms yes (3.3V) yes (3.3V + 5V)
Video output yes no
Survives a shortcut no yes
Required hardware USB Cable, keyboard, mouse, power, SD card, network USB Cable

You can of course get the $25 RasPi that is missing networking and one USB port, but it's less fun then, isn't it? Arduino's on the other hand can be found much cheaper if you go for an unofficial board. A recent Indiegogo campaign delivers a complete Arduino starter kit (with components and USB cable) for just $9.

Computer vs MicroController

A Raspberry Pi is a full computer and it's great fun. It has a 700Mhz ARM processor with 512Mb of RAM soldered onto the processor. By comparison, an Arduino UNO runs on 16Mhz and has 2Kb of RAM. That's quite a difference (32 x speed, 256000 x the RAM ) but the two have their distinct advantages and disadvantages.

A Raspberry Pi is a computer that has RAM and a CPU. It is not an embedded system. It is a very cheap computer made for learning about computers. The Arduino is not a computer, but rather a MicroController (MCU). It has a CPU like the Raspberry, but inside the chip it also has permanent storage, RAM and other features. This is why the Arduino is Embedded. It has all the features "embedded" inside a single chip.

An Arduino requires only a USB cable and a host computer to get up and running. The host computer may in fact be a Raspberry Pi. A Pi will usually require a mouse, keyboard, monitor, network connection, power source, usb cable, SD card with OS on it and sometimes a little more than that. It is a full computer and requires what other computers do. It may well be the price of an Arduino but it will cost you more than just the board.

Getting started and getting help from the community

Getting started with Arduino does not require much. You download the Arduino IDE on your computer, plug in the device and start playing with hardware. There's tons of great examples online and there's a library available for pretty much whatever you may want to connect. The Arduino community has loads of great sites with tutorial content that will get beginners going. There's several minor forums, but the central Arduino forum is a fantastic place for knowledge.

With a RasPi it's different. You will need to either buy or make an SD card with the correct ISO image of the operating system. You can choose from many distributions and while nerds love this - beginners don't. Next you'll need to configure the keyboard correctly (can be daunting if you have a Norwegian one like I use), connect to the net, get familiar with the command line so you can install and update the OS / apps, then you can use C or install Python to write apps that can control hardware. If you choose the incorrect OS, you'll even get the joy of compiling the required GPIO libraries yourself and you'll definitely have to learn to edit config files to turn on I2C. While all of this is great fun to learn, it's really not suited for beginners. Adafruit's Occidentalis distribution takes some of the pain out of this, so go with that if you're just starting out with RasPi and hardware.

While the RasPi community is great, it does not have as many users that make friendly libraries for beginners to play with. The RasPi community is much more fragmented, expects you to know more, covers less ground and you'll need to get your hands dirty with "real" code and makefiles if you want to do anything out of the ordinary.

Summing up

As a computer, I find the Raspberry Pi to be frustratingly slow and unsuitable. It is however a great machine for many purposes. I will typically use it in scenarios where an Arduino is either too slow or where I need a display or network connectivity. I usually set the Raspberry up using a screen and keyboard, and then access it via SSH. But because it's so easy for beginners to connect wires wrong, a Raspberry Pi is not a good platform for learning how to interface hardware. While an Arduino is much slower, it's much more solid and thus more suited for beginners. My advice is to start with an Arduino and graduate to a Raspberry Pi when you know what you're doing.

05 November 2013 at 10:42 am

3 Responses to Raspberry Pi or Arduino?

  1. Grayson Moses 13 November 2013 at 5:14 pm #

    Hi, I wanted to leave a comment on your post here: http://flashgamer.com/arduino/comments/how-to-update-the-official-arduino-wifi-shield
    but there doesn’t seem to be a comments section on that particular post.

    I’m having trouble with my updated wifi shield on my Uno R3. I updated the firmware for 1.0.5 with no errors, but when I try to use my arduino, I get wifi.status() = 255; wifi shield not present. I’ve tried bridging pins 3 and 7, the jumper is off, tried it on a Due, etc etc. I have two shields that did this, and my friend had this same unsolved problem a month ago. I’ve asked on the arduino forum and emailed them, but so far have gotten no help. The shields worked fine before (I was having trouble with them, but they were at least recognized by the Unos.)

    Do you know what could be causing this problem? I’m at my wit’s end, and can’t figure out what’s wrong with the darn things.

    Thanks,
    Grayson

  2. Jensa 18 November 2013 at 9:58 am #

    Hi Grayson,
    Sorry about not keeping the comments open. Too many spammers, so I auto-close comments on older entries.

    I haven’t had that exact problem and to be honest - for most things that require network, I will use a Raspberry Pi (as written above). My biggest issue with the Wifi shield (and networking on Arduino in general) has always been it’s blocking nature. If you have a display + network, it’ll freeze the display while getting data and that just didn’t work for me.

    I assume the shield is an official one? If so, I would send an email to Arduino support. They’re quite responsive for anything bought through their store.

    J

  3. Grayson Moses 18 November 2013 at 5:00 pm #

    Thanks for the reply. I am using an official shield, and besides trying to get help on the forum for more than 2 weeks and getting zero replies, I’ve sent two emails to Arduino with not even so much as a confirmation email.

    I’ll try getting this to work with Pi’s I suppose. They should do what I need for now.

  4.