Raspberry Pi...

Or, as it is often known, RasPi. I think that RasPi is actually an acronym which stands for, Really abysmal support Pathetic interface and that is my opinion based on many hours of trying to get to grips with a RasPi 3 which I originally purchased to make a NAS (Network Attached Storage) server.

Why is it not performing that role now? Because it was useless and turned out to be slower than the old Iomega NAS drive that I wanted to replace. That's why the RasPi ended up on my workbench alongside my Arduinos and other hardware. To say that I am a RasPi enthusiast is stretching credulity but I do respect the work that went into it and the original, intention of the designers and the foundation behind the RasPi.

With no other access to IT equipment, the RasPi provides a self contained platform, in the form of a Linux Personal Computer, and IO ports to allow other hardware devices such as sensors etc. to be attached and controlled. Video output is either HDMI or CVB so that older video monitors can be used if nothing better is available. The concept is sound and the hardware design, in general meets the aims of the designers but, the RasPi does not stand up against the alternatives where IO pins are concerned.

The RasPi has a built-in Linux kernel and associated file system, device control and GUIs to make life easier. Depending on the model, the RasPi also can have an Ethernet port, Wi-Fi and Bluetooth so the whole bundle makes up a self contained computer. Ironically, a lot of RasPi users run what is called a "Headless setup" opting to interface with the Linux environment using (SSH) RDP from a PC or, for the truly masochistic, a tablet or phone. The attraction must be the input/output interface then? Well, as IO interfaces go, the RasPi is not very impressive as it has no ADC, limited PWM facilities. It does have a Serial port as well as SPI and I2C but implementing and using these ports is not for the feint hearted.

The RasPi is designed to boot off of and run from a SD Card which is fine if you don't mind the slow performance of SD and you remember that SD is Flash memory which will eventually deteriorate. The RasPi 3 introduced the ability to boot from USB devices and (in theory) even a USB hard disk but, despite my best efforts, I can only get the RasPi 3 to boot from a SD card and then run from a USB hard disk. This is a serious drawback but, as I mentioned before, if you have no alternative, it's better than nothing. What I fail to comprehend is why RasPi users who already have a PC choose to use the RasPi at all especially when they use the PC to RDP or SSH to the RasPi. What is the point?

If it's IO ports that you're looking for, the RasPi is certainly not the best option but, the Arduino is. The Arduino IO ports offer ADC, PWM, Shift-in and Shift-out as well as the usual I2C, SPI and Serial ports. The Arduino is "easier to program" as long as you stick to c/c++ but this is, in my opinion, the best way to write code anyway. The Arduino IDE runs on Windows, Linux and even Raspbian so why try to dumb down programming with tools such as Scratch?

Item RasPi 3 Arduino UNO Comment
IO pins 17* 20** * Digital IO only** Multi-purpose, see below
ADC pins 0 5* * ADC pins are multi-purpose and part of the total pin count of 20
PWM pins 0 6 * PWM pins are multi-purpose and part of the total pin count of 20
Timers with IO pins 0 3* * Timer/Counter pins are multi-purpose and part of the total pin count of 20
Serial ports 2* 1 * if Bluetooth is disabled and console output if reconfigured
SPI bus Yes Yes  
I2C bus Yes Yes  
Ethernet port Yes No* * Yes via add-on module
Bluetooth Yes No* * Yes via add-on module
USB ports 4** 1* * Used for Serial coms to host and uploading programs** limited power designed for USB Flash drives and self-powered devices
Video output Yes* No * HDMI and CVBS
Audio output Yes* No * via HDMI and CVBS connector
Programming languages * c/c++ * Python, Scratch, c/c++ (others available)
Primary interface for GPIO programs Bash Terminal Serial Terminal  

I must admit to being confused over the move back to interpreted programming languages such as Python and Scratch as, despite the power of the platform's CPU there will always be a significant loss of performance over compiled code such as c/c++ but I guess this is the way programming will be aimed in the future as these interpretted languages are very powerful. I'm old fashioned I'm afraid!

In an environment where there is access to PCs, the RasPi, in my opinion, is a solution looking desperately for a problem much as the microprocessor was in the mid 1970s when they became available to the hobbyist. The whole world and his brother looked for things to do with the new wonder microchips and the same situation has presented itself with every new device entering the market. OK, I'm an Arduinonaut but I can see that the RasPi and the Arduino are definitely horses of a different colour and it is very much a case of "Horses for courses".

Anyone starting out with a RasPi who is new to Linux and c/c++ is in for a rude awakening as Linux is a beast that is hard to tame. Add the task of coming to grips with c/c++, Python or whichever programming language you choose presents yet another huge learning curve. The Arduino has many advantages over the RasPi and the ironic fact is that to do anything serious regarding control and sensing requires additional hardware such as the RasPi Gertduino board but, hold on a minute, the Gertduino board is an Arduino UNO(ish) board with a header which plugs into the RasPi!

Put simply, if you don't have a PC, the RasPi will get you going with a Linux computer, Digital IO pins and a means to write programs to control them. If you have a PC an Arduino board can be purchased for about GBP 20.00 and with relatively little trouble, you will have a powerful Micro Controller which is certainly a lot more user friendly.

Unless you are capable of writing GUIs for Linux your primary interface with any programs you write is going to be a Bash Terminal on the RasPi or a Serial Terminal on a PC with the Arduino. The Linux Terminal is better as it is TTY compatible whereas the Arduino Serial Terminal is not fully TTY compatible. However, in practice. they both perform a similar function. Support in the form of built-in libraries is excellent on the Arduino whereas, on the RasPi, even the most basic functions take a lot of coding. There is a library suite called "wringPi" written by Gordon Henderson which very successfully brings some of the Arduino's "wiring" wiring.org.co functionality to the RasPi. If you are not familiar with "wiring", here are a few examples of it from the Arduino core for c/c++:

pinMode(<pin>, <mode>);    // sets the pin to either INPUT or OUTPUT

digitalWrite(<pin>, <value>);    // writes either HIGH or LOW to the pin

digitalRead(<pin>);    // returns the state of the pin as either HIGH (1) or LOW (0)

As you can see the "wiring" functions are easy to use. The Arduino IDE takes care of all the basic tasks in setting up the base libraries such as stdio, iostream etc. and presents the user with a simple programming environment which has just two functions called "setup()" and "loop()". You put your configuration statements in setup() and your actual program code in loop() and go from there. Notice that I did not mention the main() function and that's because it does not exist in the Arduino IDE environment that the user sees. Here is what really exists underneath:

#include <Arduino.h>int main(void){ setup();

for(;;) loop();}

void setup(void);    // the user onlt sees this

void loop(void);    // and this in the Arduino IDE

The user only sees the setup() and loop() functions because the Arduino IDE puts a wrapper around the actual environment. It is possible to program an Arduino without the Arduino wrapper just using traditional c/c++ tools such as your favorite editor, that's fine, you can but it's down to you to do all the groundwork. You can alos use an external editor with the Arduino IDE so it is very flexible.

Arduino provides full support for the ATmel AVR devices used on their boards (other processors are also used). Libraries for the Arduino are c++ classes or groups of classes so writing your own libraries is very easy but, there is so much support for the Arduino that it is very likely that a library already exists for just about any hardware peripheral you might want to attach such as RTC, LCD, GPS etc., etc., etc.

My research so far has shown me that there is scant support for beginners and much of what there is assumes a working knowledge of both Linux and the chosen programming language. Linux requires a lot of command line configuration anyway but, trying to find how to enable, disable and configure the RasPi is difficult for the newcommer.

 

Workman with Jack Hammer