Tuesday, March 18, 2014

I/Kbus interface options for Arduino

There is quite a bit of information and readimade cables for interfacing a PC with the BMW Ibus PC for diagnostic purposes.  What if one wanted to connect an Arduino to the bus?  The PC serial port runs at 7 volts and the Arduino runs at 5 volts.  So right there we have a problem.  It also worth noting that the ibus voltage can be near 12V, at idle, which would most definitely fry the Arduino. 

During my testing and experimentation I’ve used several different options for connecting an Arduino to the ibus.  Thought I would share what I have learned in hopes of saving someone else some time and trouble.  This blog entry provide 3 interface options for an Arduino or other serial device to the BMW Ibus or Kbus.  This should  also work for interfacing with the TX1 (Diagnostic bus) and TX2 bus (ISO OBDII protocol) as they all use the same protocol.  9600 baud 8E1  If using an Arduino define with this statement:  xxx.begin(9600, SERIAL_8E1);

The three different options I’ve attached have some advantages and disadvantages.  We will go through them in the same order I discovered and used them.

ibus simple:


This circuit is similar to how an ELM clone connects to the OBDII ISO line.   It has the benefit of beings a fairly simple circuit to build and only requires some readily available and inexpensive resistors and transistors.  Great.  Then why do anything else?  There isn’t much separation between the 12V Kbus and the Arduino.  If a component fails or is bridged it is likely that 12V will get to the Arduino pins.  But this circuit does work and I have used it for quite a while.  I really only moved to the next version to provide isolation to reduce some audio noise in one of my projects.

ibus Optocoupler:




This is similar to the ibus simple but adds optocouplers in place of 2 of the transistors.  This isolates the bus from the Arduino ensuring there are no over voltage accidents.  Only downside to this circuit, if there is one, is that it requires using an optocoupler which not everyone might have handy.  But optocouplers are inexpensive and a great addition to your electronics supplies.  I used this circuit with great success for a long period of time.  I only moved to the next circuit as I had been looking for a way to put my circuit to sleep  and wake it with bus activity with fewer components.  (I had built a latching circuit but it was very complicated and took a long time to solder up)

ibus linbus:

This is by far my favorite method for connecting to the i/kbus.  But depending on what type of circuit is being made one of the other circuits might make more sense.  This circuit uses a linbus transceiver to translate the bus pulses into a serial data stream for the Arduino.  While the linbus data stream is not the same, the voltage structure is.  Therefore the transceiver can translate the bus pulses into a serial stream safe for the Arduino.  Transceiver chips are also used in some BMW OEM equipment. although different ones are used but they do not appear to be produced anymore.

The chip I selected, MCP2025, is also sold with a built in voltage regulator and has a sleep mode.  This allows the Arduino to put the transceiver into sleep mode reducing power drain with the car is off and kbus activity wakes the transceiver up.  It has some other cool features that you can read about in its spec sheet.  Pretty slick and all for about $1.50 each. 

9 comments:

  1. Nice, this is what I was looking for :) Do you have maybe some simple code that will receive data from chip and print them in the terminal?

    ReplyDelete
  2. Glad it was helpful. I spent a lot of time sorting through circuits trying to figure it out. Hoping to save others some time. I'm sure I can post some arduino dode. Not sure about "simple" though :-)

    ReplyDelete
  3. I want to understand, with this scheme, and 'can be connected to the stereo bmw e46, with BUS connection, manage an mp3 or an android phone? Thanks immensely

    lenovopieroit@gmail.com

    ReplyDelete
    Replies
    1. In the E46 the ibus has the Steering wheel button (skip up down etc.) and the audio is sent on it's own cable. Much like on the earlier ipods. Or in otherwords. The E46 factory stereo knows nothing of MP3's. It only accepts analog audio in.

      Delete
  4. My E39 has several steering wheel buttons and one of them is unused on some models (like in my case). So my idea is to make it possible to use this button to switch something else in the car. Many functions are turned on/off by momentary switches, like the A/C, PDC, ASC, etc. Now I thought I might build a module that listens on the iBus until this specific button is pressed and then activates a transistor. What do you think? How can I make this happen?

    ReplyDelete
    Replies
    1. Sure. If the button broadcasts a message over the bus then it is no problem. My homemade ipod adapter does just this. I use the Phone and RT buttons to enter and exit menus. Pretty sure there is a link to my google drive in one of the posts. I'd suggest starting with the ipod code and altering it to your needs.

      Delete
  5. Hi Thaniel,
    Im trying to build a device that translates the ibus to the arduino R3 UNO, so that i can change songs on my phone over bluetooth.

    Im currently building a device i found on a site called curious ninja or something, with a TH3122.4 chip and some resistors and stuff.
    My biggest problem is that i dont know much about writing sketches, so i dont know how to make it translate the ibus to the arduino.

    Do you have any hints to help me getting started? :-)

    Regards
    Fredrik

    ReplyDelete
    Replies
    1. Hej Fredrik,

      On post one in this blog
      https://e46canbus.blogspot.com/2014/01/over-year-ago-while-temporarily-living.html

      is a link to a google drive that has a sketch I wrote to interface with the ibus using an arduino and capture the button presses on the steering wheel for just this purpose. Mine controls an ipod with a wire but it is a good starting opoint.

      Delete
    2. Hi Thaniel. Sorry for my English. I'm using your scheme with MCP2025 and i can recive messages only. I spend a lot of time to send anything in I-bus but nothing works. Can you write a little sketch with sending simple message(etc. Vol +) after arduino recive message from pressed r/t button. Thx

      Delete