Make Your Own Bluetooth Audio Transmitter For Your Car
A step-by-step guide by DJ Z Frog
Background
I've come across many cheap, compact bluetooth transmitters for connecting MiniDisc players and the like to a bluetooth speaker, but none of the transmitters I've ever bought work with my car's stereo system. This page explains how I made my own using a Raspberry Pi!
Note: None of the product links on this page are Amazon affiliate links. I make no money when you click on them.
READ THIS ENTIRE DOCUMENT BEFORE DOING OR BUYING ANYTHING!
Please feel free to email me at djzfrog@djzfrog.com with your comments or questions!
What you'll need
A Raspberry Pi

This is a small single-board computer. I bought the Raspberry Pi 4 model B with 4GB of RAM, but the 1GB or 2GB version will work just fine for this project.
A case for the Raspberry Pi
There are plenty of cases to choose from. I bought this aluminun case which functions as a heat sink, but you can also get plastic cases with a cooling fan. The advantage of the aluminun case is that it is completely noiseless. If you get the kind with a fan, the cooling fan will become noisier as it ages and will eventually fail.
A microSD memory card

Any capacity of 8GB or more will do. I like Samsung, SanDisk, and PNY memory cards. Make sure the seller and shipper are both amazon.com if you're buying from Amazon (there are plenty of low-quality fake cards on the market sold by sketchy or ignorant sellers on Amazon, and you should try your best to avoid them).
A microSD memory card reader

I like the UGREEN card reader. You won't need this if your computer has a card reader built in already, so check before you buy this item.
A USB audio interface

There are plenty of these to choose from. The really cheap ones only have mono inputs, so get one that has a stereo input. I bought this stereo interface.
An audio cable
Don't get the cheapest cable you can possibly find, and don't throw your money away on expensive cables; good quality cables only cost a few dollars. A 1 meter (3.3 ft) cable should be more than long enough, depending on where you're going to store the Raspberry Pi in your car (I store mine in the armrest compartment).

The cable you choose will need a 3.5mm headphone plug on the end that plugs into your MiniDisc player. The other end should match the audio interface you chose. If you buy the audio interface listed above, then buy a cable like this one, which has RCA plugs on the end opposite the MiniDisc player.

You can also get a cable like this one that has the same 3.5mm plug on both ends, since the stereo audio interface listed above comes with (or at least should come with) a coupler for the 3.5mm audio plug.
A USB-C power bank

Any power bank with a USB-C output will do, as long as it can supply 5 volts at 3 amps. You definitely want to get one of these, because otherwise you will cut off power to the Raspberry Pi whenever you turn off your car. This is basically the same as pulling the plug out of the wall without shutting down the operating system first, which can lead to data loss.
I bought this power bank, which claims to have 20,000 milliamp hours of capacity and can therefore run the Raspberry Pi for at least a day straight. It also has the advantage of turning itself off once it detects that the power draw has fallen below a low threshold, which means that you won't have to manually turn the power bank off every time you turn off your car. If you already have one of these and it works for this project, then use it! Otherwise, consider getting one with the largest capacity you can find, or you will find yourself recharging it fairly often.
A USB-C cable

I bought this cable with right-angle connectors (the USB-C ports on the Raspberry Pi and the power bank will appreciate the reduced stress that comes from not having the cable bend sharply), but you can use one you already have if you prefer. A 30cm (1 foot) cable should be more than long enough for this project if you plan on keeping the Raspberry Pi in the same space as the power bank.
Setting everything up
Once you've acquired all the necessary components for this project, here's what to do to get started.
Step 1: Put the Raspberry Pi into its case and start charging the power bank
How you do this will depend on the case you've purchased. If you find yourself trying to force the Raspberry Pi into the case, then you're probably not inserting it correctly. With the case I purchased, I found that the easiest way to do this was to insert the Raspberry Pi at an angle so that the side ports (USB-C, headphone, and micro-HDMI) slide into their respective openings on the case, at which point it was easy to angle the other side downward to flatten the board and align the USB-A and ethernet ports.
You should also start charging the power bank at this point. Make sure you plug the power bank into an AC adapter that has a USB-C connector and supplies 5 volts (at 3 amps or higher, depending on your power bank) for the fastest charging experience.
Step 2: Prepare the microSD card
Start by downloading the Raspberry Pi Imager from the Raspberry Pi website. Install it on your desktop or laptop computer.
Once you have the imager installed, insert the microSD card into the reader. Then plug the reader into the computer on which you installed the imager.
Start the imager. You should see a window similar to this one:

Click CHOOSE DEVICE and select
Raspberry Pi 4 (or whichever model of Raspberry Pi you actually have).
Click CHOOSE OS and select
Raspberry Pi OS (other). Then, select
Raspberry Pi OS Lite (64-bit).
Click CHOOSE STORAGE and select the drive which matches the memory card you just inserted. BE EXTREMELY CAREFUL not to select your computer's hard drive, your computer's SSD, a USB flash memory drive, or any other drive that contains data you wish to keep, as this process will erase any data on the drive you select. The easiest way to avoid unwanted data loss is to first unmount and remove any drives or memory cards you don't want to overwrite. Checking Exclude System Drives will at least prevent you from overwriting your hard drive or SSD.

Click NEXT, then click EDIT SETTINGS. In the window that appears, do the following:
- On the General tab, make sure Set Hostname is checked, then input a unique hostname for your Raspberry Pi that is not assigned to any other computer on your LAN.
- Make sure Set username and password is checked, then, choose a username and password for your Raspberry Pi. This user will have full access to the Raspberry Pi's root (administrator) account, so choose a secure password. Ideally, this should be a unique password that you do not use anywhere else. If you are in the habit of using the same password for all of your accounts (email, computer login, etc.), now is the time to break that habit.
- If you use a wireless LAN (Wi-Fi), make sure Configure wireless LAN is checked, then input your Wi-Fi SSID (network name) and password. Scroll down and choose the country in which your wireless LAN is located.
- Make sure Select locale settings is checked, then choose your time zone and preferred keyboard layout.
- On the Services tab, make sure Enable SSH is checked.
- If you use an SSH key, select the Allow public-key authentication only radio button and paste your SSH public key in the input box below. If you wish to add more than one SSH public key (for example, if you use a laptop and a desktop), click ADD SSH KEY and paste your other SSH public key(s) in the additional input box(es) that appear.
- If you don't use an SSH key (or don't know what an SSH key is), click the Use password authentication radio button.
- On the Options tab, make sure Eject media when finished is checked.
- Make sure Enable telemetry is unchecked.
- Click SAVE.
Click YES when asked if you would like to apply OS customization settings.
The imager will ask you one last time if you really want to continue. If you are absolutely sure that you have chosen the correct disk to image and wish to erase everything on it, then click YES. Otherwise, click NO.

The Raspberry Pi imager will now erase the disk you have chosen, and then install the Raspberry Pi OS on it. Depending on the speed of your microSD card, USB interface, and internet connection, this may take a long time to complete.

When the installation is complete and has been verified, you will see the following screen. Remove the microSD card from the reader, click CONTINUE, and close the Raspberry Pi Imager.

Step 3: Install the microSD card in the Raspberry Pi
The microSD card goes into the small opening in the case near the USB-C power input port, with the gold contacts facing up. The important bit to remember is that the card slot is towards the top of the opening. If you miss the card slot, the card will fall into the case and just rattle around inside, and you will have to open the case to retrieve the card. Once you have the card in the slot, gently push it all the way in. If the card won't go in all the way, you probably have the card facing the wrong way.

The correct orientation for the microSD card.

The microSD card partially inserted into the Raspberry Pi.

The microSD card fully inserted into the Raspberry Pi.
Step 4: Use SSH to connect to your Raspberry Pi
If you are using a wired LAN, connect the Raspberry Pi to your switch or router using an ethernet cable. If you are using a wireless LAN, make sure you are within range of your wireless access point.
Turn the Raspberry Pi on by connecting it to your charged power bank or to a USB-C AC adapter that can supply 5 volts and at least 3 amps.
Once the Raspberry Pi finishes booting up (this takes about 1-2 minutes for the initial boot), you can SSH into it.
If you are using Mac OS or Linux on your computer and your local network has a DNS server that supports addressing hosts by their hostname, you can open up the terminal app and type the following command, then press Enter:
ssh username@hostname
where username is the username you set during the configuration steps in the Raspberry Pi imager and hostname is the hostname you set during the configuration steps in the Raspberry Pi Imager.
If your local network does not have a DNS server that supports addressing hosts by their hostname, you will have to log into your router and determine which IP address has been assigned to your Raspberry Pi. Once you have determined this, open the terminal app and type the following command, then press Enter:
ssh username@ip_address
where username is the username you set during the configuration steps in the Raspberry Pi imager and ip_address is the IP address assigned to your Raspberry Pi.
If the username you selected for your Raspberry Pi is the same as the username on your Mac or Linux machine, you can omit username@ from the ssh command.
If you are using Windows, you will have to use PuTTY to SSH into your Raspberry Pi. Open PuTTY, type the hostname or IP address into the Hostname or IP address field, make sure SSH is selected as the connection type, and then click Open.
At this point, you should receive a warning that the server's host key is not cached. On Mac OS or Linux, type yes and press Enter. On Windows, click yes.
If you are using PuTTY, you will now be prompted for your username. Type it, then press Enter.
If you are using password authentication, you will be prompted for your password. Type the password you chose for your Raspberry Pi and press Enter. Note that, for security, you will not be able to see the password as you type it.
If you are using an SSH key for authentication, you will not be prompted for a password.
If you are successful at logging in, you should see a command prompt that looks like this:
username@hostname:~ $
Step 5: Update the OS
Make sure your Raspberry Pi is connected to the internet. Then, at the Raspberry Pi's command prompt, type the following command and press Enter:
sudo apt update; sudo apt upgrade
At this point, apt will first download an updated list of all software that can be installed on the Raspberry Pi, then determine which packages need to be upgraded. It will display the packages that it intends to upgrade and ask for you to confirm that you wish to upgrade them. Type Y and then press Enter, at which point apt will upgrade the packages it has just listed. Depending on the speed of your internet connection, this process can take some time to complete.
Once this process is complete, you will see a command prompt again. Type the following command and press Enter to reboot your Raspberry Pi:
sudo shutdown -r now
Your SSH session will be terminated and the Raspberry Pi will reboot.
Step 6: Install pulseaudio
Once your Raspberry Pi finishes rebooting, SSH into it as you did in step 4. This time, you should not be prompted to accept the host key, since your computer will now have the host key cached. If you are prompted to accept the host key, then you might be connecting to the wrong machine. If you are using password authentication, you will have to type your password in again.
At the Raspberry Pi's command prompt, type the following command and then press Enter:
sudo apt install pulseaudio pulseaudio-utils pulseaudio-module-bluetooth
You will see a massive list of packages that apt intends to install. Except for the three pulseaudio packages you instructed apt to install, these packages are dependencies of pulseaudio. Type Y and press Enter to begin installation. All of the listed packages will be downloaded and installed, and at the end of the process, you will be returned to the command prompt. This process may take quite a while to complete.
Step 7: Connect the audio interface to the Raspberry Pi
Plug the audio interface into one of the black USB 2.0 ports on the Raspberry Pi. Wait a few seconds, then type the following command at the Raspberry Pi's command prompt and press Enter:
sudo dmesg
You will see a massive wall of text fill your terminal window. Look for something similar to the following, which should be toward the very end of the wall of text (your output may differ somewhat depending on which USB audio interface you are using):
usb 1-1.4: new full-speed USB device number 3 using xhci_hcd
usb 1-1.4: New USB device found, idVendor=8087, idProduct=1024, bcdDevice= 1.00
usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1.4: Product: USB PnP Audio Device
If you see this, then your USB audio device was successfully recognized by the OS.
If you don't see anything similar to this, then your USB audio device was not recognized by the OS. Try plugging the USB audio interface into a different USB port and then use the sudo dmesg command again. If the USB audio device is still not recognized by the OS, you may have either a defective audio interface or a defective Raspberry Pi. Try plugging a different USB device, such as a keyboard or mouse, into the Raspberry Pi and see if it appears in the output of sudo dmesg. If the keyboard or mouse appears in the output of sudo dmesg, then the audio device is defective or not compatible with your Raspberry Pi. If the keyboard or mouse does not appear in the output of sudo dmesg and you know that the device works on every other computer, then you may have a defective USB port on your Raspberry Pi.
Step 8: Pair your Raspberry Pi with your car's stereo system
For this step, you want to make sure that your Raspberry Pi is powered by the power bank. Make sure the power bank has a decent charge before proceeding.
Additionally, you want to ensure one of two things: that your Raspberry Pi can connect to your LAN while within bluetooth range of your car's stereo, or that you have a keyboard and display that you can connect to your Raspberry Pi while it is in within bluetooth range of your car's stereo. The easiest option is to have a laptop you can use while in the car while the car is within range of your LAN's wireless access point.
If your Raspberry Pi is currently powered by an AC adapter, you want to shut it down before powering it from the power bank. In order to do this, make sure you are connected via SSH, then type the following command at its command prompt and press Enter:
sudo shutdown -h now
Wait for the Raspberry Pi to shut down completely before continuing (this should take no more than 20-30 seconds). The red power LED will stay on, but the green disk activity LED will stop blinking. Wait for 15 seconds after you see the green LED stop blinking, then unplug the Raspberry Pi from the AC adapter and plug it into the power bank. If you fail to do this and instead just unplug the Raspberry Pi from the AC adapter while it is running, you risk corrupting the microSD card. If you corrupt the microSD card, you will at the very least have to return to Step 2 and re-image the card. You might also damage the microSD card and have to replace it with a new card.
If the Raspberry Pi is already powered from the power bank, you don't have to shut it down.
Take the Raspberry Pi, the power bank, and your laptop to your car. Make sure your car is within range of your wireless network, then connect your laptop to your wireless network and SSH into your Raspberry Pi like you did in Step 4.
If you are unable to connect to your wireless network from where you park your car, then you will need to get a keyboard and display that you can plug into the Raspberry Pi. Fortunately, there are plenty of small displays on amazon.com and the like that you can power from your car's 12-volt cigarette lighter socket and connect to the micro-HDMI ports on the Raspberry Pi. Don't bother with the displays that are built specifically for the Raspberry Pi unless you want something that's not compatible with anything but the Raspberry Pi; these displays will require you to open the case and plug a ribbon cable directly into a connector on the Raspberry Pi.
Now that you are in the car and have an SSH session open to the Raspberry Pi, type the following command at the Raspberry Pi's command prompt and press Enter:
sudo bluetoothctl
You will be greeted with the following command prompt:
[bluetooth]#
First, give your Raspberry Pi a bluetooth name that your car will see. The easiest option is to use the hostname that you gave the Raspberry Pi when you imaged the microSD card in Step 2, but you can choose any name you want. At the bluetooth prompt, type the following command and press Enter:
system-alias 'bluetooth name'
where bluetooth name is the name you want your Raspberry Pi to use for bluetooth connections. The single quotes are optional if your bluetooth name does not contain spaces. If you want to use spaces, you must surround the bluetooth name with single quotes.
Now, put your Raspberry Pi into bluetooth scanning mode by typing the following command, then pressing Enter:
scan on
You will start to see the bluetooth addresses and names of any discoverable bluetooth devices that are within range of the Raspberry Pi. Depending on how many bluetooth devices are nearby, this could be a very long list. If you are in the middle of nowhere, then you won't see very many devices listed. The output will look something like this:
[NEW] Device 00:11:22:33:44:55 00-11-22-33-44-55
[NEW] Device 66:77:88:99:AA:BB 66-77-88-99-AA-BB
[NEW] Device CC:DD:EE:FF:00:11 CC-DD-EE-FF-00-11
Now, put your car's stereo into pairing mode. How you do this will differ based on which car you have, so check your car's instruction manual for details. Once you do this, you will eventually see a line of text on your terminal display that looks something like this:
[NEW] Device AA:BB:CC:DD:EE:FF Your Car's Bluetooth Name
where AA:BB:CC:DD:EE:FF is your car stereo's unique bluetooth address and Your Car's Bluetooth Name is the bluetooth name your car stereo's display tells you to look for on the device you wish to pair.
You can now turn off scanning on your Raspberry Pi by typing the following command and pressing Enter:
scan off
At this point the text output from the scan will stop, except for a few more lines of output.
Now you can pair the Raspberry Pi with your car by typing the following command and pressing Enter.
pair AA:BB:CC:DD:EE:FF
where AA:BB:CC:DD:EE:FF is your car stereo's unique bluetooth address. Your car stereo will display a unique six-digit pairing code, just as if you were pairing your phone with it. You will see output similar to the following on your Raspberry Pi terminal display:
Attempting to pair with AA:BB:CC:DD:EE:FF
[CHG] Device AA:BB:CC:DD:EE:FF Connected: yes
Request confirmation
[agent] Confirm passkey 654321 (yes/no):
where 654321 is the six-digit code that is displayed on your car stereo. Confirm that the numbers on the two devices match, then type yes and press Enter.
At this point, you will be asked to confirm which Bluetooth profiles (capabilities) you want your Raspberry Pi to use with this bluetooth connection. The profiles are identified by their UUIDs instead of their names, which is rather irritating. The profiles you're looking for are:
0000110b-0000-1000-8000-00805f9b34fb
and
0000110d-0000-1000-8000-00805f9b34fb
Note that the only difference between these two is the final character of the first group. Answer yes to these two and no to all the rest. You will see output that ends with the following text:
[CHG] Device AA:BB:CC:DD:EE:FF Paired: yes
Pairing successful
Now, connect to your car via bluetooth by typing the following command and pressing Enter:
connect AA:BB:CC:DD:EE:FF
where AA:BB:CC:DD:EE:FF is your car stereo's unique bluetooth address. If the Raspberry Pi succeeds at connecting to your car stereo, you will see the following text output on your terminal:
[CHG] Device AA:BB:CC:DD:EE:FF Connected: yes
Connection successful
Finally, tell your Raspberry Pi to trust the car stereo by typing the following command and pressing Enter:
trust AA:BB:CC:DD:EE:FF
where AA:BB:CC:DD:EE:FF is your car stereo's unique bluetooth address. You will see text similar to the following on your terminal:
[CHG] Device AA:BB:CC:DD:EE:FF Trusted: yes
Changing AA:BB:CC:DD:EE:FF trust succeeded
where AA:BB:CC:DD:EE:FF is your car stereo's unique bluetooth address. You can now exit bluetoothctl by typing the following command and pressing Enter:
exit
The bluetoothctl program will exit and you will be returned to the linux command prompt.
Confirm that everything has been set up correctly by typing the following at the linux command prompt and pressing Enter:
pactl list sinks
In the very long output that follows, you will see a number of different devices listed. You should be able to recognize your car stereo in the output:
Sink #1Name: bluez_sink.AA_BB_CC_DD_EE_FF.a2dp_sink
Description: Your Car's Bluetooth Name
Save this output to a text file by typing the following command and pressing Enter:
pactl list sinks > sinks.txt
Note that this command will not produce any output on the screen. You can verify that it worked by typing the following command and pressing Enter:
cat sinks.txt
at which point the program's output will display on your terminal.
Step 9: Set up pulseaudio to relay audio from the USB interface to your car
Plug the USB audio interface into a black USB 2.0 port on your Raspberry Pi (if it is not already plugged in). Then, type the following command and press Enter:
pactl list sources
You will see a list of audio sources similar to the output of the pactl list sinks command you issued in Step 8. You should be able to recognize your USB audio interface by its description (this will vary depending on which USB audio interface you are using):
Source #0Name: alsa_input.usb-USB_PnP_Audio_Device-00.analog-stereo
Description: USB PnP Audio Device Analog Stereo
Save this output to a text file by typing the following command and pressing Enter:
pactl list sources > sources.txt
Note that this command will not produce any output on the screen. You can verify that it worked by typing the following command and pressing Enter:
cat sources.txt
at which point the program's output will display on your terminal.
Note the name of the source corresponding to the USB audio interface. You will need this information shortly. You will also need to know the name of the sink corresponding to your car's stereo system. If you no longer have this information in your terminal window, you can call it up by typing the following command and pressing Enter:
cat sinks.txt
Now, you will need to edit a text file in order to configure pulseaudio to relay audio from the USB audio interface to the car stereo via bluetooth. In the Raspberry Pi terminal window, type the following command and press Enter:
sudo nano /etc/pulse/default.pa.d/car-audio.pa
If you are already familiar with Linux and have a favorite text editor other than nano, then feel free to use that instead! Otherwise, stick with nano.
Type the following into the text editor:
### Configuration for bluetooth car audio
# Configure default sink and source
set-default-sink bluez_sink.AA_BB_CC_DD_EE_FF.a2dp_sink
set-default-source alsa_input.usb-PnP_Audio_Device-00.analog-stereo
# Set source volume
set-source-volume alsa_input.usb-USB_PnP_Audio_Device-00.analog-stereo 65536
# Load loopback module and set latency to 60 milliseconds
load-module module-loopback latency_msec=60
Now, save the file and exit nano by holding Ctrl and pressing X. nano will ask you if you want to save the buffer. Press Y, then press Enter when prompted for the file name to write.
Note that 65536 in the file above corresponds with 100% input volume. Depending on your audio interface and audio device, you may have to try smaller values if this results in distorted sound when played through your car stereo.
Step 10: Set up the Raspberry Pi to automatically connect to the car when booting
At the Raspberry Pi's command prompt, issue the following command and press Enter:
sudo raspi-config
You will be presented with a menu of options. Follow these steps:
- Use the arrow keys to highlight System Options and press Enter.
- Use the arrow keys to select Auto Login and press Enter.
- Use the arrow keys to select Yes and press Enter.
- Press Enter to confirm your choice.
- Use the Tab key to select Finish and then press Enter.
You will be returned to the command prompt. Type the following command and press Enter:
bluetoothctl devices
Find your car stereo's entry in the resulting output and note the unique bluetooth address.
Now you will set up your Raspberry Pi to automatically connect to your car at boot time. I have written a small program in the Python programming language to handle this for you. Luckily, I won't make you manually type this program in. All you have to do is download the program and change one line towards the top.
At your Raspberry Pi's command prompt, type the following command, then press Enter:
cd /usr/sbin/
Now, make sure your Raspberry Pi is connected to the Internet. Then, at your Raspberry Pi's command prompt, type the following command, then press Enter:
sudo curl -O https://djzfrog.com/bluetooth/bluetooth-connect.py
Note that the -O after curl contains the capital letter O, not the number zero.
Now, it's time to change one line in the program. Open the source code by typing the following command and pressing Enter:
sudo nano bluetooth-connect.py
Find the line at the top which begins with car_bt_address and change the sample bluetooth address to the car stereo's unique bluetooth address that you noted above. It is vitally important that you do not remove the single quotes which surround the sample bluetooth address. If you do remove the quotes, the program will not work.
Save the file and exit nano by holding Ctrl and pressing X. nano will ask you if you want to save the buffer. Press Y, then press Enter when prompted for the file name to write.
Now, it's time to make this program run at boot time. First, make the program executable by typing the following at the Raspberry Pi's command prompt, then press Enter:
sudo chmod +x bluetooth-connect.py
Next, type in the following command and press Enter:
sudo nano /etc/profile.d/bluetooth-connect.sh
Type the following into the text editor:
bluetooth-connect.py &
The & is important, as it makes the program run in the background. Without it, you will never be able to access a command prompt if you find yourself needing to ssh back into your Raspberry Pi again (unless you're fond of having to hit Ctrl-C every single time you log in).
Save the file and exit nano by holding Ctrl and pressing X. nano will ask you if you want to save the buffer. Press Y, then press Enter when prompted for the file name to write.
Now the Raspberry Pi will automatically log into itself after it finishes booting up, and the bluetooth-connect.py program will run automatically after logging in.
Step 11: Set up the Raspberry Pi to automatically shut down safely when it loses bluetooth connectivity to your car
You will be running the Raspberry Pi without a keyboard or display while in the car. Because of this, you will want some method of shutting the OS down safely when you are done playing audio. If you were to just unplug the USB-C power cable while the Raspberry Pi is powered up, you would run the risk of corrupting the microSD card, resulting in you having to re-image the card and run through all of the above steps again. In this step, you will set up the Raspberry Pi to automatically shut down when it detects a loss of Bluetooth connectivity to the car stereo (i.e. when you turn off the car after you reach your destination).
I have written a small program in the Python programming language to handle this for you. As in the previous step, all you will have to do is download the program and change one line towards the top.
First, make sure your Raspberry Pi is connected to the Internet. At your Raspberry Pi's command prompt, type the following command, then press Enter:
cd /usr/sbin/
Now type the following command and press Enter:
sudo curl -O https://djzfrog.com/bluetooth/bluetooth-monitor.py
Note that the -O after curl contains the capital letter O, not the number zero.
Now, it's time to change one line in the program. Open the source code by typing the following command and pressing Enter:
sudo nano bluetooth-monitor.py
Find the line at the top which begins with car_bt_address and change the sample bluetooth address to the car stereo's unique bluetooth address that you noted in Step 10. It is vitally important that you do not remove the single quotes which surround the sample bluetooth address. If you do remove the quotes, the program will not work.
Save the file and exit nano by holding Ctrl and pressing X. nano will ask you if you want to save the buffer. Press Y, then press Enter when prompted for the file name to write.
Now that you are back at the command line, you need to make the Python program executable. Type the following command and press Enter:
sudo chmod +x bluetooth-monitor.py
Next, you need to make bluetooth-monitor.py run automatically when the Raspberry Pi boots up. Type the following command and press Enter:
cd /etc/systemd/system/
Now, download the configuration file which will make bluetooth-monitor.py run automatically at boot time. Type the following command and press Enter:
sudo curl -O https://djzfrog.com/bluetooth/bluetooth-monitor.service
Next, you will need to make systemd recognize the file you just downloaded. Type the following command and press Enter:
sudo systemctl daemon-reload
Finally, you must enable the service so that systemd will start it at boot time. Type the following command and press Enter:
sudo systemctl enable bluetooth-monitor.service
Now, to check if the service was successfully enabled, type the following command and press Enter:
sudo systemctl status bluetooth-monitor.service
You should see something similar to the following:
bluetooth-monitor.service - Bluetooth connection monitor for auto-shutdownLoaded: loaded (/etc/systemd/system/bluetooth-monitor.service; enabled; preset: enabled)
Active: inactive (dead)
Make sure the output says enabled and you are ready to go!
Shut your Raspberry Pi down by typing the following command and pressing Enter:
sudo shutdown -h now
Wait about 10-15 seconds after the green LED on your Raspberry Pi stops flashing, then unplug the USB-C power cable.
Step 12: Make sure everything works
Ensure your Raspberry Pi is turned off, then plug the USB audio interface into the Raspberry Pi if it is not already plugged in. Turn your car on, wait for the stereo to finish booting up, and then plug the USB-C power cable into your power bank and your Raspberry Pi. If you have performed all the above steps correctly, the Raspberry Pi will boot up and automatically connect to your car stereo.
Connect your audio source (e.g. a MiniDisc player) to the USB audio interface. On your car stereo, select the Raspberry Pi as your audio source, just as if you were playing audio from your phone or some other bluetooth device. Make sure the volume on the car stereo is turned down to a moderate level and start the audio on your audio source. You should hear audio played through your car stereo.
Turn off your car and its stereo (some stereos stay on until you open the driver's door) and see if the Raspberry Pi shuts down (the green LED will stop blinking).
If the audio does not stream through your car stereo, you may have made a typo in one of the configuration files. Read through all of the above steps and verify that everything is exactly correct.
CONGRATULATIONS! YOU DID IT!
Please feel free to email me at djzfrog@djzfrog.com with your comments or questions!