Not joined yet? Register for free and enjoy features such as alerts, private messaging and viewing latest posts and topics.

HOWTO: DIY IBus iDevice dock - including MFSW + track info

User avatar
sk93
Lifer
Lifer
Posts: 3970
Joined: Mon Oct 19, 2009 9:20 pm
Location: Nottingham
Contact:

Re: HOWTO: DIY IBus iDevice dock - including MFSW + track in

Post by sk93 » Fri Aug 23, 2013 10:49 pm

yes :)

I've found a 30pin male to 30pin female extension cable, which should mean the ashtray mounting option is a go again.
I've also ordered an arduino, rasberry pi and another board who's name escapes me, but runs the microsoft.net compact framework (MUCH easier than everything else for me!)

I've written a small app now for the arduino that will sit on the bus and stream all the data it collects via the usb port (and then to an app i've written on the pc that will record that data and save it out to a text file).

When the board arrives, I'll be installing the app and hooking it up to the bus behind the radio and streaming all the data - just to make sure I'm on the money with how the codes all function.


I've also written a dotNet app that goes out to an old usb prototyping board I have to test controlling the idevice, and I've got it able to skip track, fastforward and play/pause perfectly - so that's a good start :)

Basically, I'm now a bit in limbo as I wait for the programming boards to arrive (should be sometime next week).
Once I get them, it's on to checking the bus codes and then seeing if I can translate them over to iPod control :)


After all that, that's when the real fun will start (sending data back on the bus for the radio - such as track name etc ;)


Oh..and I've worked out how I'm going to do the cd changer business ;)
really simple - I'm going to hook in a mini relay on the charging lines of the idevice cradle.
when the device is in place, current flowing through the charging circuit will power the relay coil... and the other end of the relay will then drive another relay placed inbetween the ibus and the cd changer.
when the idevice is connected, the cd changer will be disconnected from the bus.
when it's not connected, the changer will be reconnected :)

haven't tested this at all.. no idea if removing it from the bus will cause some issues, so I'll look into it a bit more first.
But I can't see it being an issue :)
:zzzz:

User avatar
LukeMace
Senior Member
Senior Member
Posts: 1918
Joined: Wed Apr 18, 2012 7:40 pm
Location: Northampton

Re: HOWTO: DIY IBus iDevice dock - including MFSW + track in

Post by LukeMace » Fri Aug 23, 2013 11:44 pm

Damn, good work buddy! Very nice indeed :thumbsup:
3.0, Quad Conversion, 19" CSLs, Bucket Seats, Big Brake Conversion, Lowered 40mm, AE and Clear Hockeys etc...
CLICK HERE FOR THE BUILD THREAD
Image

User avatar
Stuart Truman
Lifer
Lifer
Posts: 13039
Joined: Wed Jul 27, 2011 10:59 pm
Location: The Cotswolds

Re: HOWTO: DIY IBus iDevice dock - including MFSW + track in

Post by Stuart Truman » Sat Aug 24, 2013 8:12 am

To avoid errors when your relay is triggered, maybe you could run an event sequence that changes the head unit momentarily to the aux port, flips the relay and then back to the cd changer. That way it shouldn't see the broken connection and hopefully not put an error in the memory.
Add yourself to the Z4 Map HERE! Instructions HERE!
Z4M Roadster, Imola Red, with Stubby and Intravee II. Low Miles per Gallon, High Smiles per Gallon
Previously Alpina Roadster S #69 Alpina Blue

User avatar
Taz
Lifer
Lifer
Posts: 19501
Joined: Tue Jul 14, 2009 9:56 pm
Location: Saddleworth

Re: HOWTO: DIY IBus iDevice dock - including MFSW + track in

Post by Taz » Sat Aug 24, 2013 8:30 am

there are some smart cookies on this site :) :thumbsup:

User avatar
sk93
Lifer
Lifer
Posts: 3970
Joined: Mon Oct 19, 2009 9:20 pm
Location: Nottingham
Contact:

Re: HOWTO: DIY IBus iDevice dock - including MFSW + track in

Post by sk93 » Sat Aug 24, 2013 8:39 am

Stuart Truman wrote:To avoid errors when your relay is triggered, maybe you could run an event sequence that changes the head unit momentarily to the aux port, flips the relay and then back to the cd changer. That way it shouldn't see the broken connection and hopefully not put an error in the memory.
that's a cracking idea :thumbsup:
:zzzz:

User avatar
srhutch
Moderator
Moderator
Posts: 26959
Joined: Tue Jun 19, 2007 1:22 pm
Location: East Sussex, UK
Contact:

Re: HOWTO: DIY IBus iDevice dock - including MFSW + track in

Post by srhutch » Sat Aug 24, 2013 10:19 am

I know its not finished but :bow:

Im guessing the car looks for the cd changer on start up, so presume you cant switch between the two during a journey.
Image

User avatar
inkey$
Lifer
Lifer
Posts: 10475
Joined: Sun Mar 21, 2010 9:48 pm
Location: Sevenoaks & Suffolk
Contact:

Re: HOWTO: DIY IBus iDevice dock - including MFSW + track in

Post by inkey$ » Sat Aug 24, 2013 3:28 pm

srhutch wrote:I know its not finished but :bow:
+1 Great work so far.
Inkey$ aka Customer #1 ;)
Current: Project Audi A2 1.4SE
Previously: Z3R 2.8 • E46 330i • Z4R 3.0 • Z4///MC • E90 335i • Z4///MR • Z3///MC 'Breadvan' • Z3R 2.8 • E30 325i R • Z4C • Z4R 3.0

User avatar
sk93
Lifer
Lifer
Posts: 3970
Joined: Mon Oct 19, 2009 9:20 pm
Location: Nottingham
Contact:

Re: HOWTO: DIY IBus iDevice dock - including MFSW + track in

Post by sk93 » Sat Sep 28, 2013 9:46 am

Ok - big update on this :)


I've now settled on using a Raspberry pi (called RPI from now on), as the micro Fez just wasn't working well with the iBus.

What I've discovered:
  • You can switch the cd changer on or off the IBus at any time. When you press the mode button, the radio sends a request to see if the cd changer is on the IBus, and if it is, it shows up as an option you can switch too on the radio. Because of this, you can switch between the changer and the RPI on the fly as it were :thumbsup:
  • The RPI will take about 3 seconds to "go live" when turning on the car. This is the fastest I can get it to boot. Not instant, but not really any longer than it takes the cd changer to "check cd"
  • Its very possible to implement phone control - so you can answer calls using the MFSW buttons - need to install a mic and hook it up to the iphone connector, but it's not impossible!
Where I'm at:
  • Got the RPI to listen on the iBUS and monitor all messages perfectly
  • Got the RPI to send messages to the radio - I can display almost any text I want on the radio screen!
  • Got the device working perfectly for playing music STORED ON THE RPI to the radio
  • Got the RPI to listen specifically for the play/pause/skip buttons on the radio and MFSW controls and react accordingly

What I want to get working next:
  • Stream audio from the iDevice to the radio - got it working via airplay, but that's not what I want!
  • Control the iDevice from the RPI depending on the IBUS messages it receives
To be honest, I'm pretty close with this now - it's basically just the controlling of the iDevice that's left to do, and that's all well documented.



On a side note, I've discovered how to open / close the roof via the IBus - and have got the RPI to open close it from the console.
I also believe I've discovered the messages sent to the iBus from the keyfob when locking / unlocking.. so I reckon it won't be long until I've managed to replicate the functionality of the GapTech module - all for a fraction of the cost :thumbsup:



So.. to clarify, I currently have a device in my car that will play music stored on a USB device, through the car stereo system, that is controllable from the radio and MFSW controls.

:driving:
:zzzz:

User avatar
danmiddle2
Member
Member
Posts: 880
Joined: Mon Apr 01, 2013 10:01 am

Re: HOWTO: DIY IBus iDevice dock - including MFSW + track in

Post by danmiddle2 » Sat Sep 28, 2013 10:46 am

Just caught up on this - great work and an interesting project.

I am planning on connecting my integrated Android into the iBus (when I have everything else sorted, that is). I tried to find an iBus to Bluetooth connector, but none seem to be available.... so I am making one instead :D .

I would be interested in any details you have on controlling the roof / lights etc (or anything else for that matter). I already have a gaptech, but it would be cool (albeit largely pointless) if I could open / close the roof via SMS (I could send an SMS from my phone to the integrated phablet and close the roof that way!)

I would like the Android to display information from the radio too... like the OE screen would have. I already have the track information on the radio covered as I am using Bluetooth audio streaming.

Out of curiousity - why are you going with the RPi over the Arduino? I already have an Arduino for motor operation on my project... but was planning to get the iBus talking directly to Android.

All the best,

Dan

User avatar
sk93
Lifer
Lifer
Posts: 3970
Joined: Mon Oct 19, 2009 9:20 pm
Location: Nottingham
Contact:

Re: HOWTO: DIY IBus iDevice dock - including MFSW + track in

Post by sk93 » Sat Sep 28, 2013 10:54 am

the reason I went RPI over Arduino was simply the fact that my Arduino still hasn't turned up despite being ordered a month ago from Amazon :/
:zzzz:

User avatar
danmiddle2
Member
Member
Posts: 880
Joined: Mon Apr 01, 2013 10:01 am

Re: HOWTO: DIY IBus iDevice dock - including MFSW + track in

Post by danmiddle2 » Sat Sep 28, 2013 11:05 am

sk93 wrote:the reason I went RPI over Arduino was simply the fact that my Arduino still hasn't turned up despite being ordered a month ago from Amazon :/
I've got a spare uno kicking about if you want to have a play with one? PM me your address and I'll chuck it in the post.

User avatar
sk93
Lifer
Lifer
Posts: 3970
Joined: Mon Oct 19, 2009 9:20 pm
Location: Nottingham
Contact:

Re: HOWTO: DIY IBus iDevice dock - including MFSW + track in

Post by sk93 » Sat Sep 28, 2013 2:36 pm

Quick youtube of where I'm at at the mo ;)

:zzzz:

User avatar
sk93
Lifer
Lifer
Posts: 3970
Joined: Mon Oct 19, 2009 9:20 pm
Location: Nottingham
Contact:

Re: HOWTO: DIY IBus iDevice dock - including MFSW + track in

Post by sk93 » Fri Nov 08, 2013 10:04 pm

I've done a massive amount on this now :thumbsup:

Quick list of things that are done, in and working:
  • Raspberry Pi is fitted in a small box just behind the CD Changer, behind the back wall carpet
  • Creative Labs Play USB Soundcard plugged into Pi and wired up to head unit (using CD changer pins, not AUX)
  • The Pi acts as a secure WiFi hotspot which also supports AirPlay
  • The Pi also has a bluetooth dongle that acts as a audio reciever
  • Pi is hooked into microphone positioned between the rev and speedometer
  • The Pi boots up in just over 6 seconds and starts automatically when the car comes out of "sleep mode" (same as the in-car cigarette lighter, cd changer, and other devices)
  • The Pi is connected to the IBus continuously when powered up
  • The Pi listens to all IBus traffic and can log it to the SD card if required
  • The Pi can play music stored on its internal SD card or any connected USB drive, through the car's head unit
  • The Pi responds to user input either on the head unit, the MFSW controls, or voice commands
  • The CD Changers connector is now plugged into the Pi box and a new custom built connector goes from the Pi box back to the CD changer
  • CD Changer IBus connectivity is controlled by the Pi
  • iPhone harness all soldered up, wrapped and fed from Pi box, through the firewall and down to the ashtray
  • iPhone charges from Pi harness
  • The Pi can communicate with the iPhone and play / pause / skip etc.
  • iPhone does NOT go into "accessory" mode, so can still be used whilst connected to the Pi!

So.. a little more information :)

As above, the Pi now sits in a little black box from Maplins. I've mounted the Pi and a 12 volt, 6 port mini USB hub inside. Plugged into the hub we have the IBus interface device, a WiFi dongle, a Bluetooth dongle, the Creative Labs USB soundcard, a small USB extension cable and the Pi itself (for power)

On the side of the box, I've mounted a couple of connectors.These are as follows:

connector 1 (computer-style ATX power connector):
  • +12v Power
  • Ground
  • IBus
connector 2 (Female CD changer socket - RS Electronics!)
connects to the Carver cd changer power plug
  • +12v Power (not connected)
  • Ground (not connected)
  • IBus IN
  • IBus OUT
connector 3 (Male iPhone connector)
used so I can easily disconnect and remove the Pi if needs be

connector 4 (USB female connector)
used so I can connect external drives to the Pi

connector 5 (dual 3.5mm jack sockets)
  • First socket is for audio out
  • Second socket is for audio in (from the mic)
I decided to go for connectors rather than hardwiring, as I was having to take the Pi back inside the house and do a lot of development with it, so it was much easier to just unplug connectors, than have to have a dodgy "chocolate block" terminal connector I would be forever doing and undoing.
Plus, it looks a lot neater


So - how does it all work?

Well, as soon as I unlock the car (or put the key in the ignition if it's been sat unlocked for a while), the USB hub is provided with power and thus provides power to the connected devices - which includes the Pi.
the Pi itself then starts up and after about six seconds, it's up and running. If the headunit is turned on - it briefly displays the message "Ding Pi is done!" on the head unit display.

Once the Pi is up, it begins listening to all IBus traffic (and if in debug mode, logs it all to a text file).

The CD changer is still working and the headunit can play music from it just as before (note: the Pi doesn't even need to be powered on for the changer to function).

Because the headunit is nice, when someone presses the "MODE" button, it sends a quick message to the CD changer to ask if it's available.
Because the CD changer is still connected, the Pi doesn't respond and instead allows the CD changer to do so.
When the headunit is switched to CD Changer mode, it actually sends another message to the changer telling it to prepare to play.

It's at this point the Pi starts to pay more attention to the IBUS. Specifically, it's listening for the user to press and hold the R/T MFSW control button or the "6" button on the headunit for at least one second. (I chose the R/T button, as I don't have OEM bluetooth. I chose the "6" button as it had to be a button the headunit would announce over the IBus. I chose one second as nobody accidentally presses either button for a whole second ;))

When the user does press either of these buttons, the PI then sends a message to the CD Changer telling it to pause playing (exactly what the head unit does when you switch away from the CD changer).
After that, it then turns on the mini relay, cutting the CD changers connection to the IBus.
With the CD changer out of the way, it then checks to see if the iPhone is connected and if it is, tells it to start playing.
The audio coming back from the iPhone is then piped out to the soundblaster card, which then pipes it out via the 3.5mm jack in the side of the case.
This jack is connected to the cd changer pins on the back of the headunit - pins that are not used by the DSP system.
Once playing has commenced, it then reads the playing track information from the iPhone and displays it (scrolling text if needed) on the headunit.

If no iPhone is connected, it checks to see if an external drive has been connected, and plays music from that.
If no drive is connected, it checks for music on the SD card, and if found, plays music from that.
Finally, if no music is found anywhere, it displays "The Pi is a Lie" on the head unit display for two seconds, before reconnecting the CD changer's IBus connector and then telling it to start playing again.

This is all in, working and a whole lot of awesome :thumbsup:


But that's not all.. Whilst making all the above work, I kept finding new things I could add.
The first of which was BlueTooth.
sometimes, I can't be arsed to connect the phone to the dock - sometimes I want to listen to music on the girlfriend's Nokia.
To achieve that, I simply added a cheap bluetooth connector to the USB hub and configured the Pi to make it work as an "audio receiver".
I then coded the pi to check and play audio from any connected bluetooth device as a priority over the iPhone cradle, usb or sd cards.
If a device is connected whilst the Pi is already playing audio, a simple press of the "next track" button on the headunit or wheel forces
the Pi to recheck for a bluetooth device and prioritise it!
Simply toasty.

Next I added a wifi connector to the hub. this is mainly used so I can SSH onto the Pi whilst it's in the car and debug / work on it in a "live" environment (with all the devices up and running and the IBus connected).
However, a colleague pointed me to a blog where someone had used the exact same wifi connector on a Pi and got it to work as an "airplay" speaker!
A quick copy+paste of their code with a bit of editing to get it to work with my code, and now I have AirPlay support!

So, the final list of music-playing capabilities of the "PiSk" (yeah, that's what I'm calling it!), in the order in which the Pi priorities them, is as follows:
  • 1: Bluetooth
  • 2: AirPlay
  • 3: iPhone dock
  • 4: External USB drive
  • 5: Internal SD card

But wait -that's not all!

The Pi also has voice recognition abilities! Yep - you can control the PiSK with just your voice.
To get it to work, you have to say "pi, <command>" and the available commands are "play", "pause","next", "last","on" & "off" (so far).
This all works currently, by using Google's Voice API.
That's all well and good, but the downside is that it needs an internet connection to work (something that escaped my mind when I coded it.. :headbang: ).

Not to fear tho, as we already have a Wifi connector, we can actually tether the PiSK to our phone and use it's data connection!
currently, I believe this to ONLY be available on jailbroken iPhones (other phones probably have it - I know the Nokia lumia's have it.. just not iPhones :/)

Still, this can be got around by getting a cheap 3g dongle and using that for the data connection.
Or, you can just simply not use it :P




So what's next?

Answering phone calls is the next challenge. I expect to get this to work via bluetooth, but I've not cracked it yet...
Once I've got that, I'd look into reading text messages and the like - maybe even be able to reply using the voice recognition.. who knows.


Anyways - this is quite a long post already.
But I've achieved it. :thumbsup: :evil: 8)

It took a fook load of messing about to make it all work, I also blew the dock connector on my iPhone by getting the pins wrong once (£$6 to fix, so not as bad as I had initially feared!)
But I'm well pleased with the whole thing.

My next task is to make the code more "elegant". there are times where it gets confused about things. I think there's a bug in my code that tracks the status of the headunit.
I also want to try and speed everything up. It's already fast enough to use, but I'd be much happier knowing I got it going as fast and fluidly as possible.

finally, I need to replace the box that cases the whole thing, as when gluing in the sockets, I managed to melt it and it looks horrid (not that you'll see it under the carpet.. but I expect quite a few people may be interested in seeing it at meets and the like, so I'd like to make it look "pro" :rofl:

Happy days!

If I get the chance, I'll take it out of the car and take some quick snaps.
I'll also try and get another vid of the whole thing up and running.
:zzzz:

User avatar
inkey$
Lifer
Lifer
Posts: 10475
Joined: Sun Mar 21, 2010 9:48 pm
Location: Sevenoaks & Suffolk
Contact:

Re: HOWTO: DIY IBus iDevice dock - including MFSW + track in

Post by inkey$ » Fri Nov 08, 2013 10:18 pm

You. Are. A. Magician. :)
The PiSk solutions sounds amazing. Cant wait to hear and see more!
Current: Project Audi A2 1.4SE
Previously: Z3R 2.8 • E46 330i • Z4R 3.0 • Z4///MC • E90 335i • Z4///MR • Z3///MC 'Breadvan' • Z3R 2.8 • E30 325i R • Z4C • Z4R 3.0

User avatar
LukeMace
Senior Member
Senior Member
Posts: 1918
Joined: Wed Apr 18, 2012 7:40 pm
Location: Northampton

Re: HOWTO: DIY IBus iDevice dock - including MFSW + track in

Post by LukeMace » Fri Nov 08, 2013 11:45 pm

Brilliant, just brilliant! Huge well done on achieving that! I'd love to be able to be able to code like that but sadly at the min do not he the time (or potentially patience!) to learn!

VIDEO IS NEEDED!!!!! :thumbsup:
3.0, Quad Conversion, 19" CSLs, Bucket Seats, Big Brake Conversion, Lowered 40mm, AE and Clear Hockeys etc...
CLICK HERE FOR THE BUILD THREAD
Image

Post Reply