Struggling with my BMW ibus project

Hello community,

i'm a absolute beginner /w arduino coding and i want to realise a project.

I had installed in my E46 BMW a nexus 7 tablet. At the end i wanted to create a interface between the steering wheel controls (vol up/down etc.) to control my android tablet.

So far i was able to create /w a ATmega32U4 (https://www.amazon.de/gp/product/B01D0OI90U) a HID for the Tablet to control power etc. over software /w switches on a board.

For ibus communiation (read only) i ordered a MCP2025.

I was sucessfuly able to read data, but not to handle it.

Here my dirty crude code so far:

// total wasted time: string time = too much;
// Made for BMW E46

int incomingByte;
int eventid = 0;

void setup(){  
  Serial.begin(9600);
  
  // setup I-Bus message bytes
  //                       from,lenth,dest, ............ ,chksm
  byte KEY_IN [7]        = {0x44,0x05,0xBF,0x74,0x04,0x00,0x8E}; // Ignition key in
  byte KEY_OUT [7]       = {0x44,0x05,0xBF,0x74,0x00,0xFF,0x75}; // Ignition key out
  
  byte IGNITION_OFF [6]  = {0x80,0x04,0xBF,0x11,0x00,0x2A};      // Ignition Off
  byte IGNITION_POS1 [6] = {0x80,0x04,0xBF,0x11,0x01,0x2B};      // Ignition Acc position - POS1
  byte IGNITION_POS2 [6] = {0x80,0x04,0xBF,0x11,0x03,0x29};      // Ignition On position - POS2
  
  byte bMflVolUp [6]     = {0x50,0x04,0x68,0x32,0x11,0x1F};      // steering wheel volume up
  byte bMflVolDn [6]     = {0x50,0x04,0x68,0x32,0x10,0x1E};      // steering wheel volume down
  byte bMflTrkPrv [6]    = {0x50,0x04,0x68,0x3B,0x08,0x0F};      // steering wheel previous track
  byte bMflTrkNxt [6]    = {0x50,0x04,0x68,0x3B,0x01,0x06};      // steering wheel next track
  byte bMflRt [6]        = {0x50,0x03,0xC8,0x01,0x9A};           // steering wheel R/T
  byte bMflVoice [6]     = {0x50,0x03,0xC8,0x01,0x9A};           // steering wheel Voice need to read out!
}


void loop(){
  if (Serial.available()) {
    incomingByte = Serial.read();
    //Serial.print(incomingByte, HEX);
    switch (incomingByte) {
       case 0x1F: // p for vol up
            Serial.println("Sending vol up.");
            delay(100);
            break;
        case 0x1E: // n for vol down
            Serial.println("Sending vol down.");
            delay(100);
            break;
        case 0x0F: // n for trk down
            Serial.println("Sending trk down.");
            delay(100);
            break;
        case 0x06: // n for trk up
            Serial.println("Sending trk up.");
            delay(100);
            break;
        case 0x9A: // n for rt
            Serial.println("Sending rt.");
            delay(100);
            break;
       // case 0x1E: // n for vol down
         //   Serial.println("Sending vol down.");
          //  delay(100);
           // break;
    }
  }  
}

void processData()
{ 
  length = ibusData[ibusRow][1];
  if (length == 0) {
    Serial.println("Length Zero");
    return;
  }
  byte checksumByte = 0;
  for (int i = 0; i <= length; i++){
    checksumByte ^= ibusData[ibusRow][i];
  } 
  if (ibusData[ibusRow][length + 1] == checksumByte){
    for(int i = 0; i <= length + 1; i++)
    {
     Serial.print(ibusData[ibusRow][i], HEX);
      Serial.print(" ");
    }
    Serial.println();

  }
  else {
    Serial.println("Checksum Bad");

  }
}

//void fUsbHidPlayPause(){
//  Remote.play();  // send play/pause command
//  Remote.clear(); // Prevent duplicate activation
//}
  
//void fUsbHidNextTrack(){
//  Remote.next();  // send next track command
//  Remote.clear(); // Prevent duplicate activation
//}

//void fUsbHidPrevTrack(){
//   Remote.previous();  // send previous track command
//   Remote.clear();   // Prevent duplicate activation
//}

in the debug log from the serial monitor, i read some wired issues and now im afraid to test it in real usage.

Can someone help me to bring this project to a end?

I'm researching at this topics for days with no result.

i'm already read all topic here and @ google.

It would be a Christmas Wonder if it will works to me.
Optional Goal: Volumecontrol from steering wheel directly to my kenwood unit

Greetings Daniel

There is a lot of stuff in this BMW IBus Thread

...R

i had already read this thread, but i'm still unable to understand how to do/use it.

danja95:
i had already read this thread, but i'm still unable to understand how to do/use it.

If you had said so I could have saved some time.

All I know about is in that Thread.

...R

I did write an iBus library in the end. Although it's not my site, it is discussed/available here.

Ian.

ian332isport:
I did write an iBus library in the end. Although it's not my site, it is discussed/available here.

Arduino & BMW K/I-Bus Interface – Intro » Curious-Ninja – IT, Cars, and Aviation

Ian.

i cant compile the example sketch. it missing the file "Ibus.h"

sketch\IbusSerial.cpp: In member function 'void IbusSerial::sendIbusPacket()':

sketch\IbusSerial.cpp:265:3: error: 'else' without a previous 'if'

   else 

   ^

sketch\IbusSerial.cpp: In member function 'void IbusSerial::writeMessage()':

sketch\IbusSerial.cpp:702:3: error: 'else' without a previous 'if'

   else

   ^

exit status 1
Fehler beim Kompilieren für das Board Arduino Leonardo.

Hi Daniel,

Here's the latest files. I've just checked, and it compiles for a Nano.

Ian.

ibus_lib_setup_example.ino (3.7 KB)

IbusGlobals.h (30.2 KB)

IbusSerial.cpp (20.4 KB)

IbusSerial.h (4.15 KB)

RingBuffer.cpp (2.16 KB)

RingBuffer.h (1.15 KB)