Making some modifications to some nice Python examples found on the Internet (Fuzzy Logic Robots, python-mpd documentation, raspi-hd44780 by Irvick) I was able to make a very basic, but fully working, standalone RPI Web Radio receiver.

Here is the complete wiring sketch:

In the above sketch, pin 1 of the LCD is the leftmost one. The rightmost 2 pins (15 and 16) are for the backlight connections. The LCD works at 5V. A 2 lines x 40 characters display was employed, because the titles and the station-ID are generally long. If a smaller display is being used (e.g. 16/20 characters), some modifications to the LCD program are necessary. Adjust the small 10 kOhm variable resistor to get the best LCD characters contrast.

S1 and S2 are used to move up and down through the channels, S3 and S4 to adjust the volume level. The pull-up resistors are all connected to the 3.3V power source. Idea: the four pushbuttons may be connected to a simple remote control circuit.

Take care not to short out each-other the 5V and the 3.3V outputs coming from the RPI and double-check the wiring before powering-up the RPI.

For simplicity, two independent programs have been made: one starts mpc and handles the four pushbuttons, while the other one handles the LCD (updated every 3 seconds). Both programs run in background.

The name of the playlist used by mpc is embedded into the program.  The playlist is named “mymy” (see below).

Instructions:

MPD/MPC must be already be installed as described in Part 1.

1. download the python programs and change the file permissions:

mkdir /home/pi/rpi_web_radio
cd /home/pi/rpi_web_radio
wget http://www.gmpa.it/resources/rpiwebradio/radio.btn.py
wget http://www.gmpa.it/resources/rpiwebradio/radio.lcd.py
sudo chmod +x radio*

2. download the sample playlist “mymy.m3u” (stations may be obsolete at the time you’re reading this article, just update the contents as needed) then check/change the file permissions and the owner:

sudo cd /var/lib/mpd/playlists/
sudo wget http://www.gmpa.it/resources/rpiwebradio/mymy.m3u
sudo chown mpd:audio /var/lib/mpd/playlists/mymy.m3u
sudo chmod 644 /var/lib/mpd/playlists/mymy.m3u

3. download the following programs into /etc/init.d/ then change the files permissions:

sudo wget -O /etc/init.d/radio_btn http://www.gmpa.it/resources/rpiwebradio/radio_btn
sudo wget -O /etc/init.d/radio_lcd http://www.gmpa.it/resources/rpiwebradio/radio_lcd
sudo chmod +x /etc/init.d/radio_btn
sudo chmod +x /etc/init.d/radio_lcd

4. make the programs run automatically at boot:

sudo update-rc.d radio_btn defaults
sudo update-rc.d radio_lcd defaults

If needed, the two control programs can be manually stopped/started:

sudo /etc/init.d/radio_btn stop
sudo /etc/init.d/radio_btn start
sudo /etc/init.d/radio_lcd stop
sudo /etc/init.d/radio_lcd start

To stop the automatic program execution at boot:

sudo update-rc.d -f radio_btn remove
sudo update-rc.d -f radio_lcd remove

The Raspberry, wired to the network (ethernet or wifi), should automatically start playing and the LCD should show the song title and the station name at every reboot.

≡XXS≡