Oddly, the hardest thing so far has been making my Really Very Simple RaspberryPi radio start playing by itself when you turn it on. Which is really the sort of thing you expect a radio to do, really. Not much to ask, you’d think.
I’ve been going crazy trying to figure out ways of getting the radio to start of its own accord as the Pi boots up, trying to edit rc.local, using @reboot statements in crontab – none of it worked. I thought it might be permission problems, possibly I needed to reinstall mpd and mpc as a different user… Eventually I thought of looking at the mpd (music player daemon) logs – they live in /var/log/mpd/mpd.log
Here I found that the problem was a lack of network connectivity – there were lots of ‘Couldn’t resolve host’ and ‘Network is unreachable’ errors each time I rebooted. It seems that the problem is my Edimax wifi dongle, which is taking a LONG time to get on the network.
I found, by trial and
error improvement, that if I added this line to /etc/rc.local:
(sleep 65; python /home/pi/radio.py)&
the radio starts playing – eventually – by itself when you turn the Raspberry Pi on. It takes an age to start up though, so long that by the time it starts playing a radio station you’ve almost forgotten you turned it on. So I think if we do put this in a box, we’ll need to add another button as an ‘on/off’ switch that in fact just sends an ‘mpc stop’ command and leaves the Raspberry Pi running in the background. Perhaps I can find something else of use the Pi can do in the meantime…