Category Archives: raspberry pi

streaming radio on a Raspberry Pi

I migrated the web server that runs this blog to my new 512MB Pi, so was looking for a use for my original 256MB one. Although I have a perfectly good radio in my bedroom I like the idea of streaming radio to the command line, and maybe using the Pi as an alarm clock with some cron scripts.

A bit of Googling suggested that mpg123 and their like will struggle with the sort of playlist files and stream encoding used by the BBC, and so mplayer looked like the best candidate to have working stream with minimal fuss:


sudo apt-get install mplayer
mplayer -playlist "http://bbc.co.uk/radio/listen/live/r4.asx"

The above saw mplayer throwing some errors about unavailable pulse audio drivers. I added an argument to force use of the alsa drivers:


mplayer -ao alsa -playlist "http://bbc.co.uk/radio/listen/live/r4.asx"

Now mplayer seemed to fetch the stream ok and looked like it was playing, but I heard no sound. (I’m using a portable speaker connected to the Pi’s headphones socket). I checked the volume level in Alsamixer, and that was fine. Back to Google again and the Raspberry Pi troubleshooting guide suggested that I could force audio to route via a particular output – in this case the one I wanted for the headphone socket was:


sudo amixer cset numid=3 1

Fired up mplayer again and yay, Radio 4 🙂 Next step is to add some cron scripts to start and stop the radio in the mornings.

Advertisements

512mb of Pi

Last week the Raspberry Pi foundation announced that they’d started shipping new units with 512mb ram chips instead of the previously supplied 256mb ones. Sounded like the perfect excuse to get hold of a second Pi – I ordered one on Monday and to my surprise it arrived yesterday, just a five day turnaround (thank you Element14/Farnell).

I wanted to use my existing SD card (SanDisk 8GB x10) as it has a fair bit of stuff on it (including this website) so I needed to get Raspian to notice the extra RAM. I downloaded the updated firmware files into the Pi’s /boot directory and added gpu_mem=256 to /boot/config.txt – this gives me a 50:50 split, 256mb for the GUI/GPU and 256mb for the CPU. Rebooted and it works a treat, seems a wee bit snappier too.

Raspberry Pi in action

I’m amazed by what this little Raspberry Pi can do. This is a screengrab (from my Mac) showing it running a Rails app in my browser and a couple of ssh terminal sessions, whilst at the same time my daughter was playing Tuxpaint on it. You can see the processes in top, not even breaking out a sweat while it’s running a Ruby/Webrick server, an Apache server, an Xorg desktop and a rich app like Tuxpaint.

Debian on a Raspberry Pi

Been having fun getting Debian up and running on my Raspberry Pi, this a note of the software and config tweaks I made to get it running how I wanted

I downloaded the Debian ARM image from here and copied the image in to an SD card I had, a 4GB SanDIsk SHDC class 4 (There’s a handy list of Raspberry Pi working SD cards here.)

dd if=debian6-19-04-2012.img of=/dev/disk1 bs=1m

The image uses around 2GB arranged as:

  • 1.5GB root fs
  • 200 MB /boot
  • 256 MB swap

To make use of the rest of the 4GB card I popped the card into a spare debian box I had and resized it with Gparted. I noticed the root fs was already at 80%, so I extended that a bit then made a new 1.25 GB partition for /home (ext4) and added the necessary entry to /etc/fstab. The card now looks like this:

  • 200 MB /boot
  • 2.3 GB /
  • 1.25 GB /home
  • 256 MB swap

My first boot failed with a kernel panic. It looked like a hardware/IRQ thing to me so I whipped the keyboard and mouse out of the USB sockets and tried again and it booted fine.

I headed back to the supported hardware page again showed me that my cheapo Argos keyboard was not gonna play so I found a different keybord, tried again and this time it booted up perfectly and I logged in (default user/pass on these Debian images is pi/raspberry).

For video I used the HDMI out as my telly has a spare HDMI socket in the back. Running ‘startx’ brings up the Xfce GUI, and I added ‘disable_overscan=1’ to the file /boot/config.txt get rid of the fat black borders around the desktop.

I plan to make some ports available on the internet (a web server and sshd at least) so there were a couple of sysadmin tasks I needed to do: I added a new user account for myself, logged out and in as me, and then removed the default ‘pi’ account. I also removed users ‘pi’ and ‘suse’ from the sudoers file.

Doing this reminded me to install vim, did that and changed the default $EDITOR from joe:

sudo apt-get install vim
sudo update-alternatives --config editor

(If you’re new to Debian then this page is useful.)

The openssh-server is installed but not enabled by default, to start it and get it to restart on a reboot I ran:

sudo service ssh start
sudo update-rc.d ssh defaults

I installed Apache with

sudo apt-get install apache2

The server will fail to start on install so you’ll want to

sudo groupadd -f -g33 www-data
sudo /usr/sbin/apachectl graceful

Sound wasn’t enabled by default, to get it going I loaded the snd_bcm2835 kernel module and installed the alas-utils package:

sudo apt-get install alsa-utils
sudo modprobe snd_bcm2835

I then added snd_bcm2385 to /etc/modules so it auto-loads on boot, and added the line ‘hdmi_drive=2’ to the /boot/config.txt file to force sound via the HDMI output.

That’s pretty much it. The online community and documentation for the Raspi is great. I found this troubleshooting guide particularly useful in getting up and running.

Your order has been shipped…

Had an exciting email from the peeps at Farnell/Element 14 two days ago, the Raspi that I ordered back on April 1st is finally on its way: “Your Raspberry Pi has now been shipped from our warehouse”:

The package arrived this morning, 1 x Raspberry Pi model B (and 1 x freebie Element 14 t-shirt extra-large 😀 ). Looking forward to getting it home, plugging in and getting some software on it. I’ll post my experiences here as I go, but in the mean time here’s the obligatory unboxing shot:

Ain’t that just the cutest thing?

Raspberry Pi as an educational platform

Lots of people getting excited about a credit-card sized computer that plugs into your TV and a keyboard with the vendors reporting over 2 million pre-orders for these little boards.

raspberry pi board

For me the interesting thing about the Raspberry Pi project is the potential it has to help in the reinvention of the teaching of IT in primary and secondary schools.

There’s been some big talk from the Government about how the ICT curriculum needs to change, recognising that it’s probably more useful to teach kids about programming rather than just how to use Word and Excel. 

It reminds me a lot of the fuss around the arrival of BBC micros in my secondary school school in the 1980s. It wasn’t word processing or number crunching that caught our imagination, but games. Programming in that context was a means to an end, a way to make pixels move around on the screen. 

BBC micro

“…But the BBC Micro towered over all of these for one simple reason: it became the foundation for teaching computing in schools across the nation. Indeed, I don’t think it’s any coincidence that many of the first wave of hackers in the UK grew up on the BBC Micro, and learned real programming by exploring its possibilities.”
(Glyn Moody writing in Computerworld).

The Raspberry Pi project can put affordable, hackable hardware and open-source software in the hands of school kids. With the advent of apps and easy-to-learn development frameworks there’s a huge opportunity to make the ICT curriculum into something that will create the next generation of hackers.