Bluetooth Speakers Using Raspberry Pi
by sajingeo in Circuits > Raspberry Pi
196733 Views, 157 Favorites, 0 Comments
Bluetooth Speakers Using Raspberry Pi
hi guys long time since i wrote a tutorial, this tutorial tells you how you can use any old speaker lying around your house into a wireless bluetooth speaker, this can also be an cheap bluetooth audio device receiver for your car. This is not my original work, but modified(added a few steps/changed a few) tutorial from http://kmonkey711.blogspot.com who has also taken help from Colin CW, i am reproducing this tutorial because this is the only tutorial that worked for me and i don't want it to disappear from the World Wide Web when i really need it. thanks Kmonkey for this awesome tutorial. Another way to have an wireless speaker is using AIRPLAY here
What You Need?
1 Raspberry pi (i am running Occidentalis_v02.img from adafruit)
1 speaker
1 Male-to-male 3.5 mm audio jack
1 bluetooth dongle ( check here for list of devices that work ) do check using the command hcitool scan
1 ethernet connection for pi/ wifi (how to connect a wifi dongle to Raspberry pi) (all u need to do is edit "/etc/network/interfaces" file)
1 speaker
1 Male-to-male 3.5 mm audio jack
1 bluetooth dongle ( check here for list of devices that work ) do check using the command hcitool scan
1 ethernet connection for pi/ wifi (how to connect a wifi dongle to Raspberry pi) (all u need to do is edit "/etc/network/interfaces" file)
Installing the Softwares...
you need to install a couples of things before you can get started :-)
sudo apt-get update
sudo apt-get install bluez pulseaudio-module-bluetooth python-gobject python-gobject-2 bluetooth blueman
sudo usermod -a -G lp pi
sudo nano /etc/bluetooth/audio.conf
add the following after [general] in nano
Enable=Source,Sink,Media,Socket
CTRL+X to close nano, Y to save the file
sudo nano /etc/pulse/daemon.conf
add the following line under ;resample-method = speex-float-3
resample-method = trivial
run the following command to reboot the PI
sudo reboot
if you have a monitor connected to your PI you can skip this next step
sudo apt-get update
sudo apt-get install bluez pulseaudio-module-bluetooth python-gobject python-gobject-2 bluetooth blueman
sudo usermod -a -G lp pi
sudo nano /etc/bluetooth/audio.conf
add the following after [general] in nano
Enable=Source,Sink,Media,Socket
CTRL+X to close nano, Y to save the file
sudo nano /etc/pulse/daemon.conf
add the following line under ;resample-method = speex-float-3
resample-method = trivial
run the following command to reboot the PI
sudo reboot
if you have a monitor connected to your PI you can skip this next step
Installing the VNC Server
if you have a monitor connected to your PI you can skip this step, if you use SSH like me the following steps will install a VNC server on the PI, so that you can go into the LXD desktop.
apt-get install tightvncserver
Setup vnc password by the following command
tightvncserver
reboot the pi
sudo reboot
run the following command to create a desktop you can connect to.
vncserver :0 -geometry 1920x1080 -depth 24
apt-get install tightvncserver
Setup vnc password by the following command
tightvncserver
reboot the pi
sudo reboot
run the following command to create a desktop you can connect to.
vncserver :0 -geometry 1920x1080 -depth 24
Connect to PI Dektop
(for VNC users)
once the PI is restarted and VNC server running you need to pair your device.
connect to the VNCserver using VNC viewer that can be download from here
connect the vnc server with <<you PI's IP address>>:0 eg: 192.168.2.8:0
enter your password
(if you have a monitor hooked up start from here)
now you should be able to see your desktop, on the bottom right corner near the time display you should be able to see a bluetooth icon, right-click on it and select devices. you should now see an empty list if nothing has been added.
click on the search button to find new devices.
new devices should show up in the table below.
right-click on the device and click on pair to pair the devices
enter a pin and pair them
once paired right click on the paired device and mark them as "trust" this ll make this device trusted.once the device is in the trusted list a golden star will be visible on the device.
now you can close your vnc server ( not needed if you have your monitor hooked up) and run vncserver -kill :0 on the SSH
once the PI is restarted and VNC server running you need to pair your device.
connect to the VNCserver using VNC viewer that can be download from here
connect the vnc server with <<you PI's IP address>>:0 eg: 192.168.2.8:0
enter your password
(if you have a monitor hooked up start from here)
now you should be able to see your desktop, on the bottom right corner near the time display you should be able to see a bluetooth icon, right-click on it and select devices. you should now see an empty list if nothing has been added.
click on the search button to find new devices.
new devices should show up in the table below.
right-click on the device and click on pair to pair the devices
enter a pin and pair them
once paired right click on the paired device and mark them as "trust" this ll make this device trusted.once the device is in the trusted list a golden star will be visible on the device.
now you can close your vnc server ( not needed if you have your monitor hooked up) and run vncserver -kill :0 on the SSH
Connect the Bluetooth to Alsa Audio
run the following comands as user "pi" not sudo
amixer cset numid=3 1
find out the name of your source and and sink using the following comands
pactl list sources short
pactl list sink short
and run the following command
pactl load-module module-loopback source="name of your source" sink="name of your sink"
my command looks like this...
pactl load-module module-loopback source=bluez_source.50_EA_D6_DE_D9_39 sink=alsa_output.platform-bcm2835_AUD0.0.analog-stereo
amixer cset numid=3 1
find out the name of your source and and sink using the following comands
pactl list sources short
pactl list sink short
and run the following command
pactl load-module module-loopback source="name of your source" sink="name of your sink"
my command looks like this...
pactl load-module module-loopback source=bluez_source.50_EA_D6_DE_D9_39 sink=alsa_output.platform-bcm2835_AUD0.0.analog-stereo
Play Your Song...
now connect you phone/ipod to the Bluetooth device and start playing songs... do hookup your speakers using the 3.5 mm jack..like duh...
note:
if your volume is too less run the following commands
amixer set Master 100%
pacmd set-sink-volume 0 65537
note:
if your volume is too less run the following commands
amixer set Master 100%
pacmd set-sink-volume 0 65537