{"id":3085,"date":"2016-02-01T16:52:39","date_gmt":"2016-02-01T12:52:39","guid":{"rendered":"http:\/\/nayarweb.com\/blog\/?p=3085"},"modified":"2016-02-01T16:53:27","modified_gmt":"2016-02-01T12:53:27","slug":"raspberry-pi-car-audio-system-with-bluetooth","status":"publish","type":"post","link":"https:\/\/nayarweb.com\/blog\/2016\/raspberry-pi-car-audio-system-with-bluetooth\/","title":{"rendered":"My Raspberry Pi Car Audio System with Bluetooth"},"content":{"rendered":"<p>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 <a href=\"https:\/\/www.raspberrypi.org\/forums\/viewtopic.php?t=68779\">here<\/a>.<\/p>\n<p><a href=\"https:\/\/nayarweb.com\/blog\/wp-content\/uploads\/2016\/02\/wpid-img_20160201_133131.jpg\"><img decoding=\"async\" class=\"alignnone size-full\" title=\"IMG_20160201_133131.jpg\" src=\"https:\/\/nayarweb.com\/blog\/wp-content\/uploads\/2016\/02\/wpid-img_20160201_133131.jpg\" alt=\"image\" \/><\/a><\/p>\n<p>On the Raspberry Pi, I make the bluetooth in &#8220;Discoverable&#8221; mode and launch a bluez-simple-agent to make the initial connection.<\/p>\n<blockquote><p>$\u00a0<span class=\"s1\">sudo hciconfig hci0 piscan<\/span><\/p>\n<p>$bluez-simple-agent<\/p><\/blockquote>\n<p><a href=\"https:\/\/nayarweb.com\/blog\/wp-content\/uploads\/2016\/02\/Screen-Shot-2016-02-01-at-3.47.38-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3095\" src=\"https:\/\/nayarweb.com\/blog\/wp-content\/uploads\/2016\/02\/Screen-Shot-2016-02-01-at-3.47.38-PM.png\" alt=\"Screen Shot 2016-02-01 at 3.47.38 PM\" width=\"447\" height=\"86\" srcset=\"https:\/\/nayarweb.com\/blog\/wp-content\/uploads\/2016\/02\/Screen-Shot-2016-02-01-at-3.47.38-PM.png 447w, https:\/\/nayarweb.com\/blog\/wp-content\/uploads\/2016\/02\/Screen-Shot-2016-02-01-at-3.47.38-PM-300x58.png 300w\" sizes=\"auto, (max-width: 447px) 100vw, 447px\" \/><\/a><\/p>\n<p>On my phone, just after having launched bluez-simple-agent, I can scan and connect.<\/p>\n<p><a href=\"https:\/\/nayarweb.com\/blog\/wp-content\/uploads\/2016\/02\/wpid-screenshot_2016-02-01-15-47-25.png\"><img decoding=\"async\" class=\"alignnone size-full\" title=\"Screenshot_2016-02-01-15-47-25.png\" src=\"https:\/\/nayarweb.com\/blog\/wp-content\/uploads\/2016\/02\/wpid-screenshot_2016-02-01-15-47-25.png\" alt=\"image\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>And once connected, I need to link the bluetooth source to the Raspberry Pi audio output<\/p>\n<blockquote><p>pactl load-module module-loopback source=bluez_source.XX_XX_XX_XX_XX_XX sink=alsa_output.0.analog-stereo<\/p><\/blockquote>\n<p>I can play any songs on my phone and it plays on the car speakers \ud83d\ude1b<\/p>\n<h3>Problem<\/h3>\n<p>After 10 &#8211; 20 secs, the sound would stop playing. Looking into \/var\/log\/syslog, i found this<\/p>\n<blockquote><p>Feb 1 06:39:48 raspberrypi bluetoothd[2208]: Endpoint unregistered: sender=:1.36 path=\/MediaEndpoint\/HFPAG<br \/>\nFeb 1 06:39:48 raspberrypi bluetoothd[2208]: Endpoint unregistered: sender=:1.36 path=\/MediaEndpoint\/HFPHS<br \/>\nFeb 1 06:39:48 raspberrypi bluetoothd[2208]: Endpoint unregistered: sender=:1.36 path=\/MediaEndpoint\/A2DPSource<br \/>\nFeb 1 06:39:48 raspberrypi bluetoothd[2208]: Endpoint unregistered: sender=:1.36 path=\/MediaEndpoint\/A2DPSink<\/p><\/blockquote>\n<p>I don&#8217;t know yet why it happens but if i run this command just after pactl load module, it works fine \ud83d\ude42<\/p>\n<blockquote>\n<p class=\"p1\"><span class=\"s1\">$ pactl subscribe<\/span><\/p>\n<\/blockquote>\n<h3 class=\"p1\">The sound quality<\/h3>\n<p>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&#8217;t know. Anyways, I got a working prototype for now.<\/p>\n<h3>Future plans<\/h3>\n<ul>\n<li>Add support for phone calls<\/li>\n<li>Clean enclosure for the Raspberry Pi and cables.<\/li>\n<li>Bypass the car radio and use an amplifier to connect to car speakers directly.<\/li>\n<li>Use WiFi instead of Bluetooth<\/li>\n<li>Maybe add a touch screen too \ud83d\ude1b<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8220;Discoverable&#8221; mode and launch a bluez-simple-agent to make the initial connection. $\u00a0sudo hciconfig hci0 piscan &hellip; <a href=\"https:\/\/nayarweb.com\/blog\/2016\/raspberry-pi-car-audio-system-with-bluetooth\/\" class=\"continue-reading\">Continue reading <span class=\"screen-reader-text\">My Raspberry Pi Car Audio System with Bluetooth<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[218,210],"tags":[61,167],"class_list":["post-3085","post","type-post","status-publish","format-standard","hentry","category-automobile","category-technology","tag-linux","tag-raspberry-pi"],"_links":{"self":[{"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/posts\/3085","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/comments?post=3085"}],"version-history":[{"count":7,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/posts\/3085\/revisions"}],"predecessor-version":[{"id":3100,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/posts\/3085\/revisions\/3100"}],"wp:attachment":[{"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/media?parent=3085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/categories?post=3085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/tags?post=3085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}