Little Box of Haiku

Following on from my Little Box of Poems – which printed a random poem on till-roll, and inspired Carrie Anne Philbin’s Little Box of Geek – I present: The Little Box of Haiku.

It’s made from a RaspberryPi and one of Pimoroni’s lovely Displayotron 3000 LCD display / button gizmos.

You push a button and this Python script generates a random haiku from a set of 5, 7 and 5 syllable sentences.


#!/usr/bin/env python
import time
import dot3k.lcd as lcd
import random
import dot3k.backlight as backlight
import dot3k.joystick as j
import signal

lcd.write("@blogmywiki's   amazing random  haiku machine")

five_syllable = ['Cat crouches     wisely', 'Dog wags tail in hope', 'Leaves fall on   the ground', 'Apples are       falling', 'A child stops to look']
seven_syllable = ['No-one knows why they come here', 'The moon rises   unnoticed', 'Stars are       falling to Earth now', 'The grass is moist underfoot', 'Buttercups hide in the shade']


lcd.write("Press button to create your     personal haiku")

while True:

        def handle_button(pin):
          line1 = random.choice(five_syllable)
          line2 = random.choice(seven_syllable)
          line3 = random.choice(five_syllable)
          lcd.write("Press button to create your personal haiku")
        # Prevent the script exiting!
Posted in poetry, Raspberry Pi | Tagged , , , | Leave a comment

Thoughts about Serial

It seems as if everyone in my Twitter timeline is raving about Serial. Serial is an American podcast about a possible miscarriage of justice. Episode 1 describes itself thus:

It’s Baltimore, 1999. Hae Min Lee, a popular high-school senior, disappears after school one day. Six weeks later detectives arrest her classmate and ex-boyfriend, Adnan Syed, for her murder. He says he’s innocent – though he can’t exactly remember what he was doing on that January afternoon. But someone can. A classmate at Woodlawn High School says she knows where Adnan was. The trouble is, she’s nowhere to be found.

I’ve listened to 6 of the 50-minute episodes now – so clearly it must be doing something right. And yet, I don’t have the same passion about it, the same addiction about it that most people do.

There are plenty of things to like. Oddly, we don’t tend to use the term ‘sound design’ in radio, but it sounds fantastic. It’s very well mixed and edited, the original music is haunting, presenter Sarah Koenig has an easy-on-the-ear voice and a personable style.

And yet something is missing. Perhaps I’ve not been paying close enough attention, listening whilst doing other things, last night listening at 4am because I couldn’t sleep, and Koenig’s voice is almost as soothing a narcotic as a radio programme in Burmese. Or it could be because of the things that are not there; you’d expect heart-wrenching, tear-jerking testimony from the murder victim’s family, and that’s missing. It’s oddly dispassionate, almost matter-of-fact in the way material is covered. Sarah Koenig is no John Sweeney – the tempo and tone of her voice rarely changes much, you can’t imagine her losing her temper and railing against the injustice of it all.

Possibly (and I’m not quite up-to-date yet) this is because she just doesn’t know herself. And neither do I. As a slightly casual listener, who hasn’t read through the paperwork, I’m thinking at this point that this probably wasn’t a miscarriage of justice. Clearly something doesn’t add up in this case, but I’m far from convinced of Adnan’s innocence.

I am, however, convinced by the Serial web site. It is beautiful to look at, clear, it responds to mobile devices, the audio player is really well-designed, and I have fallen in love with the headline font, Sackers Gothic, beautifully serious, very, very North American. Perfect.

Posted in radio | Tagged , , | Leave a comment

Displayotron3000 Pi Radio

In the summertime I built a Raspberry Pi radio that I could control via a web interface from my phone, and got to musing about some kind of Arduino-type shield that could snap on to a Pi to turn it into a little internet radio with a display, a few buttons and a speaker.

Well, blimey charlie, imagine my surprise when I discovered something pretty darn similar already exists! The good people at Pimoroni make and sell the splendidly-named Displayotron 3000 (not sure if it is related to Andre). This sits snugly on a Pi’s pins and gives you a 3-line LCD display with 3 strips of variable RGB backlights, a 4 way mini joystick with centre-press and a strip of eye-wateringly bright (but dimmable) white LEDs for use as a bar graph. It even has its own radio module, and I’ve been testing it out.

In short, I love it. It does everything my imaginary radio gizmo did, apart from having a built-in speaker (how about it, guys?). It goes perfectly with Pimoroni’s Pibow Coupe case (pictured) – this is a half-height case that leaves GPIO pins and other gubbins accessible.

It took a bit of tweaking to get it working. I started with a fresh install of Raspbian, updated my Pi with
sudo apt-get update
sudo apt-get upgrade
sudo rpi-update

I then installed the files from
sudo apt-get install python-dev python-pip python-smbus
sudo pip install dot3k
git clone

I couldn’t get it to work, and then discovered that I had a bit more work to do: namely enabling spi and i2c. Details on how to do that are here and here.

I then installed psutil, another requirement:
sudo apt-get install python-psutil

My previous Raspberry Pi radios have all used mpd/mpc to play radio streams, but this one uses VLC, and I’m impressed. I installed VLC and added some stations to the config file*, and bingo! a cool little internet radio with a colourful screen and a well-designed menu allowing you to browse stations, view CPU load and temperature, change the volume and a very cool clock with an optional binary display and time-sensitive dimmer.

It’s a great piece of work – Pimoroni and @gadgetoid should be very, very proud.

My wishlist for tweaks:
- an alarm clock
- display time and station name at the same time
- ‘now-playing’ track info, as per my web-based radio
- weather info
- a record function
- a built-in speaker!

Time to retire my PiRadio made with an Arduino-driven LCD display and buttons.

* the radio bit of my config file now looks like this (starting with the world’s greatest radio station, fip. Mais oui.)

[Radio Stations]
fip32 = fip bas debit,
fip128 = fip haut debit,
radio1 = BBC Radio 1,
radio2 = BBC Radio 2,
radio3 = BBC Radio 3,
radio4 = BBC Radio 4,
radio4x = BBC Radio 4Extra,
radio5 = BBC 5Live,
6music = BBC 6Music,
einws = BBC WS News,
nwpr = NWPR,
meat = MEATransMISSION,
monocle = Monocle M24,
resonance = ResonanceFM,
purple = Purple Radio,
rte1 = RTE Radio 1,
share = Share Radio,

Posted in Raspberry Pi, Raspbian, Uncategorized | Tagged , , , , , | 1 Comment

Raspberry Pi internet radio with web interface

Having made a bare-bones Raspberry Pi internet radio and one with an LCD display with push buttons to change channel, I decided that it would be nice to be able to control it from my smartphone, as well as displaying ‘now playing’ track information.

This was a fun challenge that kept me busy in the summer… I got distracted dreaming of different RaspberryPi shields (see below) with little speakers, buttons and LCD displays that would make nice Kickstarter projects, and I’ve been so busy since that I never wrote it up. So here, from memory and a few scribbled notes, is how you might do it…

In brief, you install mpd and mpc music players, add some internet radio stations, install a simple web server and add a bit of PHP code to dish up a web page that controls the radio and displays tracklistings. It was the latter that was an especially tough nut to crack. The BBC, despite being funded from public subscriptions, does not seem to freely syndicate its ‘now playing’ data, and I have had to get it via a commercial third party’s RSS feed ( Madness. For my favourite radio station, fip, I used its Twitter feed to display the last 3 tracks played.

How to build one (very) roughly

1) Start with a vanilla RaspberryPi running Raspbian OS ‘headless’ so it doesn’t boot into a GUI. Adding wifi and giving it a static IP address is a good idea (in my experience, most wifi routers allow you to give devices the same IP address each time they start up). Enable SSH so you can log into your PiRadio remotely.

2) Install MPD and MPC music players as per

3) Add internet radio stations of your choice as per

4) Plug in some headphones, powered speakers or an amp into the analogue audio output of the RaspberryPi to test it works when you type
mpc play 1

5) Optional: add a line to /etc/rc.local to play the radio station of your choice at boot-up.

6) Install nginx web server and PHP.

6.5) Install SimplePie to handle the RSS feeds that give ‘now playing’ data for BBC Radio.

7) Add my index.php and shutdown.php file (code here) to /usr/share/nginx/www – there was probably a whole mess of permissions horror here that my notes glide over. It looks like I had fun making the shutdown work, I probably had to give the nginx user sudo rights or something horribly ill-advised.

8) You should now have a radio you (or your children! such hilarity!) can remotely control from a web-browser on any smartphone, computer, tablet – or indeed eBook reader. The stylesheet is optimised for an iPhone, but this easily be tweaked.

To do:
- enable recording (I did make some headway with this using streamripper but ran out of time).
- have a nice HTML5 volume control slider (this was beyond me).
- find a better way of setting it up so you can configure the wifi from a simple command line in a KanoOS-style.
- make it so you can easily edit the station list from web interface or command line.
- mesh in better with my Arduino-driven LCD display (at the moment if you change the channel using the web interface, the LCD shows the wrong station name).
- find someone to help me build my Kickstarter radio shield/widget. Adafruit do an LCD screen with buttons like my Arduino one, but it’s a kit. I’d like a cute little box with a screen, buttons and a speaker or two, powered by USB.

Controlling an early version of PiLittleRadio from an old Kindle 3G.

Posted in Raspberry Pi | Tagged , , | Leave a comment

10 fun things to do with a Raspberry Pi

Got a Raspberry Pi? Not sure what to do with it? Here are some cool things I’ve done with mine to get you thinking:

Some of these posts are old and the precise details of what you need to do may be out-of-date, but I hope this list gives you some ideas.

Posted in Raspberry Pi | Tagged , , | Leave a comment