Tag Archives: raspberry pi

Kano the Raspberry Pi go mainstream?

Since its launch the Raspberry Pi has been phenomenally  successful – with over 2 million units of the little computer sold around the world, it’s arguably kick-started a revolution in cheap, educational computing.

The only slight worry about this is how many Raspberry Pi computers have landed in the hands of kids (who it was really intended for) as opposed to 30-something computer nerds who are re-living their 8-bit computing childhoods, or networking the family toaster. Arguably there’s nothing wrong with that as the enthusiasts provide a ton of support but sometimes it’s easy to lose site of the goal of the project in the first place.

Then there’s the Raspberry Pi’s biggest competitor – the tablet computer. Many kids will be given tablets as they’re ‘educational’ devices – and given the choice of an instant on, readily usable ipad that can play games as well, the Raspberry Pi has its work cut out to avoid the drawer of forgotten devices.

So enter the Kano project – a kickstarter that raised over 1 million dollars, and effectively bundles the Raspberry Pi up with some nice hardware and some trendy design. Marketed as the computer you can build, it’s taking aim at the educational market in the hope that the kids will put down their iPads and have a go.

The Beta version of the Kano OS software part of the project launched this week so here are some first impressions.

In order to prepare your SD card Kano requires a burner program to run on a PC or Mac – although this does the job, it’s not quite as elegant as the NOOBS drag and drop method which has now become the standard for most Raspberry Pi software.

It did work on the first attempt
It did work on the first attempt

On bootup you get asked a few questions in the terminal, in the style similar to a text adventure. This is actually a rather nice touch. It neatly introduces the idea of the text interface and entering commands, and makes typing startx rather exciting (there’s a countdown!). I can imagine this being fun with a classroom of kids trying out the Raspberry Pi for the first time.

Not the command line you know
Not the command line you know

This first person theme continues as you use the computer – one nice touch is the bundled wi-fi setup app asks you to test your internet connection with the ping command (thus introducing the idea for later).

Once you get past this you’re presented with the Kano desktop. It’s beautifully designed with nice flat icons for the various apps. Chromium is the default web browser and it runs at a decent speed, and there are some bundled apps for creating programs.

Even as a Beta it feels quite polished.

Overall Kano OS is much simpler and less cluttered than other Raspberry Pi distributions and everything you really need is still there.

The tabletty desktop
The tabletty desktop

Lots of things here will be already familiar to anyone who’s used a Pi before – the command line is still accessible, so despite its user friendly interface there’s still the option to type proper linux commands.

The apps that have had the most work done to them are the programming tutorials – these allow you to mess around with a game of snake or pong using the drag and drop interface of scratch, and there’s also a split screen Minecraft app that is quite clever. It doesn’t take long at all to start really using the Pi and trying out different projects.

Here's pong with garish colours!
Here’s pong with garish colours!

It’ll be interesting to see how this software progresses – there are definitely some good points, and as something I could load onto a Raspberry Pi and give to some kids to play with it perfectly fits the bill; and it does still include the vital command line for anyone that gets curious as to what’s running their computer behind the scenes – something that a tablet computer lacks.

One thing I wonder though is exactly how the Kano kit fits in with the other Raspberry Pi distributions – I’m not sure if the aim is to get this to fit alongside the other Raspberry Pi distributions (for instance including it as part of NOOBS) or to sell it separately. Raspbian’s open source nature has led it to be massively improved over the years by the community – and it would be a shame if Kano OS missed out on this.

You can try out Kano for yourself at kano.me

The kit launches sometime this year with a custom keyboard – I’ll be reviewing that as well.

Make any remote into a Pi remote with FLIRC

I recently acquired a FLIRC USB Dongle to use with my Raspberry Pi, and thought I’d post a few impressions of this handy media gadget.

FLIRC is a USB programmable adapter that can learn from any IR remote controller. You program the FLIRC using an app running on a Mac, PC or Intel based Ubuntu install, and once setup the FLIRC just appears as a standard USB keyboard.

The FLIRC itself is the size of a small USB stick – I’ve been using it with an old SKY box remote which has lots of handy buttons to use for various options. These remotes are a nice size, take AA batteries, and there are plenty available from amazon if you don’t have one to hand.

SKY remote being used as a Pi remote
It’s a (SKY) Pi remote

Each of the keys is set by running the FLIRC app – this can be set up as a simple apple TV remote:

Super simple (apple TV)
Super simple (apple TV)

for a more complicated XBMC remote, compatible with the Raspberry Pi’s RaspBMC:

FLIRC XBMC
More options here…

Or for the full kitchen sink option, as a complete USB keyboard:

Just when you need something that adds a couple of keys here and there...

The latter is particularly useful as it offers keys like left and right command – which are missed off some keyboards, like the one on the Motorola Lapdock and using a small remote as a keypad is also quite a handy feature. Programmable keypads are usually much more expensive than the £22.99 that the FLIRC retails for.

All in all the FLIRC is a handy tool for the Raspberry Pi – it’s only downside is that it can’t be programmed directly from the Pi itself, as you need an intel based Mac or PC to program it. There is an API promised in the near future that should hopefully address some of these issues.

One possible option would be to use the Pi as a bluetooth adapter, thus allowing you to control your iPad with an ancient Sky remote. 

Holga 120 D

This is an update to my original Raspberry Pi Holga camera case project.

Earlier this year Holga Direct created a digital version of the Holga – the 120d as an April fool joke – although my version lacks the 73 megapixel sensor and retina back display it does actually exist, can take nice pictures and is fairly easy to build yourself if you’d like to give it a try.

The aim of this is to build a neat case which fits the Raspberry Pi and camera module, and to do a bit of experimenting with the GPIO (General Purpose Input and Output) pins to use them to control various aspects of the camera. Lacking instant feedback and having no idea what you’ve captured until you take it home also fulfils some of the ideas behind retro analogue photography made popular by Lomography. It also looks a bit hipster.

Holga 120 d Raspberry Pi camera
Shutter release and power on the front lens

This is a fully working Digital Holga 120d – it used the case from a broken Holga, unfortunately it doesn’t use the original plastic lens (although I have kept this) as the Pi Camera board has it’s own built in lens, however it is now possible to use screw on lenses and filters.

The case is now finished but I have made a few changes since my last post:

I’ve lost the external USB port as there wasn’t quite enough space inside the case to fit the USB plug – I am now using a nano wifi adapter inside the case – specifically the Edimax EW-7811UN adapter which works well with the Raspberry Pi model A and fits inside the case.

Along the way I’ve added a few extra parts:

  • A 49mm adapter ring on the front lens – it is now possible to add filters – this is a zomei 46-49mm adapter ring (similar to this one) which screwed in to the original Holga plastic lens after using a dremel to sand down the holga lens until it fitted.
  • 3.5mm plug for external camera trigger – this is a stereo headphone socket with 2 wires attached. Am using a mono 3.5mm cable to use as a cable release driver as I think it’s some kind of standard.
  • led indicator (in the viewfinder – which glows red to indicate a picture is being taken )
  • Optoisolator flash circuit – this is an LED attached to an image sensor – the model I’m using is rated to control very high voltages.
  • A 3 position rotary switch – to select between video, still photos and program mode. This is a 12 way switch so i’m only using a few of the contacts. I used a big chunky switch I found on ebay which makes a satisfying click when you turn it – it did fit after a dremel was used to cut a larger hole. I’ve used a tap washer to fill the gap between the switch and the camera case.
Holga 120d Raspberry Pi Camera Case
Here’s the 3/4 view with the big clunky switch. It will switch something eventually.

I’m currently powering this using a (rather big) Anker USB battery – will likely use something smaller in due course but the Anker battery seems to last forever and powers the Pi with the Wifi adapter with no problems at all.

The next step is to build the hardware to connect the various inputs and outputs to the Raspberry Pi. I’ve been experimenting with these using breadboard and hope to solder it all neatly together – with details – for my next project post. Essentially I need to wire 3 switches (shutter, 2 rotary switch positions) and 2 LEDs (indicator, optoisolator) to the GPIO.

Then finally there’s the matter of some software to pull it all together. At the moment I’ve been testing using the rather useful BerryCam iOS app – although it seems ironic to be using a device with it’s own much better built in camera to control the camera of another computer remotely, it’s a useful app to test things with. If you use the instructions in the first bit of my post about using the Pi as an Adblock server you can also set the IP address to be the same each time.

Update: I’ve added the inputs and 2 LED outputs to the GPIO on the Raspberry Pi – check out this post for more details, circuit diagrams and code.

Finally here’s a selfie in the mirror:

BerryCam Holga 120d self portrait
Hello me

 

 

Raspberry Pi Camera Case – from a Holga

Here’s version 1 of the Holga Raspberry Pi Camera – a hackable, programable camera with a 5 megapixel sensor and HD video capabilities, in retro camera form.

My original concept was to do something like this:

Pi Camera Module camera case sketch
Everything and the kitchen sink

And I managed to build something like this:

Pi Camera Holga Case
And here’s how it turned out..

The Holga is an ultra-cheap medium format camera – if you shop around you can get one for about £15-20 – the model I used for this was the Holga Camera 120N (120 N) (Plastic Lens / Hot Shoe) with the Raspberry Pi Model A – although with a bit of modification it would work with the larger model B. Potentially by soldering the power supply and USB directly to the Pi you could make this a slimmer fit, but I wanted something that didn’t modify the Pi in any way.

The model A Pi fits quite well – you just have to remote the 2 plastic struts inside the case, and peel off the foam that secures the film reels inside the case. I had to remove the plastic panels that enclosed what would have been the flash (my Holga came without one). I cut up a cheap USB extension cable to mount on the top of the camera – and to plug into the side of the Pi. In order to make it fit with the right angled micro USB on the other side I needed to solder and make my own USB cable (you’ll need the shortest USB plug available – I used a poundland retractable USB cable as the source for mine).

If you don’t want to bother with the soldering you could probably just drill holes in either side of the case – there is room, and the plastic is easy to cut through.  

I also added a couple of plastic struts to locate the Pi in place – it’s a snug fit so doesn’t rattle around inside the case.

With the Pi removed you can see how it sits in the camera:

Pi Camera Case without Pi (rear view)
Here it is with all the wires

The yellow wires go to the flash hotshoe – the green to the trigger button on the side of the lens housing, and the red to the power button.

Pi camera case with Pi fitted
Here it’s sitting in it’s case. Snug.

The camera module sits inside the lens with the ribbon cable carefully wrapping around the board and over to the socket – I experimented with Sugru to hold the camera board in place (which would work) but wanted it to be removable, so opted to cut up a piece of spare plastic and drill a hole for the module to peek through – it’s a fairly firm push fit which holds it in place. The lens can still be rotated a little to make it easy to level the Pi camera.

For the power switch I used the same circuit as for the Motorola Lapdock, and added it to the lens mount. I’ve also added a press button on the other side to use to take photos – this will be (eventually) wired to the GPIO.

Pi Camera Detail
Here’s a closeup

Despite it’s cheapness the case feels solid – most of the modifications could be done with a sharp craft knife, apart from a few places where the plastic was thicker or I needed to make holes and a dremel was needed. There’s a lot of empty space inside this case so plenty of room to add things later (I wanted to add a speaker and a few other outputs and inputs, so will do later..)

Overall this was a fun project – all the messy cables and glue are neatly hidden (I went a bit overboard on the glue gun when soldering my USB extension cable) and the case was fairly easy to work with.

The case also has a nice screw mount for a tripod – handy for securing the Pi with camera to things.

Making it more than ‘just a camera’

Replicating a simple Camera with the Pi and Holga (HolgaPi? Piga?) would be a bit boring so my aim with this project is to provide a nice case with the possibility of extending it beyond what I could achieve with a normal compact camera.

At the moment the GPIO isn’t connected to the shutter button or flash trigger – i’ll do this next and write up the method in another blog post.

Things to do:

  • Think of a name
  • Calibrate the viewfinder
  • Write / find some code to make the camera operate over a network. As it lacks a screen the idea of putting all the camera controls into a web app makes sense
  • Add an LED indicator to the viewfinder
  • Add a speaker and think of some sound effects for the camera to make
  • Make use of the flash hotshoe (I’m thinking of using an opto-isolator for this, as some flashes have high trigger voltages running through them)
  • Add some more inputs – this could make the basis of a camera trap. Would be fairly easy to make this rainproof. As it is it would work with a Makey Makey…
  • Write some code to make the GPIO stuff work. I’m relying on this blog post to learn how.
  • Spray it red / green to match with the Pi look, neaten up the lens mount where the glue has discoloured the plastic
  • Investigate batteries or solar power
  • See if I can add a filter mount
  • Send a detailed proposal to the Lomo people to ask them to make a modified Holga case for the Raspberry Pi

Update: check out the following posts in the series.

Get iplayer on the Raspberry pi XBMC – RaspBMC

I wrote a post a while back about installing Sam Nazarko’s Raspberry Pi flavoured XBMC – Raspbmc, but now things have moved on a bit, rendering my original instructions out of date. Updated update: RaspBMC is now available as part of the NOOBS installer.

Sam has now released the final release version of Raspbmc so I thought I’d give it a go.

Raspbmc
Now with a lovely logo too!

My criteria in trying this out is, is this something I could use everyday and is this something I could set up for an older relative and just leave in place

The updated release version of Raspmbc now has a very easy to use installer, and is really simple to get running. Just prepare your SD card using the appropriate installer (I’ve been using the Mac version) pop it into your Raspberry Pi (ensuring it has an ethernet connection) switch on the power and then go and have a cup of tea.

Everything’s lovely and smooth – the menus work slickly, and the behind the scenes hard work on Raspbmc has really paid off. It behaves like a commercial product, and although it does pause occasionally it’s still far superior to the bundled apps that come with a lot of  (often very expensive) smart TVs.

It also works well on a Motorola Lapdock (adjusting the screen size automatically from the HDMI monitor I originally installed it on).

In face you often have to remind yourself that this is running off a $25 computer.

Once you’ve got it running adding WiFi is nice and straightforward – I’ve been using the Edimax EW-7711UAN 150Mbps Wireless adapter which is detected and works with my BT hub without any issues. You just need to enter your network SSID and login using the Raspbmc settings option which is under programs.

Installing iPlayer on RaspBMC

Youtube and Vimeo plugins can be found in the ‘add plugins’ section and work out of the box.

To add iplayer – possibly the main thing I use my streaming box for these days there are a few additional steps (for just iplayer follow the step by step guide see this blog)

You’ll need to add some additional repositories –

There’s actually a handy plugin which automates the addition of new repositories, so we’ll install that first.

With the Raspberry Pi connected to the internet:

Home Screen to Settings > System Information. You need to locate and take note of your Pi’s IP address – this usually starts with 192.168.1.(then a number)

Next on another computer, you’ll need to connect via SSH – on a Mac or Linux PC open the console and use:

ssh pi@(your IP address)

the standard password is raspberry. Select yes and enter your locale details in the menus that appear – this will then end up with a [email protected] prompt.

On a PC you’ll need an SSH tool like PuttY

Copy and paste the following into your terminal window:

get http://passion-xbmc.org/addons/Download.php/plugin.program.repo.installer/plugin.program.repo.installer-1.0.5.zip

Then back on the pi go to system -> addons (in XBMC backspace moves up through sub-menus, so you might have to hit this a few times to find the top menu) and select install from zip file option.

Select homefolder and then plugin.program.repo.installer-1.9.5.zip

you should get a little message in the bottom right hand corner to say it’s been installed.

then select the programs icon and run the Repositories Installer

There’s a long list – iplayer can be found in Hitchers Repo, 4OD in the Mossy repo. Once this is installed you can navigate to system – settings – add-ons to install, and then video- Add-ons to watch.

For much more – including things like setting this up for airplay, using an ipad as a remote – and to support this excellent project – check out Sam Nazarko’s book for more info: Raspberry Pi Media Center

Using a Raspberry Pi LEDborg as an IFTTT.com blinky LED notifier

Here’s a little project to build a very simple web-controlled multicoloured LED indicator with your Raspberry Pi and the PiBorg LEDBorg board.

Using IF This Then That (IFTTT.com) – a simple online service which allows you to daisy chain different web things together – you can light up your Pi’s LEDborg based on particular events.

Take for instance it’s predicted to be frosty outside – your Pi could light up blue, or perhaps someone’s just mentioned you on twitter – your Pi could light up green. Or your boss has just emailed you and your Pi lights up red. IFTTT allows you to set up alerts based on a wide range of events. You could even potentially use your Pi to trigger events by sending information to IFTTT – but in this example I’m just using it as a receiver.

LEDborg
Spidey checking out the LEDborg

At about a fiver, the LEDBorg is one of the cheapest add-ons available for the Pi that plugs directly into the GPIO (General Purpose Input and Output) pins. It consists of a single 3 colour LED surface mounted on a board with a controller chip. It’s fairly simple – if you’re feeling adventurous you could probably have a go at building your own version, although it would be tricky to make something so compact. The LEDBorg fits neatly over the GPIO pins and would probably fit inside most Pi cases – I’ve opted to use my upright lego case to show off the light better.

First you need to fit your LEDborg, and install the software according to which revision of the Pi you have.

The LEDborg comes with a nice app that runs in a window – you can use this to test that everything is working correctly. My first impression of the LEDborg was how bright it was – it’s considerably brighter than the on-board indicator lights:

LEDborg fitted to a Raspberry Pi
Resistance is futile

Next comes to automating the LEDborg to work with our online service IFTTT.

To do this I’m going to be using a specially created email account. There are other ways to do this which are a bit quicker, but email is easy, doesn’t require much setup and as long as the Pi has internet access it will work. In this example I’ve opted for gmail.

Next we need a bit of code on the Pi to check the gmail account, and fetch the subject of the latest email sent to it. This code then uses the email subject to program the LEDborg. This is my first attempt at writing Python (so be kind if you spot any mistakes!) – you just need to change the your_email_address and your_password for the bits you set up:

import imaplib
import email
#connect to gmail

mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.login('[email protected]','your_password')
mail.select('inbox')
mail.list()

typ, data = mail.search(None, 'ALL')
for num in data[0].split():
typ, data = mail.fetch(num, '(RFC822)')
typ, data = mail.search(None, 'All')	
ids = data[0]
id_list = ids.split()

# get most recent email id

latest_email_id = int( id_list[-1] )

for i in range( latest_email_id, latest_email_id-1, -1):
typ, data = mail.fetch( i, '(RFC822)')
for response_part in data:
if isinstance(response_part, tuple):
msg = email.message_from_string(response_part[1])
varSubject = msg['subject']
varFrom = msg['from']
varFrom = varFrom.replace('<','')
varFrom = varFrom.replace('>','')
if len( varSubject ) >35:
varSubject = varSubject[0:32] ='...'

#print the subject to test

print varSubject

#output the subject to the ledborg

LedBorg = open('/dev/ledborg', 'w')
LedBorg.write(varsubject)
del LedBorg

 


(you can also download this from Gist)

Save this as ledchecker.py

You can test this by sending an email with the subject line 111 to the gmail account and by then running the script with:

sudo python ledchecker.py

Hopefully your Pi should be bathed in white light!

The position of the number in the subject refers to the red green blue LEDs in the LEDborg, and the value the intensity 2= full 1=half 0=off

So 100 is dim red, 200 is bright red. You can mix colours by using different combinations. Sending an email with the subject 000 switches the LEDborg off.

Excellent – but we don’t want to be constantly typing in the commands to run the script all the time – to get by this we’re going to use cron (think of it as Linux’s cronometer – a regular clock that does things at regular intervals). For a bit more info about cron check out this blog from David Singleton.

We can set cron to run our ledchecker.py program every minute:

sudo crontab -e

Opens your cron table in the nano editor – you just need to add

* * * * * sudo python /home/ledchecker.py

and then control-O to save and control-X to exit. You might need to adjust the line above depending on where you saved your python script.

Now your Raspberry Pi should automatically check the email account every minute and light up the LEDborg if it receives the appropriate email.

The final step is to head over to IFTTT.com and try creating a ‘recipe’ to feed your Raspberry Pi with information – I’ve created a simple recipe to get you started. If you think of any good ones, please share in the comments below!

Next thoughts are how to improve on this – perhaps it could cycle through last 5 emails? blink if it’s something really important? have a wired up ‘reset’ button. Play a chime when the notification changes?

Update: Fork me!

Brilliant –  vwilcox has forked the original script and made it better – it’s now indented properly, and has a loop to check if there’s no email, for rejecting the email if the subject is too long, and a nice empty the inbox function. This is the first time anything I’ve written on gist has been forked, so that has made my day (in a very nerdy way) – thank you!

Check out the fork here.

Raspberry Pi as an adblock server for iPad, iPhone, Android and anything else on your network

Adblocker without Jailbreak:

On my computer I find using Adblock plus a handy way to speed up surfing and hide invasive pop-up ads.

Annoyingly you can’t install Adblock on an iPad without jailbreaking it – and I’ve yet to come across a way of installing it on Android devices easily without requiring root access.

Fortunately there’s an easy way to install Privoxy on a Raspberry Pi that can block adverts (and do a few other things as well) and that works seamlessly on iOS and more or less anything you attach to your network.

You could run this software on any PC attached to your network – but with the Pi’s low power consumption  (3.5 watts) you can afford to leave it on all the time. Plus you could combine this functionality with a fileserver or an airplay speaker for a bit of extra usefulness.

Setting up your Raspberry Pi for remote control by iPad

Raspberry Pi running as an Adblock for iOS
Nice conversation piece for geeky dinner parties

First step is to prepare an SD card for your Pi – I’ve been using the default Raspbian.

Next step is to boot up the Pi with a screen and keyboard attached, and connected to your home network with an Ethernet cable. This would also work with a wireless connection, but ethernet is a bit simpler, more stable and means the Pi will run happily off a low powered USB adapter (e.g. a kindle power supply). On it’s first boot the Pi will run the config app – if you’ve already run your Pi before you can restart the config app by typing the following into the console:

sudo raspi-config

Make sure you change the default Pi password, and enable SSH in the menu. We’ll be using SSH to control the Pi remotely.

Now find your Pi’s IP address – in the terminal type:

ifconfig

This will give you some information about how the Pi is connecting to the network – make a note of the inet addr – usually 192.168.1.number (I’ll use this notation to refer to this value in the guide)

Next you can connect to your Pi using an SSH client – I’ve been using Remoter Fusion on the iPad (other SSH apps are available but I was using Remoter for something else) note that you will need to purchase SSH support in app which adds £5 to it’s price.

To connect to your Raspberry Pi with Remoter Fusion, click on discovery list -> Add Session Manually. On the Server Type choose SSH.

In the box that says SSH Hostname enter your Pi’s IP address which you found out above:  192.168.1.number then choose Manual – leave the SSH Port setting at 22 and in SSH Username enter your Pi username and SSH Password your Pi password.

Remoter Fusion iPad with Raspberry Pi
Remoter Fusion

Then connect – you might get a warning message (just accept) and then you should be seeing the Linux prompt.

Now you need to change your Pi from having a dynamic IP address (given to it by the router every time it reboots) to a static IP address which will stay the same. In the prompt type:

cd /etc/network
sudo nano interfaces

this launches nano which is a basic text editor – the following settings will depend on your Router – most routers will have a configuration page which will give you this information if you visit their configuration page – usually found on your network by typing 192.168.1.1 into a browser. The following settings worked for the BT Homehub version 3.

auto eth0
iface eth0 inet static
address 192.168.1.number
gateway 192.168.1.254
netmask 255.255.255.0
network 192.168.1.1
broadcast 192.168.1.255

Press control and O and then enter to save, followed by control and X to exit.

You might want to test your settings – either by using the Ping command, or by attaching a monitor / keyboard / mouse directly to the Pi and firing up the web-browser – the Pi should be able to connect to the internet.

Installing Privoxy on your Raspberry Pi

Finally we just need to install Privoxy – with the nice simple:

sudo apt-get install privoxy

then start Privoxy

sudo /etc/init.d/privoxy start

Then you’ll need to setup Privoxy by editing the configuration file –

sudo nano /etc/privoxy/config

This is a long file with lots of options – scroll or do a search with control W and find the listen-address line. Change it to 192.168.1.number:8118

Control O to save in nano then control X to exit.

Restart Privoxy with:

sudo /etc/init.d/privoxy restart

Now on your iPad go to settings -> Wi-Fi -> your network name and then scroll to the HTTP proxy options. Choose Manual and where it says Server type your Pi’s IP address: 192.168.1.number and where it says port type 8118.

Finally go to config.privoxy.org and if it’s all working correctly you should see an enabled message.

Straight out of the box Privoxy started blocking ads for me – you can edit the exact way it does this in the configuration files. So websites like this:

Lots of Adverts
Lots of Adverts

Become websites like this:

After Adblock on iOS
Less adverts. Still rubbish.

You can take this a bit further by turning your Pi into a personal VPN for secure browsing on the go with this Lifehacker tutorial.

Probably an overkill using a Pi for this, but it is handy being able to work on the Pi using an iPad and as I mentioned before there are a few other useful things your Pi could be doing at the same time.

How to play the original 8-bit Elite on a Raspberry Pi

Ok, so after my last post about running the Archimedes 32-bit version of Elite on RISC OS on the Raspberry Pi I got a few comments about running the earlier (and more authentic) 8 bit version on modern hardware. So I thought I’d have a bit of a play and try out a few options for running the original version.

Probably the easiest way to get a taste is to run the NES version on an emulator – Elite co-creator Ian Bell describes this as “the best way to re-experience the feel of 8 bit Elite“.

There are NES emulators available for almost any platform – here it is running on my Android 4 MK802 lapdock using iNES. You can download the ROM freely (and legally) from Ian Bell’s website.

Elite running on the iNES emulator on an Android 4 MINI PC
Cobra mk III

If you find the display corrupts you need to make sure it’s set to PAL and not NTSC or ‘auto’ . iNES has a nice function where you can remap keys to the various buttons, which is handy when using an external USB keyboard with the MK802.

It works well- although Elite’s many keys are replicated through combination key presses which takes a bit of getting used to. You can fly, shoot, get shot at, and crash at docking.

As I mentioned in my previous post – it’s rather fun to play Elite on the Raspberry Pi computer – the original BBC B’s spiritual successor, which also shares a creator with Elite.

The Raspberry Pi also has (various) NES emulators available for it – although I’ve yet to find one that can run Elite smoothly and without any issues (consider this a work in progress). However you can emulate the machine where it all started back in 1984:

How to emulate the BBC Micro  (model B) on a Raspberry Pi (model B)

Bridge of the Cobra Mk III image from the Elite user manual
Bridge of the Cobra Mk III – uncanny how the console of a 31st century starship looks a bit like a 1981 microcomputer…

It is possible to run the original BBC B version of Elite using the !BeebIt emulator – this is an emulator that runs in RISC OS.

Compared to the linux and android based emulators available this runs much more quickly since RISC OS is a very lightweight operating system.

To relive the original Elite – I’ve prepared a step by step guide – make sure you do all this on a Raspberry Pi running RISC OS – particularly unpacking the zip files.

First create an SD card running RISC OS or just download the NOOBs installer.

RISC OS uses a 3 button mouse – you’ll need one to access menus using the middle button – applications have a ! at the beginning of their name, and shift-click opens the application folder. There’s more RISC OS info available here.

Note that it also helps to have a standard, full size keyboard.

Then download !BeebIT – of the two versions available I’ve been using Michael Foot’s.

Extract the archive on your Raspberry Pi by dragging and dropping the download file, and then double clicking and dragging the !Beebit application file to a new folder. (Note that RISC OS is very drag and drop orientated).

Next you’ll need some BBC ROMs – the ROMs download on Michael Foot’s page contain both the OS2 and DFS ROMs you’ll need:

Download

Open up this archive as before – this will contain a !Beebit application icon – just drag and drop this over the !Beebit application you extracted earlier. (Application files on RISC OS are folders containing the program and needed files – by dragging and dropping the ROM file you are just adding the files you need)

Double click !BeebIT to run – it should appear on your icon bar. If you get any errors for missing ROMS, check the steps above or try downloading them individually. f12 will exit the emulator back to the RISC OS desktop.

Download BBC Micro Elite extract and set the type to DFSImage (the icon should change to a floppy disc) – to do this click the middle (menu) button on the file > File ELITEBBC/SDD > Set type and change “Data” to “DFSImage”.

Double click on the image file to run.

Once in !BeebIT type *!BOOT (on my keyboard the @ was *)

then enjoy!

The classic loading screen
The classic loading screen

Have a go at playing with the settings – you can choose a high quality display mode, or set CPU speed to Full Speed. If you’re feeling a bit more adventurous !BeebIt also emulates the Master 128 which ran a full colour version of Elite which is similar to the NES version – you’ll need to download the correct ROMs but all the info is included in the !BeebIt help file (middle click on the !Beebit application App.> ‘!Beebit’ >Help)

Commander Jameson
Commander Jameson

The easiest way to save your progress is to hit f12 to return to the desktop and then the middle button on the !Beebit emulator icon to then choose Save >Save as snapshot. Dragging the snapshot file back to the !Beebit icon will reload your game in the same state you left it. Note for some reason double-clicking on the snapshot icon to load it won’t work.

If you’re interested in Elite you can read a bit more about the 32-bit version of the game in my previous post – or check out the Elite Dangerous Kickstarter which is collecting pledges for a 21st Century version.

Raspberry Pi + Arduino + 8×8 LED Matrix + Python = Raspberry Pi LED display

The other week at work we launched a petition to support lifesaving Aid using a Jumbotron display, so I’ve been inspired to have a go at building a (very) mini version using my Raspberry Pi and an Arduino.

This is a handy way of getting your Pi to display information from any Python app you may have written – so you could use it to make a new email notifier, flash up messages from twitter, or if you’re using your Pi as a server without a monitor – status update messages. I’m interested in using it as a ‘now playing’ message board for an email controlled spotify jukebox I’m working on (more updates to follow).

There are lots of ways you could achieve this – it’s certainly possible to drive LED displays directly from the Raspberry Pi GPIO pins, but this is method is easy to do as it uses off the shelf kits, provides a bit of soldering practice, and an opportunity to learn a bit about Arduinos, Python and serial communications. As with a lot of Arduino projects once you’ve got the hand of how things work you could easily build a cheaper version using only the parts you need. Plus these are my first steps getting an Arduino to do something more interesting than flash a single LED on and off.

I’ve been using a standard Arduino Uno which is available for around £20, and the LED Matrix Shield v.1 from Ciseco which is £5 – this is a Arduino add on board that sits on top of the Arduino. The Matrix shield is fun to put together and good for practising soldering, as a lot of the parts aren’t particularly heat sensitive.

Setting up the Arduino

The instructions that come with the Matix shield are a bit basic – for a much better step by step how to check out this tutorial which I found in the forums.

LED matrix shield Ciseco
LED matrix shield sat on top of an Arduino Duo

Next step is to prepare the Arduino with the code you need it to run. Unlike the Nerdkit microcontroller I mentioned in a previous post the Arduino has a nice user friendly graphical front end – the downside to this is that it runs quite slowly on the Raspberry Pi. I used my Mac to upload the code to the Arduino – just remember to connect it directly to the USB ports on your Mac and not via a USB hub.

First you’ll need to add frequencytimer.h to your Arduino Library – there are instructions on how to install libraries here and you can download frequency timer here.

Then you’ll need to download 8x8LEDMatrix written by Andy Lindsay who has all sorts of other interesting Arduino / Pi stuff on his blog.

The script includes a 5×7 font file which you can experiment with to get the display to show different characters. Compile and upload this to your Arduino to check that everything’s working properly.

Now you’ll need to modify Andy’s code to send the text you want your Arduino to display over the serial port. Using a tilda character clears the script (although I discovered you don’t actually need this as the Pi resets the Arduino when it communicates with it on the serial port)

/*
 * Show messages on an 8x8 led matrix,
 * scrolling from right to left.
 *
 * Uses FrequencyTimer2 library to
 * constantly run an interrupt routine
 * at a specified frequency. This
 * refreshes the display without the
 * main loop having to do anything.
 *
 */

#include
#include &amp;amp;quot;font5x7.h&amp;amp;quot;

#define DELAY 80

int incomingByte = 0;   // for incoming serial data
String incomingString; // for the incomming serial data string
char message[] = &amp;amp;quot;&amp;amp;quot;; // define the message

byte col = 0;
byte leds[8][8];

// pin[xx] on led matrix connected to nn on Arduino (-1 is dummy to make array start at pos 1)
int pins[17]= {
  -1, 17, 8, 7, 19, 9, 13, 4, 10, 6, 5, 18, 3, 2, 11, 12, 16};

// col[xx] of leds = pin yy on led matrix
int cols[8] = {
  pins[13], pins[3], pins[4], pins[10], pins[06], pins[11], pins[15], pins[16]};

int rows[8] = {
  pins[9], pins[14], pins[8], pins[12], pins[1], pins[7], pins[2], pins[5]};


void setup() {

  // sets the pins as output
  for (int i = 1; i  0) {

                // read the incoming byte:
                char incomingByte = (char)Serial.read();

                incomingString += incomingByte;

                if (incomingByte == &amp;amp;#039;~&amp;amp;#039;) {
                  // using a tilda ~ clears the string

                incomingString = &amp;amp;quot;&amp;amp;quot;;

                }

                // check string for command variables

                incomingString.toCharArray(message, 160);



                }





  scrollMsg( message );




}

void clearLeds() {
  // Clear display array
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      leds[i][j] = 0;
    }
  }
}

void setChar(char ch) {

  for (int i = 0; i < 5; i++) {
    unsigned char bt = pgm_read_byte(&amp;amp;amp;(smallFont [(ch-32)*5 + i] ));
    for (int j = 0; j < 8; j++) {
      leds[j][i+1] = (bt &amp;amp;amp; 0x01);
      bt = bt >> 1;
    }
  }
}

void slideChar(char ch, int del) {
  for (int l = 0; l < 5; l++) {
    for (int i = 0; i < 7; i++) {
      for (int j = 0; j < 8; j++) {
        leds[j][i] = leds[j][i+1];
      }
    }
    unsigned char bt = pgm_read_byte(&amp;amp;amp;(smallFont [(ch-32)*5 + l] ));
    for (int j = 0; j < 8; j++) {
      leds[j][7] = (bt &amp;amp;amp; 0x01);
      bt = bt >> 1;
    }
    delay(del);
  }

  for (int i = 0; i < 7; i++) {
    for (int j = 0; j < 8; j++) {
      leds[j][i] = leds[j][i+1];
    }
  }

  for (int j = 0; j < 8; j++) {
    leds[j][7] = 0;
  }
  delay(del);
}


// Interrupt routine
void display() {
  digitalWrite(cols[col], LOW);  // Turn whole previous column off
  col++;
  if (col == 8) {
    col = 0;
  }
  for (int row = 0; row < 8; row++) {
    //    if (leds[col][7 - row] == 1) {
    if (leds[col][ row] == 1) {
      digitalWrite(rows[row], LOW);  // Turn on this led
    }
    else {
      digitalWrite(rows[row], HIGH); // Turn off this led
    }
  }
  digitalWrite(cols[col], HIGH); // Turn whole column on at once (for equal lighting times)
}

Once you’ve uploaded this you can test its working properly by clicking on the serial monitor icon (the magnifier glass on the right hand side) and typing some text – if everything is working OK you’ll see the text appear on your Arduino’s matrix display.

Arduino software
Click on the magnifier icon on the right hand side

Setting up the Raspberry Pi

Now you need to connect the Arduino to the Pi. I’ve used one of the Pi’s USB ports rather than via a USB hub – you could also use the serial pin on the GPIO port to do this as well. Make sure the Arduino is connected before you power up the Raspberry Pi.

You can test the Pi -> Arduino control with minicom (thankyou http://codeandlife.com/2012/07/29/arduino-and-raspberry-pi-serial-communication/

Install minicom on the pi via the console:

sudo apt-get install minicom

then run minicom and connect it to the Arduino:

minicom -b 9600 -o -D /dev/ttyAMA0

Hopefully everything you type into the console will be appearing on the Arduino Matrix.

Next is to get Python to send data to the Arduino over the serial port. Install the python serial libraries:

sudo apt-get install python-serial

Now you’re ready to write some Python code to control the Arduino’s LED display. I’ve been using the IDLE app on the Raspberry Pi. The following code is a super simple python script that can send some text to the LED Matrix:

import time
import serial

#configure the serial connection

ser = serial.Serial("/dev/ttyACM0",9600)

ser.open()

# add some time delays to stop the Arduino resetting

time.sleep(1.5)

ser.isOpen()

time.sleetp(1.5)

ser.write("Raspberry Pi")

Hit f5 and you should see this:

Arduino LED MAtrix Shield v1.0 IOT Research 2012
Bingo! or whatever you want it to say…

And that’s it – you now have a neat way of controlling an LED display with Python. The LED display always shows the last message it received until it gets a new one.

Update: Cisco – the company who made the lovely shield kit, are now doing a kickstarter for a Pi version with a lot more red or white LEDs that plugs directly into the GPIO. 

Getting a Nerdkit to work with the Raspberry Pi

Most of the things I do on a day to day basis are in relation to building websites and looking at ways to code interesting online actions – one thing I’m interested in however is the idea of the internet of things – smart, connected objects that bridge the gap between the online and actual world. Perhaps one day I’ll even find an ecampaigning application for this.

I just had a go connecting up a Nerdkit with the Raspberry Pi. Nerdkits are similar in some ways to the Arduino boards, although they’re a bit more hands on. Whereas the Arduino is nicely assembled and can be just plugged into a USB port, the Nerdkit comes as a pile of parts, a bit of breadboard and some instructions. What’s exciting about Nerdkits, Arduinos and microcontrollers (MCUs) in general is that they provide a flexible, re-programmable set of ‘brains’ with lots of interesting uses. Think of them as lego for electronics.

The ultra cheap Raspberry Pi makes a nice partner to the Nerdkit, as I’m still slightly nervous about attaching something I’ve put together myself to my shiny Mac. Along with the instructions come a set of makefiles which you compile and upload to the MCU via the USB to serial adapter.

The  Nerdkit is based around an Atmel AVR ATmega168 microcontroller which has it’s own bootloader. Also included are the crystal, various resistors, voltage regulators and a variety of input sensors and output electronics. Putting the whole thing together is very satisfying and has given me a bit more insight into how microcontroller based kits work (and what all the bits on the Arduino board do). One really nice additional feature of the Nerdkit is the lcd display panel, which provides feedback in the form of messages, poetry or temperature readouts – depending on what you program it to do. The example below shows it running as a thermometer (one of the included tutorials). Mounting the whole thing on a bit of board is highly recommended.

Photo of Nerdkit mounted on a board with a Raspberry Pi
Here’s my Nerdkit mounted on a board (an Ikea shelf panel) with power switch

Installing the software as in the user guide works fine -it’s all done in the command line, so there’s no Java based application to worry about –

sudo apt-get install avrdude
sudo apt-get install gcc-avr
sudo apt-get install avr-libc

You can edit the makefiles using Leafpad which is part of the default Raspbian operating system. Connecting the Nerdkit cable to the Pi’s USB port presented no problems either.

I did however run into a small snag – although programs would compile and upload successfully, the display on the Nerdkit was showing just on the top line:

Garbled text display
Not quite working

 A quick hunt through the forums later and I came across the fix – open the Makefile (in the example above it’s the one in the tempsensor directory and the one in the libnerdkit directory), look for the GCCFLAGS line and change the “-Os” flag to “-O0” (letter O, number 0). Then delete the .hex and .o files in both the directory your Makefile is in and the libnerdkit directory. That last bit is vital, I kept missing it.

Then it should work fine:

Normal nerdkit display
Working as it should. It was slightly chilly.

So there you go – my first steps in getting my Raspberry Pi to do a bit more than web surfing. I thought I’d highlight that the Raspberry Pi and Nerdkit work together happily, in case anyone else wants to try it out.