Quick and dirty Raspberry Pi radio scheduling

Many thanks to James West for putting me onto this: http://www.bbc.co.uk/rd/blog/2013/09/prototyping-radio-experiences-with-radiodan and http://radiodan.github.io/. A lot of this seems quite complex – I like really, really simple things – but it’s got me thinking about building my own simple radio schedule, changing the channel for programmes I know I don’t want to miss.

It occured to me that I could use cron to do some really simple radio scheduling of my own on one of my Raspberry Pi radios – either the simple one or the sexy one. I tried it, and it works! I am my own scheduler: I never need miss treasured programmes again, nor indeed have to listen to ones I detest (I’ll refrain from naming any, but the words ‘hilarious opening montage’ spring to mind).

All you have to do is type

sudo crontab -e

at the command line and then add a line like this at the bottom of the file, remember to press return to make a new line at the end, and save it:

0 14 * * 5 mpc play 5

This will play Wittertainment every Friday at 2pm! Or, try this:

0 12 * * 1-5 mpc play 5

which will make sure you never miss Shelagh Fogarty‘s programme.

You can use a cron job generator like this to generate the crontab codes for you.

Next I need to tweak my LCD radio code to display the station that’s been played by the sheduler, but even so the buttons still work, so if you don’t like the scheduled programme, you can still over-ride it.

UPDATE

One way of getting the scheduled radio event to update the LCD display might be to run another script at the same time, so the cron entry would look something like this:

0 14 * * 5 mpc play 5 && /home/pi/schedLCD.py

The schedLCD.py script would look something like this:

#!/usr/bin/env python

import os
from nanpy import Arduino
from nanpy import (OneWire, Lcd)

# configure pins for Hobbytronics LCD shield
lcd = Lcd([8, 9, 4, 5, 6, 7], [16, 2])

L= [S.strip('\n') for S in os.popen('mpc').readlines()]
sttn = L[0][0:15]
lcd.printString(16*" ", 0, 0)
lcd.printString(sttn, 0, 0)

Not sure if this would conflict with the other Python script running the radio – I’ll have to try it!

This entry was posted in Arduino, hardware, Linux, radio, Raspberry Pi, Raspbian and tagged , , , , . Bookmark the permalink.

Leave a Reply