After much trial and error, managed to get bluetooth AD2P profile on my Raspberry Pi which I then connected to my car auxiliary (aux) input. I followed the tutorial found here.
On the Raspberry Pi, I make the bluetooth in “Discoverable” mode and launch a bluez-simple-agent to make the initial connection.
$ sudo hciconfig hci0 piscan
$bluez-simple-agent
On my phone, just after having launched bluez-simple-agent, I can scan and connect.
And once connected, I need to link the bluetooth source to the Raspberry Pi audio output
pactl load-module module-loopback source=bluez_source.XX_XX_XX_XX_XX_XX sink=alsa_output.0.analog-stereo
I can play any songs on my phone and it plays on the car speakers 😛
Problem
After 10 – 20 secs, the sound would stop playing. Looking into /var/log/syslog, i found this
Feb 1 06:39:48 raspberrypi bluetoothd[2208]: Endpoint unregistered: sender=:1.36 path=/MediaEndpoint/HFPAG
Feb 1 06:39:48 raspberrypi bluetoothd[2208]: Endpoint unregistered: sender=:1.36 path=/MediaEndpoint/HFPHS
Feb 1 06:39:48 raspberrypi bluetoothd[2208]: Endpoint unregistered: sender=:1.36 path=/MediaEndpoint/A2DPSource
Feb 1 06:39:48 raspberrypi bluetoothd[2208]: Endpoint unregistered: sender=:1.36 path=/MediaEndpoint/A2DPSink
I don’t know yet why it happens but if i run this command just after pactl load module, it works fine 🙂
$ pactl subscribe
The sound quality
Not that awesome. A direct AUX connection sounds much better. I can hear quite some background noise. Is it due to the raspberry sound card, the bluetooth adapter or just some configuration? I don’t know. Anyways, I got a working prototype for now.
Future plans
- Add support for phone calls
- Clean enclosure for the Raspberry Pi and cables.
- Bypass the car radio and use an amplifier to connect to car speakers directly.
- Use WiFi instead of Bluetooth
- Maybe add a touch screen too 😛