Raspberry pi mpd bluetooth

Raspberry Pi Internet Radio and MP3 Player with Bluetooth

Raspberry Pi Internet Radio and MP3 Player with Bluetooth

This internet radio and MP3 player uses a 3.5 HDMI LCD touchscreen for operation. The original project was published by Adafruit. https://learn.adafruit.com/raspberry-pi-radio-player-with-touchscreen/overview The project uses MPC, MPD and Pygame. The project has been evolving over time. I am still trying to incorporate automatic album images on the sreen.

Installation:

  • Download the raspbian stretch image and burn to a 8GB or bigger SD card. To start you should be know how to SSH to the raspberry pi. You can also connect a mouse and keyboard to the pi and install everything locally. See https://www.raspberrypi.org/documentation/
  • Attach the LCDscreen to the raspberry pi.
  • After the Pi boots up connect to the internet. Open the terminal screen and type
  • Set internationalisation options and change the Timezone
  • Go to Advanced Options and enable VNC and set the resolution to 640×480. I use VNC for remote connection.
  • Exit and reboot.
  • The stretch image takes a lot of space on the SD card and we need to make room for the MP3 music. SSH to the Pi and delete Wolfram and Libreoffice, or use the mouse on the Pi and select preferences, add/remove software
sudo apt-get purge wolfram-engine libreoffice* -y 
sudo apt-get clean
sudo apt-get autoremove
sudo apt-get update
sudo apt-get upgrade
  • After the upgrade you are ready for the installation.
  • Now install the Pi-radio files.
  • Connect your Pi to a TV, or use Vnc and open the Terminal window.
sudo raspi-config
Change the resolution to 640x480 and reboot.
sudo apt-get install mpd mpc
cd
sudo git clone https://github.com/granpino/Pi-Radio-mp3-.git
cd Pi-Radio-mp3-
sudo chmod 777 *.sh
sudo ./install.sh
  • Now lets test the audio output plug to see if Mpd is working. You should have internet access to hear the radio.
mpc load playlist
mpc play
mpc stop
sudo ./radio.sh
  • At this point the Pi-radio should work and play internet radio only through the audio port, and without the LCD screen if you have TV connected or are using VNC viewer.
git clone https://github.com/goodtft/LCD-show.git
sudo
cd LCD-show
sudo ./MPI3508-show
  • The installation file will create the required playlist for the internet radio. There should be an icon on the raspberry desktop. To open the Pi-radio double tap on the radio shortcut. To change the desktop for a single click go to file manager, click on Edit and at the very bottom select preferences. Select ‘open files with single click’.
  • The application uses pygame and the touchscreen will only run under lx-terminal. I you run the application from SSH, the touchscreen will work upside down. I elected to run the app from the desktop because I want to run other apps on the same Pi that use the LCD screen. I did not have to calibrate the screen to make it work.
  • I included some sample radio stations for your testing. To add other radio stations to the playlist go to http://www.radiosure.com/stations/ and copy the m3u links. There are 2 way to create a playlist.
mpc add 
mpc save playlist
sudo nano /var/lib/mpd/playlists/playlist.m3u
  • The Pi-radio is set to read the mp3 files from a USB stick. A playlist is created and stored in the database. To see if the files are there type;

The mpd.conf file

The mpd.conf file needs to show the location of the mp3 files and the type of bluetooth speaker. Put some mp3 files in a USB stick and connect to the Pi, then open the mpd.conf file.

and change the file location to;

music_directory "/mnt/usbdrive"

It would be nice to send the music to a bluetooth speaker. If you are using a Raspberry pi 2, insert a bluetooth dongle int the USB slot. Go to the raspberry desktop and click on the bluetooth icon then add device. Select your bluetooth speaker and pair. Some speakers will require a password, sometimes 0000. You will need a mouse to righ-click on the speaker icon on the menu to connect.

You will also need to edit the mpd.conf file to include the bluetooth speaker.

Copy the speaker mac address xx:xx:xx:xx:xx:xx

Look for the audio output and change to include the mac address and name of the speaker. Replace yhe XX with your mac address

audio_output 
type "alsa"
name "bluetooth-speaker "
device "bluealsa:HCI=hci0,DEV=xx:xx:xx:xx:xx:xx,PROFILE=a2dp"
mixer_type "software"
>

You can have more than one bluetooth speaker.

audio_output 
type "alsa"
name "headphone "
device "bluealsa:HCI=hci0,DEV=xx:xx:xx:xx:xx:xx,PROFILE=a2dp"
mixer_type "software"
>

If you want to listen to the audio jack and bluetooth at the same time, then add a second audio output as;

audio_output 
type "alsa"
name "hdmi audio jack"
>

If the radio fails to start, check the mpd.conf file for errors. To see if the mpd is running open the terminal and type:

If it does not say it is running then you have a problem. Look at your mpd.conf for typing errors and correct. To restart mpd after making changes type;

And check again and see if it is running.

If you wish to control the Pi-Radio from your phone, there are several MPD apps available for android and Iphone. The One I use is MPD remote. From the app enter the IP address of your Pi and have fun..

Источник

Bluetooth Speaker + Raspberry PI – The ultimate guide. Now with WiFi support!

Note: Complete installation script available here: Installation Script Once logged into yourRaspberry, just run:
wget https://www.dropbox.com/s/fz9m19r2fmiz0xe/install.sh
and run the script (after sudo su and chmod 777 ). Open web-browser with IP assigned.

Background

DBS-Three(2)

I purchased a BlueTooth Speaker called a D-Link DBS-2012 Portable Stereo Speaker (Review) with the hope of getting RuneAudio or Volumio streaming to the speaker, but no such luck. The developers of both states outright they do not support the technology, which I find a bit of a lack of vision. Please note, you will also need a BT Dongle.

This said, here follows a guide getting a rather nice, light-weight distribution with a web front-end manageable via cell-phone or any web-browser:

Wheezy Installation

– Check if your BTDongle is listed:
lsusb
– Update your OS:
apt-get update
– Install all the dependencies:
apt-get install bluetooth bluez bluez-utils bluez-alsa mpd mpc python-mpd
– Edit audio.conf and add after [General]:
vi /etc/bluetooth/audio.conf
Enable=Source,Sink,Socket
Disable=Media
– Save and reboot

hciconfig hci0 up
hcitool scan
– This will give you a MAC-ID. Mine is 30:22:00:2F:C1:E0 – Write yours down
bluetooth-agent – – adapter hci0 0000 nnn # change this MAC address to the one you wrote down (0000 = pass) ( Double minus before adapter no spaces! )
bluez-simple-agent hci0 nnn # change this MAC address to the one you wrote down
bluez-test-device trusted nnn yes # change this MAC address to the one you wrote down
bluez-test-device trusted nnn # change this MAC address to the one you wrote down
– This should give you one (1)

vi /etc/asound.conf
pcm.bluetooth
type bluetooth
device nnn # change this MAC address to the one you wrote down
profile “auto”
>

vi /etc/mpd.conf
audio_output
type “alsa”
name “bluetooth”
device “bluetooth”
mixer_type “software”
>
– Save and reboot

At this stage you should be able to play a playlist by loading one and playing it with mpc:

mpc load
mpc volume 70
mpc play

For reference:
Your MPC.CONF file you edited and changed the values on has the path for your playlists stored (default is /var/lib/mpd/playlists). You can save playlists in this directory and do a mpc ls to display the lists…

Configuring your web-client

For this installation, I used ympd. It is a light-weight, no-nonsense web-client written in C, not needing any installation of apache2 or any other web-software. It just works! Description from GitHub: Standalone MPD Web GUI written in C, utilizing Websockets and Bootstrap/JS.

mkdir /home/pi/yp
cd /home/pi/yp
wget http://www.ympd.org/downloads/ympd-1.2.3-armhf.tar.bz2
tar -xvf ympd-1.2.3-armhf.tar.bz2 /home/pi/yp/

#! /bin/sh ### BEGIN INIT INFO # Provides: yweb # Required-Start: $all # Required-Stop: $all # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Simple Start Web Service for MPD # Description: Start Web Service for MPD: Program gotten from http://www.ympd.org/ ### END INIT INFO N=/home/pi/yp/ympd set -e case "$1" in start) # Clear MPD Log File, Start the web-service, Wait for 30 seconds and then start mpc: > /var/log/mpd/mpd.log /usr/bin/sudo $N --webport 80& sleep 30 && /usr/bin/mpc play ;; stop|reload|restart|force-reload|status) ;; *) echo "Usage: $N " >&2 exit 1 ;; esac exit 0

chmod 755 /etc/init.d/yweb
update-rc.d yweb defaults

Reference:

Testing

Adding WiFi:

Adding WiFi is quite easy. First off, you have to add a WiFi USB dongle (I use the D-Link DWA-121 that works out-the-box for all my distros. It is not only small, but also cheap) then scan for your SSID’s and then add it to your WiFi configuration. Let me explain:

wpa_passphrase “SSID” “PASSPHRASE” >> /etc/wpa_supplicant/wpa_supplicant.conf

(ps: You can add multiple SSID’s with the above command)

If you want a static IP, just change the /etc/network/interfaces file to look like this:

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface wlan0 inet static
gateway YOUR_GATEWAY
netmask YOUR_NETMASK
address YOUR_IP

Источник

Читайте также:  Лучший звук через bluetooth
Оцените статью
Adblock
detector