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