AVR, Raspberry Pi, VW Beta: VAG CDC Faker

AVR, Raspberry Pi, VW Beta: VAG CDC Faker

(4 votes, average: 5.00 out of 5)

I was tired connecting my cellphone with an old cassette adapter to my VW Golf with an Beta 5 in it. I needed something new, something cool. And here it is, a fully functional interface between the Beta 5 and any device you want to play the music with.

This project raised out of an ebay search: I just wanted to know if there is a solution to get an AUX input on the car radio. Yes there is, even complete mp3 players are available. But that’s not what I wanted – at first!

Then I started digging the web for more info about the protocol the radio talks to cd changers.
The idea was to build a tiny thingy that fakes a cd changer and simply enables the AUX input (as it is available in several online stores). But during the development my ambition became greater and I wanted to read the keys pressed on the radio to remote control my RPi.

1. Understanding the Protocol

First of all this is the pinout of the radio:
The interesting cell is no. 3, the blue one.
DATA IN simply is MOSI of an 8bit SPI interface with special timings between the bytes
CLOCK is SCK of the SPI
DATA OUT is the key code of the pressed key on the radio itself

The radio needs a sequence of bytes to enable the AUX input and display CD# and TR#. It looks likes this:

frame cd#   tr#   time  time  mode  frame frame
0x34, 0xBE, 0xFF, 0xFF, 0xFF, 0xFF, 0xCF, 0x3C

cd# and tr# are sent inverted. So this sequence will display: CD1 TR00
mode sets the playmode (PLAY|SHFFL|SCAN)
As the beta doesn’t support time display, I will ignore these bytes.

If cd mode is switched on/off or keys are pressed, 4 byte messages will be sent from the radio. They are coded like RC5 messages.
Each message has a startsequence. A low byte has a short low phase, a high byte a longer low phase. Everything you need to know can be found in the pictures here:

2. Remote commands from the radio

As you know 4 byte messages are sent. The following pattern describes the control codes:

head head cmd  !cmd
0x53 0x2C 0xAA 0x55

Here is the complete list of all bytes from all keys:

switch on in cd mode/radio to cd (play)
0x53 0x2C 0xE4 0x1B
0x53 0x2C 0x14 0xEB

switch off in cd mode/cd to radio (pause)
0x53 0x2C 0x10 0xEF
0x53 0x2C 0x14 0xEB

0x53 0x2C 0xF8 0x7

0x53 0x2C 0x78 0x87

seek next
0x53 0x2C 0xD8 0x27 hold down
0x53 0x2C 0xE4 0x1B release
0x53 0x2C 0x14 0xEB

seek prev
0x53 0x2C 0x58 0xA7 hold down
0x53 0x2C 0xE4 0x1B release
0x53 0x2C 0x14 0xEB

cd 1
0x53 0x2C 0x0C 0xF3
0x53 0x2C 0x14 0xEB
0x53 0x2C 0x38 0xC7
send new cd no. to confirm change, else:
0x53 0x2C 0xE4 0x1B beep, no cd (same as play)
0x53 0x2C 0x14 0xEB

cd 2
0x53 0x2C 0x8C 0x73
0x53 0x2C 0x14 0xEB
0x53 0x2C 0x38 0xC7
send new cd no. to confirm change, else:
0x53 0x2C 0xE4 0x1B beep, no cd (same as play)
0x53 0x2C 0x14 0xEB

cd 3
0x53 0x2C 0x4C 0xB3
0x53 0x2C 0x14 0xEB
0x53 0x2C 0x38 0xC7
send new cd no. to confirm change, else:
0x53 0x2C 0xE4 0x1B beep, no cd (same as play)
0x53 0x2C 0x14 0xEB

cd 4
0x53 0x2C 0xCC 0x33
0x53 0x2C 0x14 0xEB
0x53 0x2C 0x38 0xC7
send new cd no. to confirm change, else:
0x53 0x2C 0xE4 0x1B beep, no cd (same as play)
0x53 0x2C 0x14 0xEB

cd 5
0x53 0x2C 0x2C 0xD3
0x53 0x2C 0x14 0xEB
0x53 0x2C 0x38 0xC7
send new cd no. to confirm change, else:
0x53 0x2C 0xE4 0x1B beep, no cd (same as play)
0x53 0x2C 0x14 0xEB

cd 6
0x53 0x2C 0xAC 0x53
0x53 0x2C 0x14 0xEB
0x53 0x2C 0x38 0xC7
send new cd no. to confirm change, else:
0x53 0x2C 0xE4 0x1B beep, no cd (same as play)
0x53 0x2C 0x14 0xEB

scan (in 'play', 'shffl' or 'scan' mode)
0x53 0x2C 0xA0 0x5F

shuffle in 'play' mode
0x53 0x2C 0x60 0x9F

shuffle in 'shffl' mode
0x53 0x2C 0x08 0xF7
0x53 0x2C 0x14 0xEB

The micro controller will only send the 3rd byte after error check over uart. See below.

3. The Hardware I picked

  • Atmel ATmega32A
  • 1117 Regulator (maybe not the best, it’s heating up at >50mA due to the high drop voltage)
  • FTDI FT230X as uart usb bridge
  • ISO connector to fit into the radio

4. Programming the AVR

First thing about the uart communication. I use the library of Peter Fleury:
To be independent from clockrates I utilized delay loops instead of timers to create correct timings. Hopefully my comments in the code explains everything very well.

Additional info can be found here: (in German)

5. The Circuit

Nothing special here, just an ISP header for programming the AVR, USB connector, voltage regulator, LED,…
For feature circuits in the glovebox I provided 12V, 5V and GND through further pins. I was thinking of powering the RPi directly from my faker. But I don’t know if the radio is able to provide around 400mAmps. Even the regulator would heat up like hell at these currents.
The FT230X is programmed as selfpowered and CBUS1 as output for the #POWER_ON singnal.

6. Bringing all together: MPD and RPi

Now we need a wrapper for mpc to let mpd act as our cd changer. I’ve written a python script to evaluate the radio commands and send cd and track numbers back periodically. The script starts at startup by the rc.local and checks for the connected faker.
The last listened cd no. will be stored in a file to send it to the faker if something is restarted or reconnected. I let the script stop mpd to save power and make sure the current settings are synced with the filesystem, because a powerfail will cause a corrupted playlist.
The music is stored in /var/vag_cdc/cdX where X is the cd no. 1 to 6. You can put up to 99 tracks in each folder due to radio display limitations.

7. Some further ideas

The project is mostly complete – for now. But there are some things I have in mind that could be quite nice to have. It would be awesome if it had bluetooth to remote control my android phone. Or mute the radio at incoming calls and act as a hands free set.
But what I’ve done lately is preparing the RPi with Wifi, so it connects automatically to my Wifi, when parking in the garage to sync the music folders with rsync.

  • summi

    Here somebody has done the bluetooth part:
    Both part together would be similar like this:

    • Nice link about the bluetooth part! But I thought more about a version without the RPi.
      The ready to buy product is what I found, too. But did you take a look at the price? I don’t count the RPi as it is a multipurpose devce. Everything together in my project is less than EUR 20.

  • su541

    Do you think, that i can use an “arduino uno” as hardware? It uses an amtel atmega328.

    • Yes you can. Maybe you need to modify some settings and registers.

  • Vilius

    Is it possible to get stereo sound from this?

    • Of course it is!

      • Vilius

        maybe you can give some advice, how to do that? p.s. great work!!!

        • Well, how can I help you in particular? Maybe you write me an email and I can answer your questions.
          The RPi supports stereo out of the box.

          • Vilius

            can i get your email than? or atleast, can you write me on P.s. i already modified the schematics for stereo, so i guess code left

  • Tomas
    • Great! Thanks for sharing!

  • tomas
  • Andrew

    Great work, Can you give a detailed wiring diagram how Raspberry is connected to the radio?

    • Thanks!
      The RPi is not connected directly to the radio. It’s connected through USB to my circuit which is connected to the CD-Changer socket on the radio.

      • Andrew

        Thanks for the explaination. Now I understand how it is working :)

  • Lacho

    Great post, thanks for the info! Do you think the same commands can work for a RCD300 radio (vw passat)?

    • Hi Lacho, my guess: yes, it should. The RCD300 pinout looks like this:
      These are the same pins I use.
      So give it a try and let me know, if you are making any progress.

      • Lacho

        I’ll try it, fingers crossed :) btw I noticed in the schematic the SPI pins are connected directly – that doesn’t need any level shifting, right? They run on 5v?

        • Yes, they run at 5V. Good luck then!

          • Lacho

            So I have some progress… the good news is that the SPI commands seem to work – I managed to get the cd changer screen to show up.

            The strange thing is that no audio gets out of it – I tried both on the AUX pins and the CD-R/L pins. I thought that when it recognizes a cd changer it will unmute them, but perhaps I’m missing something…
            Another strange thing is that the SPI communication seems quite unstable – it “magically” started working and now magically stopped working :) And I used to get some weird readings on the screen like CD FE, TRACK 0F… And when it was working, it was like once out of 5 times :)

            What I do is to continuously send this sequence with 41ms delay:
            0x34, 0xBE, 0xFF, 0xFF, 0xFF, 0xFF, 0xCF, 0x3C

            I’ve kept the delays as in your code.

            I suspect it may be something in the hardware, my mcu uses 3.3v on the SPI lines, I hooked it up directly to the radio, also tried level shifting to 5v… no difference. It runs on 62500 HZ, mode 0. I’ve connected the CDC GND, CLOCK and DATA IN pins.
            If you notice anything wrong with the above, please let me know.

            I’ll leave it for today and will continue digging tomorrow.
            Thanks again for all the info – it’s very useful!

            • That sounds great! Try to change the cd and track number. My radio can display hex too. Keep in mind that audio GND is not the circuit GND. Do you have a scope to analyse the edges after level shifting? Feel free to write me mails to avoid long reply chains in here.

  • Maciek

    Hi! Last time I interested in your project and I’m trying to build CDC Faker but on Arduino UNO with MP3 Player Shield. I tried to connect Arduino with radio but Arduino didn’t see any signals on RX pin (UART). The same situation were when I sent prepared message to the radio – nothing. Have You any ides how can I solve this problem?
    Thanks for all tips.

    • Юрий

      There is no UART in VW Beta, it use SPI.

      • Exactly beta arduino needs to be SPI as described, arduino to whatever can be UART as in my project.

  • Bartek

    Great project, much respect :)
    Im wondering, will it work with Alfa Romeo/Fiat radio units?
    Pinouts are basically the same. I need to build sth like this for Alfa Romeo since there is no possibility to play any external source

  • Kostas

    Nice project!
    I tried with Raspi and Uno on a Concert II , it works but it has a problem. Cd +/- buttons don’t work. Maybe it needs to know the number of available cds on connection. Any thoughts?
    Thank you.

  • Pingback: VW Golf 5 Grunding (Blaupunkt) RCD300 programming()