E81/E87 Hands Free Arduino/KCANBus/BT solution

Check here to find out more about ICE, Satellite Navigation, Telecoms etc.

Moderators: babybmwadmin, Producethis, marco_polo, Lambster, Rich196

DaIceMan
Junior Member
Junior Member
Posts: 27
Joined: Thu Dec 27, 2018 5:27 pm

E81/E87 Hands Free Arduino/KCANBus/BT solution

Post by DaIceMan »

Hi all,
As I have a Business radio model without BT support on my 2008 E81 I decided to go all the way and add my own support for it using an Arduino Pro Mini, an MCP2515 CANbus module and a BT module to make use of the steering command buttons which you wouldn't have with the basic BT modules you can find anywhere. I tapped into the KCAN bus and power from behind the radio and routed the audio output to the AUX input pins there as well. Here is the module assembly:
BT Module Top
BT Module Top
Arduino-CAN-BT-top-s.jpg (142.07 KiB) Viewed 4150 times
BT Module Bottom with Arduino Pro and MCP2515 module
BT Module Bottom with Arduino Pro and MCP2515 module
Arduino-CAN-BT-s.jpg (65.67 KiB) Viewed 1669 times
This is the link of the BT module:
https://www.aliexpress.com/item/5V-Wifi ... 33834.html
You can find alternatives to this model, but this is the only I found with INPUT and OUTPUT apart from the USB and MicroSD card reader (the most interesting is the USB port). This means you can route the AUX input to this module and the output to the back of the radio. You can then select the operation mode using the steering "Voice" button and switch from BT to USB to AUX Input in a loop. Unfortunately if you are in USB or AUX input mode on the module the BT is disconnected from the phone, but you can quickly cycle back using the steering button. The next/prev track is the up/down button on the steering wheel and long pressing it increases/decreases the BT volume which is handy as this module has a very high output.

As you can see I stuck the Arduino Pro Mini and MCP module on the bottom side of the BT module using thick double sided tape and wired everything. The 5 buttons (Mode Play Next Prev EQ) have 2 redundant connections each, just use a tester to find the ground and the next pin is the signal pin to be wired to the Digital Input pins of the Arduino (9,8,7,6,5). The EQ pin at the moment is not used but I wired it anyhow in case I decide to make use of it through software as it only works when listening to the MP3 files on the USB port. Wire the SPI pins as indicated following the labels (standard SPI wiring). In the above photo I have my FTDI programing USB-2-serial interface plugged in. I soldered the condenser mic after having measured the length needed to the 2 MIC pins. I tucked it under the black plastic cover between the ashtray and HU block. Alternatively you can route it all the way to the side, up the front glass side and back to the top center lighting block where it is originally housed. Quality was good enough where I put it so I decided to leave it there.

Here are a few pics of my installed setup (still have to add some foam to keep the board in place):
HU with removed climate control panel showing install location.
HU with removed climate control panel showing install location.
20190210_193613s.jpg (101.98 KiB) Viewed 1628 times
AUX plug C-Connector removed from Quadlock assy.
AUX plug C-Connector removed from Quadlock assy.
AUX-IN-s.jpg (94.11 KiB) Viewed 4150 times
The above shows the removed C plug of the quadlock block (the bottom right connector viewing from the back). Mine only had these 3 pins connected which come from the AUX mini jack plug under the arm rest above the 12V cigarette power port. This is an option and not all E81/87s have it. However ALL Business radios have the AUX input, you just need to wire them and enable the AUX input through coding (use NCSExpert for ex.). The hardest part will be to locate the exact pins (search on RS, Farnell or Digikey) which if you do not have the option you will certainly need to complete the wiring. You can find the pinout of the quadlock on the usual pinouts site. I wired the BT power to the +12V line on the quadlock. This is powered until the car goes into sleep mode. Please be careful if you want to tap in here when removing the pin from the quadlock as it most likely will be still powered so avoid any shorts (best disconnect negative from battery if not comfortable). I am not very happy about this delayed +12V disconnect not because of the insignificant power it absorbs (30mAmps) but because if you turn off the car and stay near it your phone will still be connected via BT and you won't be able to answer your phone (or even not hear it) if you don't disable BT first which is annoying. So I will add a transistor or FET which is driven by the radio Pilot wire (black wire on quandlock A block) which pilots the switch and powers the BT module block. This way when you turn off your radio your BT will be OFF. In reality the radio amplfier is never really off as if you have parking sensors these trigger the tone through your radio amplifier even if it is off (more like stand-by). The whole assembly uses from 30 to 60mAmps when streaming BT music and using handsfree. It reaches around 90mAmps if you leave a USB key connected (depending on the USB key size and model). This is under the 100mAmp limit of the 78L05 regulator on the Arduino pro Mini so everything is powered from that (+12V input goes to the RAW pin and MCP and BT module are powered from the VCC pin). I added a 20Ohm resistor in series to the 12V to limit the voltage drop on the regulator so it does not dissipate too much heat. This also provides an additional safety headroom for any voltage peaks. The 78L05 has thermal shutdown if it overheats and overcurrent protection in any case. An in series 250mA slow fuse can be added in series to the +12V.
A big thanks to Trevor Cook (loopbunny.co.uk) avoiding me the hassle of debugging the KCAN bus and to mr-fix (mr-fix.pl) where I found the BT module model I ordered from aliexpress with button support.

Arduino Code:
KCAN_BT_Handsfree_26-12-2020.zip
Updated code to avoid callback instead of play/stop song
(3.87 KiB) Downloaded 82 times
Here is a short video of the installed setup:

Follow up:
Last edited by DaIceMan on Sat Dec 26, 2020 5:34 pm, edited 7 times in total.
User avatar
Nottsknots
Too Much Time To Waste Member
Too Much Time To Waste Member
Posts: 3128
Joined: Sat Jun 29, 2013 8:35 pm

Re: E81/E87 Hands Free Arduino/KCANBus/BT solution

Post by Nottsknots »

Great work there. Those modules are getting so small these days - I love the Arduino minis, so much scope for mischief :D

I’m pretty sure there will be a power line thats not subject to the delay; I’ll have a poke around the wiring diagrams later - might be easier than faffing with a FET.
E87 118d, stock, plus PDC control unit drain, Parrot, debadged, Mothercare baby shades (but no babies), and occassionally a good layer of wax. Instantly forgettable, and thats the way I like it.

Gone (East), but apparently not forgotten.
boine
Junior Member
Junior Member
Posts: 5
Joined: Sun Jul 19, 2020 10:03 pm

Re: E81/E87 Hands Free Arduino/KCANBus/BT solution

Post by boine »

Hey guys!

Great project! Was searching for exactly this, now lets have a go!
But a beginner here, with several newbie questions....

First, any solution to the delayed power supply?
Wouldnt it be possible to tap some juice for this project straight from the radio pilot wire?
Or from the cigarette lighter plug? (Perhaps that got a delay too... )

I havent dismantled the car yet, but how does the tapping of the KCAN bus work?
I just find the wires on the harness back of the stereo and tap into them?
No need for any dedicated "free" point somewheres on the bus?

Finally, Im a total noob with Arduino programming, but I got the hardware, and peeked into the .ino file.
Can I use it "as is", or do do I need to tweak any of those parameters/filters/masks/delays?

Help highly appreciated :) Thanks a lot for all efforts!
DaIceMan
Junior Member
Junior Member
Posts: 27
Joined: Thu Dec 27, 2018 5:27 pm

Re: E81/E87 Hands Free Arduino/KCANBus/BT solution

Post by DaIceMan »

boine wrote: Mon Jul 20, 2020 10:14 am First, any solution to the delayed power supply?
Wouldnt it be possible to tap some juice for this project straight from the radio pilot wire?
Or from the cigarette lighter plug? (Perhaps that got a delay too... )
The pilot wire supports usually max 100mA - it is not usually for direct driving devices but just a signal to pilot a transistor or similar high impedance device. That said, due to the low current absorption of this setup it could be viable however I do not recommend it. Better add a simple NPN transistor with a resistor as pilot driver, you can find how to on the net there are several simple schematics. Currently I still have mine wired directly to the +12V bus - I just disable my phone's BT if I'm hanging around the car (got used to it!).
boine wrote: Mon Jul 20, 2020 10:14 am I havent dismantled the car yet, but how does the tapping of the KCAN bus work?
I just find the wires on the harness back of the stereo and tap into them?
No need for any dedicated "free" point somewheres on the bus?
As stated in the description just piggy back onto the 2 kCAN wires with a max 20cm long twisted cable. The shorter the better to avoid signal reflections (CANbus is always terminated at the 2 ends and you are tapping into "after" the end).

The file is ready to use unless you modify any digital pinout which you don't need to. The button delays worked fine for me until now - just keep in mind that the play / answer button is *very* sensitive so the pressing must be very fast or it will go ahead and dial the last called number instead (as it takes it as a double click). That's the only part I might modify, to add a debounce/delay for the double play/answer function of the button as it's too sensistive atm.
Last edited by DaIceMan on Sat Jan 02, 2021 5:14 pm, edited 1 time in total.
boine
Junior Member
Junior Member
Posts: 5
Joined: Sun Jul 19, 2020 10:03 pm

Re: E81/E87 Hands Free Arduino/KCANBus/BT solution

Post by boine »

Thanks a lot for your quick answer!
I will go ahead and try this out, will report if I succeed :)
Thanks!
boine
Junior Member
Junior Member
Posts: 5
Joined: Sun Jul 19, 2020 10:03 pm

Re: E81/E87 Hands Free Arduino/KCANBus/BT solution

Post by boine »

"The button delays worked fine for me until now - just keep in mind that the play / answer button is *very* sensitive so the pressing must be very fast or it will go ahead and dial the last called number instead (as it takes it as a double click). That's the only part I might modify, to add a debounce/delay for the double play/answer function of the button as it's too sensistive atm."

Is there a simple fix in the coding to change this behaviour?
A total noob with both Arduino and programming, but if there is an easy fix code-wise, I might change it before fitting into my car :)
DaIceMan
Junior Member
Junior Member
Posts: 27
Joined: Thu Dec 27, 2018 5:27 pm

Re: E81/E87 Hands Free Arduino/KCANBus/BT solution

Post by DaIceMan »

No there is no simple fix as I have to implement a debounce routine which checks if you pressed that button once or twice within a certain time. It's not a complex thing (it involves setting a couple of flags and a loop counter) but I need to get around to test it and have no time at hand this moment (it's not really a priority). I implemented a similar routine for the Next/Prev and MM Vol up/down double function: the up down arrows select next or prev track but ALSO can increase/decrease the BT output of the BT module (I will actually extend this to work also for the play/stop button). This was more important as the Phone Multimedia audio is much higher than the hands free so you need to decrease it significantly (40%) to have them leveled out of the car radio.
boine
Junior Member
Junior Member
Posts: 5
Joined: Sun Jul 19, 2020 10:03 pm

Re: E81/E87 Hands Free Arduino/KCANBus/BT solution

Post by boine »

Hi again guys!
Finally build time on this side!
Though one of the pictures in instructions above is missing.
Any chance for a repost of "BT Module Bottom with Arduino Pro and MCP2515 module"...
Will keep you posted on my progress :)
DaIceMan
Junior Member
Junior Member
Posts: 27
Joined: Thu Dec 27, 2018 5:27 pm

Re: E81/E87 Hands Free Arduino/KCANBus/BT solution

Post by DaIceMan »

I reuploaded the pic of the assembly in the original post, it displays now, don't know what happened, probably got lost or corrupted as it was displaying fine some time ago.
I will repost it here for redundancy with an additional pic:
Arduino-CAN-BT-s2.jpg
Arduino-CAN-BT-s2.jpg (124.57 KiB) Viewed 1668 times
Arduino-CAN-BT-s.jpg
Arduino-CAN-BT-s.jpg (65.67 KiB) Viewed 1668 times
Arduino-CAN-BT-top-s.jpg
Arduino-CAN-BT-top-s.jpg (142.08 KiB) Viewed 1668 times

I will also test a new version of the software which resolves the "play" issue if pressed too long triggering the last call. WIth this version you can keep the button pressed as long as you want but it won't trigger a new call, to do that you have to double tap.
boine
Junior Member
Junior Member
Posts: 5
Joined: Sun Jul 19, 2020 10:03 pm

Re: E81/E87 Hands Free Arduino/KCANBus/BT solution

Post by boine »

Thank you very much!!!
Will keep an eye out for any software updates ahead :)
DaIceMan
Junior Member
Junior Member
Posts: 27
Joined: Thu Dec 27, 2018 5:27 pm

Re: E81/E87 Hands Free Arduino/KCANBus/BT solution

Post by DaIceMan »

Here's the latest video update:

Here's the arduino code:
KCAN_BT_Handsfree_26-12-2020.zip
Fix to avoid double click to trigger callback of last dialled number!
(3.87 KiB) Downloaded 46 times
This fixes the "double click/press" to avoid calling back the last dialed number. WIth the old version if you pressed for more than briefly the "phone" button to start a song, it would trigger 2 (or more) pulses towards the BT module which it would interpret as "callback". Now this no longer happens.
VPCAPTAIN
Junior Member
Junior Member
Posts: 11
Joined: Fri Feb 26, 2021 11:12 pm
Location: Glasgow

Re: E81/E87 Hands Free Arduino/KCANBus/BT solution

Post by VPCAPTAIN »

Hi DaIceMan fantastic little write up on how to upgrade to Bluetooth and USB functionality. I’ve just bought an 2009 E87LCI 1.6i and have the same BMW Business CD radio with aux input but no usb or Bluetooth and although I’ve looked at the upgrade options to get USB and or Bluetooth the cost is extortionate. Enter the multitude of Bluetooth streaming modules on fleabay. Then I spotted your post. Just a quick question I’ve some experience in Arduino’s pro micros etc and haven’t used the Arduino Pro mini. Would I be right in thinking the mini needs the extra board ( shown vertically attached to the 6 pins on the mini ? ) to communicate via USB and could the code be adapted to other arduinos like the pro micro which has onboard usb support ?
Will no doubt have several more questions when I start constructing as I’ve no experience of CANBUS protocols etc thanks
DaIceMan
Junior Member
Junior Member
Posts: 27
Joined: Thu Dec 27, 2018 5:27 pm

Re: E81/E87 Hands Free Arduino/KCANBus/BT solution

Post by DaIceMan »

Hi, yes the extra board you see is a usb to serial converter which the arduino mini does not have (hence why mini). If you use the nano or the uno of course you don't need it as already integrated on the pcb - you could use the nano for ex instead (even if longer because of this and would not fit in the footprint of the bluetooth module). It's up to you - I chose the pro mini as very compact and could all fit under the BT module pcb with double sided tape - but it's not obligatory. Just match the pinout as specified in the source code for buttons and MCP SPI interface and power input and output from the onboard 5V regulator and it will work just fine.
VPCAPTAIN
Junior Member
Junior Member
Posts: 11
Joined: Fri Feb 26, 2021 11:12 pm
Location: Glasgow

Re: E81/E87 Hands Free Arduino/KCANBus/BT solution

Post by VPCAPTAIN »

excellent thanks I’ve just received the MCP2515 module but will have to wait for the same Bluetooth input output board as the one I had did not have input and output. Will let you know how I get on when I receive everything to test. Best Regards
DaIceMan
Junior Member
Junior Member
Posts: 27
Joined: Thu Dec 27, 2018 5:27 pm

Re: E81/E87 Hands Free Arduino/KCANBus/BT solution

Post by DaIceMan »

Just FYI the input is not mandatory. You just need the buttons on the bt module to control your phone.
Post Reply

Return to “In Car Entertainment, Communication & Sat Nav”