Arduino vs Raspberry Pi comparison

Posted at: 7:31 pm on May 10, 2015 by Ismail Uddin

A month or more ago, I finally decided to try my hands at theArduino, and got my hands on an Arduino Uno-based board from Hobby Components. These are cheaper clones of the original Arduino board, made possible since the actual design for an Arduino board is Open source. Unfortunately, a few weeks later, the dispute between the Arduino foundation’s founders was broughtto light (you can read about it here, here and here), which made me feel a bit guilty of not having supported the Arduino foundation. Nevertheless, I had an Arduino-like board and was ready to get my hands dirty with it!Before I delve into tutorials, I thought it would be worth outlining the key differences between Arduinos and Raspberry Pis!

How does anArduino differ froma Pi?

The main difference between a Pi and an Arduino, is that the Pi is a full-fledged computer capable of running operating systems such as Linux within which you can do all the programming, where as the Arduino is a microcontroller. An Arduino board can’trun OSs like Linux, in fact it’s processor is only 16 MHz and it has only 32 kb of memory! How could this possibly be better, you might wonder? In a variety of ways!

_DSC4906

Python vs C

With a Raspberry Pi, if you want to run a piece of code, you would need to have first installed an O/S such as Raspbian on the SD card, and run your code inside this OS. With Arduinos, you simply connect the board via the USB cable to your computer, and upload a code written in C to the board. The board can only run that code, and nothing else. The key here is that the code is written in C, which must be compiled before it can be run. This means your code is converted into ‘machine code’ that is uploaded to the Arduino, which can be executed very rapidly. Conversely, Raspberry Pi’s main coding language is Python, within which code is compiled (converted into ‘machine code’) on the fly as it is being run. This introduces a slight lag into the execution of code, making it not ideal for certain purposes we’ll talk about in a bit.

Great for sensors!

Another key difference between the two, is that Arduino boards feature an analogue-to-digital converter (ADC). This is useful for making measurements from variable dependent resistors such as thermistors, light dependent resistors, etc. Essentially, what the ADC does is to compare the voltage across your component (resistor, etc.)with a reference value (by default set at 0 V). This value can be any value up to 5V, and is measured with a precision of 1024 levels. That means increments of 4.88 mV can be measured accurately. This means you can use components such as a potentiometer to control your code! Making measurements of voltage across a resistor with a Raspberry Pi would need to be done using a complex arrangement involving a capacitor, through which the value is inferred based on the time constant of the capacitor. Furthermore, a Raspberry Pi operates mainly on 3.3V, as opposed to 5V,which most sensors workat.

_DSC4933

Better speed!

As mentioned earlier, Arduino microcontrollers run only a single pre-compiled C code. This code can run much faster than Python code, which must be compiled on the fly, making it more suitable for operating certain components such as Adafruit’s Neopixel LEDs (although, there has been an unofficial hack to get them to work on a Pi). Another advantage of running just one single code, is that once you power up the Arduino, it’s immediately running your code. With a Pi, you’d need to set up a script to run your code on start up, which itself can only run once the OS has fully booted. These minor things make setting up a project so much more simpler and quicker!

_DSC4914

Conclusion

So does that mean an Arduino is better than a Raspberry Pi? No, not necessarily. The way to see it, is that they’re two different kinds of boards which have different purposes. The Raspberry Pi is capable of more complex functions thanks to running a full fledged OS, whereas the Arduino is more optimised for controlling miniature electronics such as sensors, LCD screens, etc. Ultimately, the two can be combined together to build an even more powerful project. And of course, there are in fact many other alternative systems available on the market such as Beagle boards, Intel Galileo, etc. The Raspberry Pi and Arduino, however, remain to be the more popular choice currently. If you’re really getting into electronics and the maker community, I’d recommend you get yourself both!


Comments