Category Archives: Geekery

New year, new server

Well I always like to celebrate a New Year in style, so to celebrate 2014 (the busiest year for this website ever) I’ve finally upgraded my legacy Supanames web package to something a bit faster.

The really-quite-handy-I-can’t-believe-it’s-free Uptime Robot tells the story better than I can, but hopefully things will start to work a bit faster and fall over less often.

It probably also helped that I had a bit of a script spring clean at the same time...
It probably also helped that I had a bit of a script spring clean at the same time…

Next step is to sort out the design again…

Unipi case (all that’s missing is a fruit logo)

A while ago I backed a kickstarter for an aluminium Raspberry Pi case. Although I’ve already amassed a collection of Pi cases (everything from Lego to a hollowed out Holga medium format camera) this one caught my eye as being a rather beautiful piece of industrial design. They even went as far as quoting me on the kickstarter page.

“The best metal case I’ve seen for the Pi” – Feel free to send free stuff!

Plus it was being made by a bloke and his Dad, which I like.

Well the case has arrived today, and I’m glad to say it’s not a disappointment. I opted for the bare metal version, and it feels really well made. The finish is more matt than it appears in the photos which is a plus point, and it comes with two lids – a perforated version and a version with slots if you want to make use of the camera and GPIO.

The Pi fits snug inside
The Pi fits snug inside

This is a very pretty case – perhaps most suited for a desktop Pi. The perforated design is a little bit reminiscent of the powermac G5 and the construction is spot on. I did need to bend the cover very slightly to get it to lock into place, but once it’s there it sits very securely.

All that's missing is a shiny fruit logo
All that’s missing is a shiny fruit logo

The case is also stackable, which would make a very attractive Pi cluster.

Downsides? well it’s not cheap – Adafruit are selling it for $49.95 although it’s cheaper than the other Aluminium cases I’ve seen. If you’re quick you can still buy it direct for $34.99, which still makes it about as much as a Pi, but then it does look very nice on my desk next to the iMac. The video out and stereo jacks are recessed, so angled plugs might struggle but the HDMI socket is almost flush with the side of the case – and this is the output I would use 99% of the time anyway.

Overall? I stand by my statement that this is the best Aluminium case available for the Raspberry Pi – there are others out there but they start to push the ludicrously expensive barrier, and the UniPi case has the feel of much more expensive fruit branded products.

Xtrinsic sensor evaluation board giveaway!

Thanks to the lovely people at Farnell UK I have 4 Xtrinsic sensor evaluation boards to give away. These boards include a stack of sensors (altitude, pressure, magnetometer and accelerometer) attached to a Freescale Freedom Development Platform board which has a multicolour LED and a touch pad.

Out of the box the boards show up as a USB drive when attached to a PC, and it’s possible to load apps to the board – the Farnell kit comes with a script that displays the information from the various sensors via a USB/Serial interface.

At the moment the board instructions are for PC, although there is a Linux driver available.

xtrinsic sensor board
Droids building droids?

There’s potential for lots of really interesting projects with these boards, so here’s how to win one*:

Just come up with an idea for a project using the board – can be anything you like, from the complicated to the simple – and add it as a comment below.

If you want to include a bit of information (or write a blog about your idea) link to it from your comment.

I’ll pick the 4 I like the best and send out the boards. The closing date is the 7th of December 2013 so you have a week to get your thinking caps on.

I’ll feature the ideas – and follow up on how the projects went on in a later blog post.

 *droids not included. I live in the UK but will post anywhere but it might take a while to arrive. Decisions are all final. Boards supplied by Farnell UK who send me nice stuff from time to time.

Update:

The competition has now closed, thank you to everyone who entered, I’ll be sorting through the ideas and contacting you if you’re a winner.

This rather good competition is still open –  http://uk.farnell.com/panasonic-lego-mindstorms if you’re looking for something else to enter.

Build a Raspberry Pi powered LED web counter

Here’s a little project to build an LED web counter for your blog. Proudly(!) display the number of visitors on a retro LED display, using the wordpress stats API – or potentially using any web accessible stats page.

You’ll need a Raspberry Pi (could even be the computer that’s hosting your blog) and a WordPress blog – either hosted yourself and using the Jetpack Stats plugin or on WordPress.com.

For this project I’m using a Python library called beautiful soup which can grab information from a web page – so as well as using this script to display a web counter, you could use it to display any information scraped from any accessible web page.

If you’re not using WordPress you could also do this using google analytics and the Embedded Analytics service, or by using your own counter installed on your website (see ideas below).

The Python script grabs the value from the web, and then sends it to the Pi’s serial port where it is displayed on an LED matrix.

For my project I’m using the Wharfe-Education.com BelleVue kit which fits neatly inside a Ferrero Rocher box and has a nice Back to the Future look about it. For 15 quid it’s a nice easy to solder together kit which features a 6 figure 7 segment LED display.

Wharfe-Education.com BelleVue and Raspberry Pi
Wharfe-Education.com BelleVue and Raspberry Pi

Raspberry Pi to BelleVue serial wiring diagram
Best to attach these with the power off

First make sure the Pi is powered down before attaching anything to the GPIO pins.

To attach the BelleVue to the Pi, you’ll need to attach the TXD (transmit), 5v and GND (ground) pins on the Pi’s GPIO to the inputs on the BelleVue – the right is a diagram for reference: – TXD on the Pi goes to RxD on the BelleVue, 5v on the Pi goes to Vcc and GND to GND.

For reference the diagram on the right shows the top row of GPIO pins with the Pi logo and text on the board the right way up – on the BelleVue it’s the 3 pins on the left hand side as you look at the board, again with the text the correct way up.

When you power on the Pi a sequence of characters will be sent out across the serial port. It is possible to disable this using the instructions found on the Raspberry Pi Spy website here – although they are for the Pi-Lite they equally apply to the BelleVue or any arduino powered LED display.

The Raspberry Leaf provides a handy guide to get the correct pins on the GPIO – or you can use the Adafruit cobbler and some breadboard. The serial port pins are in the same location for all revisions and A and B models of the Pi.

You could also use an arduino with an LED display – here’s an LED Matrix board made by Ciseco, which I’ve written about before:

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

or a Pi-Lite for a scrolling ticker board effect. The Pi-Lite just plugs into the GPIO and sits neatly on top of the Pi. I’ve found that the transparent Mod-My-Pi.com case perfectly fits over the Pi-Lite:

Pi-Lite and Raspberry Pi
Pi-Lite and Raspberry Pi

Alternatively if you’re up to the challenge (and want to save some cash) you could make your own – the Pi-Lite, BelleVue and LED matrix boards are all LED modules driven by Arduino based micro controllers and there’s a handy tutorial here which also includes the code you need.

Setup guide

First on the Raspberry Pi we need to install pyserial to make use of the Pi’s serial port:

sudo apt-get install python-serial

Then install the Beautiful Soup library. This allows us to grab information from a web page.

sudo apt-get install python-beautifulsoup

We could use something simpler, but Beautiful Soup is quite a handy way of scraping information from any web page, and it’s an interesting library to learn about.

For WordPress based stats:

Get your API key from https://apikey.wordpress.com – this will require you to log in using your wordpress account.

A quick test is to use the following URL:

http://stats.wordpress.com/csv.php?api_key=yourAPIkey&blog_uri=www.yourblogaddress.com&days=-1&summarize

Replacing yourAPIkey and blog_uri with your values. The final part of the URL defines what data is returned. You should see a plain text message of “views” and a number if everything is working properly. The &days=-1 returns the total number of unique visits to the site – you can replace this with &days=1 for number of views in the last day or &days=30 for number of views in the last 30 days, etcetera.

Once you’re happy with your URL, create a new python script – either on the Pi Desktop or on the command line using

sudo nano webcounterticker.py

and pasting the following python script

Once you’ve saved the script, run it using the:

python webcounterticker.py

Command – you should see your attached LED display list the number of visits to your site. This will loop with the same value until the script is stopped or run again.

Finally – 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 (short for 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 webcounterticker.py program every minute:

sudo crontab -e

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

* * * * * sudo python /home/webcounterticker.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.

A few other ideas:

Once you’ve got your LED display running you might want to think of a few other things to do with it:

  • You can use Embedded analytics to generate a copy of your Google stats to use with the Beautiful Soup library
  • Use your own web counter – e.g. this php script (which I’m currently using on the footer of GhostPi.org)
  • Host a blog on the same Raspberry Pi that is running the web counter
  • Build an Ashes scoreboard to record England’s epic victory over Australia
  • Build a rack of LED counters for Web visits, Twitter followers, Emails sent or other things you want to measure (and show off)
  • Buy a DMC-12 on ebay and turn it into a time machine

As always, corrections and improvements are welcome!

Having a play with the Pi-Face board

Recently I’ve been sent a PiFace board from the lovely people at Farnell UK – I’m currently working on a slightly silly but hopefully quite fun project with this, but in the meantime I wanted to post up a quick review of the board.

Pi-Face expansion board for Raspberry Pi
Where’s Chewie when you need him?

The Pi-Face comes fully assembled and features 4 inputs (complete with push switches for testing) and 8 outputs – 2 of which are relays, making it suitable to drive high current motors. All the outputs feature surface mount LED indicators so you can easily see what’s happening.  As there’s a load of screw terminals attached to the board, absolutely no soldering is required to hook it up to LEDs or motors, or any type of power application. Although the big chunky relays are rated up to high voltages I think the practical limit is about 20v.

Fitting the board – in this case to a Raspberry Pi model A is a push fit job – there are cut outs for the video out and ethernet ports, along with a rubber foot that rests on the HDMI port. My only slight niggle was that in order for the board to fit completely flush against the Pi I had to trim 5 of the pins from the inputs for it to fit where it sits on the blue audio output port. This is a minor issue though as the board would work fine without this.

For installation – ignore the url printed on the board as this includes a mistake in the setup instructions. I used the following to install the software for the board:

sudo nano /etc/modprobe.d/raspi-blacklist.conf

and edit the file to add a  # at the beginning of the line which reads blacklist spi-bcm2708, so it reads # blacklist spi-bcm2708.

then use:

sudo wget -O – http://pi.cs.man.ac.uk/download/install.txt | bash

to install the software – reboot your Pi and then you can use the rather neat graphical interface to test out the board –

startx

to startup the graphical user interface, then open a terminal and type:

~/piface/scripts/piface-emulator
Pi Face graphical emulator
A bit blurry via VNC

The emulator lets you see inputs from the buttons, and switch the outputs on and off:

Pi-face with outputs on
Punch it Chewie

The instructions and resources from the Start Pi website seem to be the most accurate – there’s a lot of work in progress, but hopefully the support for the Pi-Face will improve with time.

In conclusion it’s a cheap, nicely put together board with very handy relays and terminal inputs – I’m planning on putting mine to use with a lego project (watch this space) – although it lacks the flexibility of some of the bigger boards it has enough for most of the projects you’re likely to do – particularly if like me you interested in the whole idea of social media controlled gadgets. The documentation could be a lot better, and with the screw terminals rather than soldering requirement this board is aimed at the beginner, so hopefully that should improve over time.

The Pi-Face is available from Farnell UK’s website.

 

Update

The official Pi-Face website is now a much better source of information & how to guides – find it at http://www.piface.org.uk/

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.

Make your own Pebble Watch face (in 5 minutes)

My new kickstarter backer Pebble Smartwatch arrived this weekend – and tempted as I was to just put it on ebay straight away I had a bit of a play with it.

The Pebble is a ‘smartwatch’ that connects via bluetooth to your phone. It’s a fairly simple devices a little bit bigger than a regular casio, featuring 4 buttons and a magnetic charging point. The display (described as e-paper rather than e-ink) is a classic black and white lcd – although it’s not quite as high contrast as the display in a kindle it’s not far off and it updates much more quickly without the ghosting you typically get with an ereader.

Out of the box you get vibrating text message, phone call and email notifications, and a few different watch faces – a really nice touch is the shake to activate the backlight function. It’s also possible to control your phone’s music app through a simple pause / play / skip forward and back interface. Battery life is quoted as being a week – although I tend to leave it on charge with my phone every night. Overall it’s a lovely device – perhaps not worth the mega prices cropping up on ebay right now, but worth waiting for.

I suspect watches like this will get smaller, cheaper and a bit more robust over time – my one gripe is that I wish they’d included a glass front rather than the polished plastic.

As this is a version 1 device – as Kickstarter keeps telling us they are not a store – some of the software feels a little bit unpolished, but there is plenty of potential there for handy remote control functions.

Pebble Watch generator screenshot
Here’s how it looked on the site…

And this leads me on to the pebbles killer feature – it’s possible to write software and upload it to the watch using the SDK which has recently been released by Pebble.

For those with less time on their hands there is: http://www.watchface-generator.de

Which is an online custom watch face generator site – on the left is my design in progress.

The website allows you to customise the font size and background image (in this case my website’s logo) and do a bit of tweaking – it then generates a file you can download on your mobile and open using the Pebble App.

Rather cleverly it provides the download with a QR code making it very simple to open it on your phone and send it to the Pebble.

Bingo! – you can create a super-simple simple watchface in minutes:

Pebble watch with kimondo design
and here it is on the watch…

I’m not going to put this online as there’s something hipster nice about owning a watch face that no-one else has.. and there’s this thread here bemoaning the millions of not particularly good designs that will clog up the more professionally designed sites.

Ultimately designing a watchface (or other clever app – am thinking if there’s a Raspberry Pi projec here) properly using the SDK would be more satisfying, but the sheer speed and ease you can do this is amazing.

Pebbles are available on Amazon – hopefully they’ll drop in price as orders catch up. You can explore watchfaces and other Pebble apps at www.mypebblefaces.com.

Update: Pebble is now on version 2, but mypebblefaces.com has been updated as well. Watch faces can include second counters, analogue displays and battery status.

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