Tuesday, April 2, 2013

Raspberry Pi

Today I want to have a ramble on about the diminutive Raspberry Pi. If you have not heard of the "Raspberry Pi" then let me fill you in. Firstly, it's not something you eat. It's the name of a very small, low cost, low power, silent computer. It is meant to be a very low cost computer for the education market, possibly in 3rd world countries.

By low cost, I mean really low at around $40 for the model B 512MB spec. Amazing as that is, there are a few gotchas with the Pi and the sticker price is one of them. You see, for this you don't get much - just a small white box with a circuit board in it basically. So the first thing you will want to get, and I suggest you do this at the same time, is buy a case for it. By case, I'm not talking a normal PC desktop case. This is about as big as a deck of cards. More than a few people have made cases themselves out of Lego - I kid you not - and it seems to fit it fine. So, you might consider that!

Now, back to price. The problem after the case issue is the other cables you are going to need. There are quite a few, depending on your setup, and it doesn't come with any of them. I will describe my setup, which I think is pretty typical. For this you need a HDMI cable (or HDMI to DVI cable) for the video out. You will need power via a 700mA minimum micro USB adaptor. If you had an old Blackberry or Samsung phone you might have one of these lying about - just check that it has enough juice as not all of them are strong enough. I highlighted micro in the previous sentence because it is a different connector to the mini USB that you may also have lying about (for cameras, typically). To network the device you will need a network cable. To control the computer you need also a USB keyboard and mouse. If you are computer geek like me, you will have at least one of each of these things just lying around. If you don't though, it will add significantly to the cost of the Pi. Woolworths are selling keyboard and mouse for under $20 (total!) and for gods sake please do not splurge on a HDMI cable for more than $10. Some stores will try and sell you very expensive cables ($60+) and you simply do not need them in this case. If you can wait a day or two, eBay is the cheapest place for this stuff.

Is that it then, to get you going? Well, not quite. There is one more thing you will need - storage in the form of an SD card. This realistically is a minimum of 4GB, but I would suggest 8GB or even 16GB. This is also when some frustration may set in as not all cards will work with the Pi. I suggest that you check out the compatibility chart here. Actually, it gets worse. You see, cards may work but the read/write speed may be very slow. This is not a fast computer by any stretch, but having a very slow card really doesn't help. I was lucky and recycled a Sandisk 16GB card I last used in a digital camera and it not only worked but I found was one of the fastest cards around. You can pick up a 8GB card for around $15, so it's no major drama if it doesn't work - it'll just be annoying. I'd buy this part in a store, not on eBay myself.

The other gotcha with the Pi is about its size. Yes, it is small ... however... when all the cables are plugged into it you are likely to have cables coming out of 3 if not 4 of the sides and this makes it take up more room than you might at first imagine. Think octopus or spider and you are getting the right mental image.

Now back to that SD card, which is a replacement for a hard disk drive in normal computers - it is where the Operating System (OS) and all your installed applications and documents are going to go (assuming you don't also attach an external HD, or use a shared drive on a server, or some sort of cloud based storage).

So you might be thinking - Windows 7 or Windows 8? Um, no. This baby only runs on Linux and to be honest, only very specifically prepared versions at that, due to the fairly rare ARM processor which is the brains of the beast. This may or may not be a complete turn off for you, and perhaps I should have mentioned it in the beginning, but hey, a $40 computer is not going to have the grunt to run the full behemoth that is Windows. I will discuss in a bit how well the Pi performs overall under Linux, but lets say for now that it is probably fast enough, depending on what you are trying to do.

The good news is that Linux is not only small, relatively fast and fun to learn - it is also free (Download it here). There is even a choice of different flavours, but at the time of writing Raspbian is the preferred setup and the one I would recommend. It certainly helps to have another working computer to set things up with - preferably one with a SD card slot too. You will need to get the ISO onto the card before it will boot off of it, and this is perhaps the second major frustration most of us will face. You can get around this by buying a pre-loaded card, and this might be a good idea if you are fearful of this step. The reason I don't fully recommend this is that most of these seem to be on slower and smaller 4GB cards. Besides, I feel that "getting is working" is part of the fun. But if this idea sounds totally stupid to you, then buy the card, please - it's around $10.

One very last thing you will need is either a computer display or a TV. Note that not all computer displays have HDMI ports, so check first that the one you intend to use has this. Almost all monitors have a DVI port these days, and a HDMI to DVI cable can be found on eBay for $5, so that's what I have done. I did use the HDMI on our TV to start with, but found in awkward in terms of my posture, so I moved it back onto my desk. You can't use the VGA port sadly, that's even more common on monitors but slowly going the way of the dodo and the Pi does not support it.

So as you can see, but the time you add the case, power supply, HDMI cable, keyboard, mouse, SD card, network cable and display, you could be up for a lot of additional $ on top of the price of the Pi itself. You may have spares of many of these things (as I did), but if not then factor this into the overall price. If you want the cheapest computer money can buy, you might be better off looking at a low end netbook, like the Asus eeePc.

OK, so you plug all the cables in, power last, and then it will boot for the first time. There is no on/off switch by the way - if you want it off turn off the power or pull out the cable. Lights (LEDs) will come on the Pi board to show that it is alive. The screen should come alive with text scrolling up. It will look somewhat crazy, but after a short time will stop. I'm not going to turn this into a blow by blow tutorial, but there is some more configuration (eg expand the SD card to use it all), you log in as user "pi" and password of "raspberry" and then you can start the GUI (graphical user interface) with the command startx. You read that right. It doesn't even start a GUI unless you tell it to (to be fair, you can set it to automatically do this).

From there I embarked on a few different things. First, I had to fix up the keyboard layout which defaulted to UK (I have US layout), then the screen resolution which was also wrong. Google on another computer helped alot. Then I updated the system (this takes a while, and is fascinating to watch). Then I logged onto the Pi store, it's pretty empty but one thing of note is LibreOffice. If you have an 8GB card, then install this free version of a productivity suite like Microsoft Office. With this done, you could in theory and possibly in practice use this little computer for everyday web browsing and word/excel/powerpoint type documents. You can get a PDF reader for it, and with a bit of arm twisting, even play flash although Youtube sucks (it's a slide show rather than video).

I have played a bit with Ubuntu and Linux in general before, not really much - but enough to know how the commands mostly work. Quite a bit is done using a console, and knowing how to use the sudo command to give elevated privileges is pretty critical (eg sudo raspi-config) . Be aware that Linux is case sensitive, and the slashes for directories are the "other one" than windows. There are not GUI control panels for everything like there is in windows or on a mac.

So, now that I have fixed the main configuration issues I had, what am I using this computer for? Well, to learn more about Linux (and I guess Debian more specifically, and Raspbian even more specifically). There are also various programming languages installed by default, and these are cool. I urge you to check out the MagPi magazine (start from Episode 1!). This magazine has running articles which introduce you to various languages and tips.

You may be surprised to learn that I am actually writing this blog entry using the Pi. In terms of responsiveness, the Intel i7 based computer I use as my main computer leaves it for dead. I have read that the Pi is equivalent to a Pentium II 300Mhz computer, which sounds pretty dire. Sometimes I will click on something, and there is a long pause as it processes the command. I guess I am used to everything being fairly instantaneous these days, so I notice it these delays and if you are in a hurry it could be annoying. If I have some serious work to do, I'll do it on the PC. If I want to learn about Linux, or have a second computer going for whatever reason, I will power up the Pi. It doesn't take long to boot, it is silent and it is fun to see what it can do. If your initial expectations are low, you will be surprised what it can achieve. If you expect it to be as good as a normal desktop computer, you are likely to be horribly disappointed. I got a quake clone running on the PI, but it is so laggy that it is effectively unplayable. Minecraft on the Pi is ok if you don't run it fullscreen, but it is like the mobile version (creative only) and I'm a survival kinda guy, so it is only a curio due to this. If you want a games machine, I'd say look elsewhere, unless it's retro gaming via MAME.

One area I have not explored, and you could argue is one of the main strengths of the Pi, are it's ability to use the pins on the board to control other equipment. This gets into the world of electrical engineering, which is not really my passion, but provides a lot of fascinating possibilities for this low cost controller. You could embed it into all sorts of things, and the Magpi has an article of someone who is using it as the brains for a robotic arm on a movable platform. If you love the smell of solder, and think in terms of wiring diagrams, then this thing is probably heaven.

Something I have noticed is that I now sometimes compared other purchases "how may Pi's I could have bought" with the same money. For example, the other day the family stopped for a coffee (2x), some hot chocolate (2x) and one pastry. This cost me as much as half a Pi. To fill my cars petrol tank from empty is two Pis!

Another thing I wanted to mention is that the SD card based OS allows you to simply swap out a whole new OS by simply shutting down the machine and changing cards. I intend to get an extra card or two ($10-$15 each) just to do this. Imagine being able to change a PC from windows 7 to 8 or XP so easily.

My next challenge is to perhaps remotely control the Pi desktop (ie like RDP or VNC), or set it up as a thin client. I am not in a hurry, I just tinker away and have fun. Don't get frustrated if something isn't working out. I could not get it to print for example - but that is more the fault of Fuji Xerox than anything. I still might be able to get it to work, we'll see. There are a lot of people out there doing the same thing, so google is you friend. I have spend a long time reading posts where people are solving the same problem I have, and it is interesting to me to see this dynamic in play. The "free" spirit encourages people to be generous with help, which is nice to see. Where I can, I will add my voice, and this Blog entry I suppose is a part of that idea.



No comments: