Wednesday, December 12, 2012
my Raspberry Pi
on a whim, I plunked down $35 for a Raspberry Pi lightweight computer. I have put off blogging about it because I have done very little compared to what I see being done. this used to make me feel guilty but I realize now that for everyone who you see doing something amazing with robots or Arduino or 3D vision sensors and Roombas, there are probably 10 people like me who use it for piracy and as an SSH server and whatnot.
so, here is what I'm doing with it:
- it downloads TV shows for me from Usenet, using SABNZBd
- this has allowed me to keep my desktop computer in sleep mode for at least 8 hours of the day when it was previously on all the time. if I'm doing the math right, that saves between $100 to $200 per year, or would save that much if I paid for power (my co-op building doesn't submeter power). the Pi draws its power from a Blackberry charger so it pulls 0.7W vs. the 120W I calculated my PC drawing when always on, which means it costs maybe $1.85 per year to run.
- because of the above I spent more time than I'm comfortable admitting to facilitate the handoff of MKV files from Pi to PC. if you care, I could never get a stable enough samba load to just copy the files from the Pi to the PC or vice versa, and scp was super slow, so I use anonymous FTP now. the sole SABNZBd script copies an MKV or MP4 file to a directory and then wakes up the PC via a Wake On LAN packet. the PC, upon being awakened, has a scheduled task to check the Pi for new files via anonymous FTP, and if it finds them, downloads them via FTP and deletes them via the plink command.
- for laughs, I had the Pi run ffmpeg to convert the downloaded MKV files for iPhone, but one thing that is better about a PC that draws 200x as much power is that it is much faster. I ran this test twice to be sure but the conversion takes about 24 minutes on my PC (8 cores, 2.5 years old) and 12 hours and 24 minutes on the Pi (non-overclocked). so as much as I'd like to push non-time-sensitive tasks like overnight conversion of files, I did a lot of traveling recently and really appreciated having last night's shows ready to load onto iPad before heading to the airport at 4:30AM. so, the advice is, know your workloads as you decide which workloads translate well to low energy servers and which still require lots of processing (and thus electrical) power.
- it facilitates printing from iDevices to my HP LaserJet via avahi-server and cups (all credit due to this guy)
- after a LOT of different attempts, I got it working with XBMC so it can show YouTube (using an add-in with a really painful UI) on my TV, I'd like to get it to show Amazon Digital Prime content as well. I don't think the current setup will have a Wife Acceptance Factor so I'm leaving it offline until I have more time to play with it.
- out of guilt that I have used the Pi mostly like a small cheap piracy machine, which is a bit of a slap in the face to its legacy as a cheap educational tool for children, I have very recently been using it in service of my 5 1/2 year old's desire to "write a Ninjago video game."
- my son and I first started going through online Python Pygame tutorials to try and teach ourselves how to write a cross-platform game, but Python is very similar to real programming and it couldn't hold his attention. it also wasn't clear that games we wrote using Pygame would work on the iPad (which was my son's hope) so I gave up on it for now. I had never written in Python so I had no head start myself.
- I then looked at Scratch, which came preinstalled in my Raspbian image, and it seemed to fit the bill. I'm not sure my son understands while loops and conditional operators, but if you look at what Scratch provides and how it is built, it is easy to write little programs while explaining the process to a child.
- so, we have a very cheesy little program called "Ninjago Kick-Butt" where you can move the Golden Ninja over to Snike (these two are characters from the Lego Ninjago series) and, if you are in proximity to Snike, pressing K kicks him and makes him fall over. also you can press S for Spinjitsu and the Golden Ninja does a spinning tornado move which knocks Snike over. my son and I spent time picking out images for the characters and background and making the former transparent, and I think he somewhat understands the programming although I do not sense that he has grasped "x" and "y" which are important for the movement options, but then again, no offense to my wife as I know she reads this blog, but I don't know if she would immediately know which direction negative X represents.
- I have it available via SSH, but 99% of the time I just SSH in to wake up my PC so I can do things with it using TeamViewer.
I was inspired to write this when I read that the Raspberry Pi Foundation had finalized arrangements to move production of the device from China to the UK where they are based. as a not-very-patriotic left-wing American I don't know why this moves me but it does. the creators have fulfilled their own dreams by getting the Pi produced at the same price on British soil as its previous Chinese manufacture, creating 30 British jobs in the process, and came full circle to the BBC Micro computers which were designed and built in Britain and which taught them programming and hardware hacking, and inspired them to create this project. why would a government-controlled company design, manufacture and market its own computer? that seems to make no sense, but it inspired the three core Raspberry Pi founders to build this thing that has been an amazing success, has thousands of British students competing to build cool things, and has brought 30 jobs to Wales… what could make more sense than that? writ large, there are thousands more stories like this. I have nothing against Chinese manufacturing or the Chinese in general but I'm in awe that a $35 computer the size of an index card can be made in Western Europe without compromises for a price roughly equivalent to an iPhone 5 case. there's a cool article about the manufacturing process but in reality I'm mostly excited about the innovations people are coming up with on their Pis and the fact that a '70s government program has led to this flourishing of innovation. and I'm always excited to see my kids get into some sort of nerdy thing they can do with me.