YMMV

* your mileage may vary

Sunday, 25 May 2014

Raspberry Pi Radio with 2.8 TFT Touch Screen


Update: Avoid upgrading to Jessie if possible.
Working details of how to setup a Pi-Radio using MPD/MPC Python and a TFT Touch Screen. 

If using Jessie, Pygame is broken.  
Follow this work-around:
http://dumb-looks-free.blogspot.fr/2016/01/jessie-pygame-and-tft-touch-screens.html
Note the Linux Kernel V4 has the work by Notro built in, so it is easier to build under Jessie/Linux V4, you just need to do the Pygame work-around.
//

Mar 13/2016
New Jessie version here (removed pygame):
http://dumb-looks-free.blogspot.fr/2016/03/pi-radio-new-version-under-jessie.html

Under Wheezy:
Get the image
Download the latest file from notro  (nice work by this guy!).
http://tronnes.org/downloads/2014-01-07-wheezy-raspbian-2014-03-12-fbtft-hy28a.zip

Extract img from zip and copy to SD card 
  • sudo dd bs=4M if=2014-01-07-wheezy-raspbian-2014-03-12-fbtft-hy28a.img of=/dev/sdb 
Insert SD card into Pi and power up
Run raspi-config 
set up local keyboard etc
  • sudo raspi-config
Calibrate the screen
  • sudo ts_calibrate 
Test screen 
put this file in /home/pi (from Texy - the guy who sells the TFT)
https://drive.google.com/file/d/0BwUGkFVOqZsPdURuemVUT082U1U/edit?usp=sharing
  • sudo python touchv7.py
Install mplayer to check music plays ok
  • sudo apt-get update
  • sudo apt-get install mplayer
  • mplayer http://8343.live.streamtheworld.com:80/KDFCFMAAC_SC
Set USB as priority device
  • sudo nano /etc/modprobe.d/alsa-base.conf
change: => options snd-usb-audio index=0
add:=> options snd_usb_audio nrpacks=1

Install MPD / MPC 
  • sudo apt-get install mpd
  • sudo apt-get install mpc
Setup directories under /home/pi
  • cd ~ 
  • mkdir radio
dump these files into the radio directory
https://drive.google.com/file/d/0BwUGkFVOqZsPdURuemVUT082U1U/edit?usp=sharing 

https://drive.google.com/file/d/0BwUGkFVOqZsPSE5xWFRPU1ZFMDg/edit?usp=sharing
  • mkdir Music
add music files (mp3, etc) & adjust /pi/radio/playlists/mymusic to fit with the Music directory

Update mpd configuration
  • sudo cp /etc/mpd.conf /etc/mpd.orig
  • sudo nano /etc/mpd.conf
change the music and playlists directories as per above 
change ip to => bind_to_address         "0.0.0.0"
  • sudo service mpd restart 
Allow playlist to repeat
  • mpc repeat on
Install python mpd2
  • git clone git://github.com/Mic92/python-mpd2.git
  • sudo pip install python-mpd2
Setup to auto login
  • sudo nano /etc/inittab
change add the following
#1:2345:respawn:/sbin/getty --noclear 38400 tty1
1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1


Change to start up radio automatically on boot
  • nano .bashrc
Put this at the bottom of the file
cd radio
sudo python pi-radio.py &


Done! 
  • sudo reboot

20 comments:

  1. Hi,
    the link to the "dump these files into the radio directory" is the same as the first script for the screen test, could you update the link for the file pi-radio.py please?

    thanks

    ReplyDelete
    Replies
    1. Hi,
      try,
      https://drive.google.com/file/d/0BwUGkFVOqZsPSE5xWFRPU1ZFMDg/edit?usp=sharing

      thanks

      Delete
    2. Hi,

      Thanks for the update, all works fine now and than you for sharing a really useful pi project.

      Delete
    3. Ok....glad to hear you got it working.

      Delete
  2. Hi,

    i just made it running too, but my tft does not let me "touch" though it is working fine in other programs
    http://raspimart.co.uk/rpi-touch-display-setup/
    can you help me please?

    Wolfram.

    ReplyDelete
  3. ok, i got it working!
    I forgot to calibrate the ts....

    ReplyDelete
  4. has anyone has done changes to the pi-radio.py to scroll between folders and files yet?

    ReplyDelete
  5. Hey there,
    I have a 320x240 LCD and it works great. Is there a version with equalizer working? ...some final version?

    Thank you, very grateful

    ReplyDelete
  6. No equalizer implemented unfortunately. It was an idea that I never developed.

    ReplyDelete
  7. Hello, I have a problem with that line "sudo pip install python-mpd2" - command not found Do you know this problem? thanks Krupi

    ReplyDelete
    Replies
    1. Hello,
      Do you have pip installed .... ?
      https://pip.pypa.io/en/stable/

      Delete
  8. Hi,

    I am getting the following error, and am lost where to begining looking for the errors solution, could you offer some pointers please?

    pi@PiRadio ~/radio $ Traceback (most recent call last):
    File "pi-radio.py", line 230, in
    client.load(CURRENT_PLAYLIST)
    File "/usr/local/lib/python2.7/dist-packages/mpd.py", line 629, in decorator
    return wrapper(self, name, args, bound_decorator(self, returnValue))
    File "/usr/local/lib/python2.7/dist-packages/mpd.py", line 254, in _execute
    return retval()
    File "/usr/local/lib/python2.7/dist-packages/mpd.py", line 623, in decorator
    return function(self, *args, **kwargs)
    File "/usr/local/lib/python2.7/dist-packages/mpd.py", line 379, in _fetch_nothing
    line = self._read_line()
    File "/usr/local/lib/python2.7/dist-packages/mpd.py", line 291, in _read_line
    raise CommandError(error)
    mpd.CommandError: [50@0] {load} No such playlist

    Thanks

    ReplyDelete
  9. make sure you have the playlist directory defined in /etc/mpd.conf and the playlist "radio.m3u" is in /pi/radio/playlists/

    ReplyDelete
    Replies
    1. Thanks very much, all working now.

      Delete
  10. I listen to Swedish radio and there is many strange symbols in the station name. Have changed the font. But can't get get song names whiteout symbols. Åäö

    ReplyDelete
  11. I listen to Swedish radio and there is many strange symbols in the station name. Have changed the font. But can't get get song names whiteout symbols. Åäö

    ReplyDelete
  12. Hello, can you send me the URL for the station you play so I can check?

    I'm in the process of updating the pi-radio for Jessie, so I'll post the new code here in a few days. (I removed some functions & icons that I never finished, and made the push buttons bigger). I think it runs better under Jessie, but it is not such a huge difference.

    ReplyDelete
  13. Accented characters like Åäö work in the new version running under Jessie

    ReplyDelete
  14. New version here ...
    http://dumb-looks-free.blogspot.fr/2016/03/pi-radio-new-version-under-jessie.html

    ReplyDelete