Adding Airplay to your stock car stereo

Heute ist Stammtischzeit:
Jeden Donnerstag 20:30 Uhr hier im Chat.
Wer Lust hat, kann sich gerne beteiligen. ;)
  • How do you like this project? 4

    1. That's pretty cool! (4) 100%
    2. Nothing for me here. (0) 0%

    I am driving a Volkswagen Golf 5 which was built in 2006.
    The standard sound system itself is pretty descent, but it lacks a Line in port.

    These days it seems to be standard to provide that, but back in 2006 it wasn't.
    So here are the steps in short, followed by the detailed description:
    (Steps 1 to 4 are completely optional, if you already have a line input in your car)

    1.) Disassembling the the Dashboard of the car, unmounting the stock radio (in my case: VW RCD 300).
    2.) Plugging a USB/AUX/Line interface into the to stock car stereo. It acts to the car stereo as a virtual disc changer, so that it is accessible through the standard buttons.
    You need to search for one, that has the plugs needed by your car model.
    2a.)Pulling the wires from the USB interface to my glove compartment. This is where the RPi is gonna be sitting as well.
    2b.)The RPi is connected to the Interface Box through a 3,5 mm line cable.
    3.) Configuring the RPi as WiFi access point.
    4.) Installing shairport on the RPi to provide an airplay server.

    My RPi is powered through a 12V car charger by TomTom which works perfect. One of the 2 outlets provides 2A (which is use for my RPi) and the other one provides 1A. TomTom High Speed USB Charger [Anzeige]

    Someone pointed out, that just pulling the plug when stopping the car isn't that good for the filesystem. I am aware of that, but actually I find it not convenient to write a script for that and controlling that via my phone before shutting down the car.
    You get the point: I want a hassle free step-in-start-driving-listening-to-music-device an I think thats pretty much what I did.

    1.) Disassembling the the Dashboard of the car, unmounting the stock radio (in my case: VW RCD 300)

    It's basically just fiddling around with some sharp tools, to bend out those plastic parts around the car stereo.
    For my Golf, I had to remove the climatic sensor first:
    zhij.jpg


    Only a few screws that hold the stereo:
    rlot.jpg

    2.) Plugging a USB/AUX/Line interface into the to stock car stereo.

    I used this one here, as it provides lots of connectivity on fitted my stock car stereo: USB AUX Adapter on Amazon [Anzeige] .
    IMPORTANT: Most of this adapters need to be grounded by connecting the already existent ground cable to some metallic part of the car with a small screw. I found some space behind the stereo, where the screw fitted and it was no hassle.
    If you are not hearing any sound you should definitely checked if your parts are grounded!

    3.) Configuring the RPi as a WiFi access point

    I first but some Edimax Dongle: EDIMAX EW-7811UN [Anzeige]
    Problem No. 1: It draws to much power from the RPis USB outlet. WiFi and so airplay was not stable.
    Problem No. 2: The chipset. It's said to be a Realtek RTL8188CUS, which is not ideal to configure the RPi as an access point. I got it working, but it was a hassle as I had to compile a special version of hostapd (The Access point package).


    This led me to another dongle: Bigtec Nano Dongle [Anzeige]
    Chipset here is a Ralink RT5370.
    And that did the trick. No driver installation needed, it just works after a reboot.


    Now let's get to installing the Accesspoint software (hostapd). I got my instructions mainly from: http://elinux.org/RPI-Wireless-Hotspot
    We don't follow all those steps for our purpose, as weed don't need NAT etc. at the moment in our car.
    Here we go:

    Install the necessary software:

    Code
    sudo apt-get install hostapd udhcpd


    Configure DHCP. Edit the file /etc/udhcpd.conf and configure it like this:

    Code
    start 192.168.2.2 # This is the range of IPs that the hostspot will give to client devices.
    end 192.168.2.20
    interface wlan0 # The device uDHCP listens on.
    remaining yes
    opt dns 8.8.8.8 4.2.2.2 # The DNS servers client devices will use.
    opt subnet 255.255.255.0
    opt router 192.168.2.1 # The Pi's IP address on wlan0 which we will set up shortly.
    opt lease 864000 # 10 day DHCP lease time in seconds


    Edit the file /etc/default/udhcpd and change the line:

    Code
    DHCPD_ENABLED="no"
    
    
    
    
    #DHCPD_ENABLED="no"


    You will need to give the Pi a static IP address with the following command:

    Code
    sudo ifconfig wlan0 192.168.2.1


    To set this up automatically on boot, edit the file /etc/network/interfaces and replace the line "iface wlan0 inet dhcp" to:

    Code
    iface wlan0 inet static
     address 192.168.2.1
     netmask 255.255.255.0


    If the line "iface wlan0 inet dhcp" is not present, add the above lines to the bottom of the file.

    Change the lines (they probably won't all be next to each other):

    Code
    allow-hotplug wlan0
    wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
    iface default inet manual


    to:

    Code
    #allow-hotplug wlan0
    #wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
    #iface default inet dhcp


    3. Configure HostAPD. You can create an open network, or a WPA-secured network. A secure network is recommended to prevent unauthorized use and tampering, but you can also create an open network. To create a WPA-secured network, edit the file /etc/hostapd/hostapd.conf (create it if it doesn't exist) and add the following lines:

    Change ssid=, channel=, and wpa_passphrase= to values of your choice. SSID is the hotspot's name which is broadcast to other devices, channel is what frequency the hotspot will run on, wpa_passphrase is the password for the wireless network.


    IMPORTANT: if you're having trouble with hostapd when using WPA encryption, please try an open network first, to see if it works.


    If you would like to create an open network, put the following text into /etc/hostapd/hostapd.conf:


    Code
    interface=wlan0
    ssid=My_Car
    hw_mode=g
    channel=6
    auth_algs=1
    wmm_enabled=0


    Change ssid= and channel= to values of your choice. Note that anyone will be able to connect to your network now.

    Edit the file /etc/default/hostapd and change the line:


    Code
    [align=left]#DAEMON_CONF=""
    [/align]
    [align=left]to:[/align]
    DAEMON_CONF="/etc/hostapd/hostapd.conf"


    Alright: Now start the services:

    Code
    sudo service hostapd start
    sudo service udhcpd start


    To start those everytime you plug your Pi:

    Code
    sudo update-rc.d hostapd enable
    sudo update-rc.d udhcpd enable

    IMPORTANT: When connecting to this network with our iDevice, enter your network settings, chose static an enter only the IP Adress given to your iDevice before an the subnet 255.255.255.0

    This ensures, that you can browse over 3G while beeing connected to the wireless network, which of course cannot provide an internet connection at the moment.



    Defining the standard audio device:

    Code
    sudo amixer cset numid=3 1

    Updating packet lists and needed packages:

    Code
    sudo apt-get update
    sudo apt-get install libao-dev libssl-dev libcrypt-openssl-rsa-perl libio-socket-inet6-perl libwww-perl avahi-utils git

    Installing a needed library. Be patient, this can take a while!

    Code
    sudo cpan Net::SDP

    Getting the latest shairport:

    Code
    sudo git clone https://github.com/albertz/shairport.git

    Compiling and installing shairport:

    Code
    cd shairport
    sudo make
    sudo make install

    Copying the sample script into the correct folder and changing permissions:

    Code
    sudo cp shairport.init.sample /etc/init.d/shairport
    sudo chmod a+x /etc/init.d/shairport

    Adding the required run level:

    Code
    sudo update-rc.d shairport defaults

    We like to have a nice Airplay Name, so we edit the following file:

    Code
    sudo nano /etc/init.d/shairport

    In this file we search for the NAME field an change "AirPi" to the name of our liking. Mine ist "Michaels Golf".


    Finally we can start shairport: (If anything goes wrong, please try a reboot at this point)

    Code
    sudo /etc/init.d/shairport start

    Have fun with this one!

    rzaa.jpg[/align]

    Einmal editiert, zuletzt von michif100 (28. Juni 2013 um 22:33)

Jetzt mitmachen!

Du hast noch kein Benutzerkonto auf unserer Seite? Registriere dich kostenlos und nimm an unserer Community teil!