Hi everyone,
I hope you are well, I have been trying to send can messages to bmw e90 car cluster using the example used in this forum: Controlling BMW E90 instrument cluster - #5 by Terraviper-5 However, my car cluser does not turn on and sometimes it gives me a symbol of red car on a lift
Can anyone explain how to even send a simple can bus message to turn the ignition on atleast, here is my code:
#include <SPI.h>
#include "mcp2515_can.h"
#define lo8(x) (uint8_t)((x)&0xff)
#define hi8(x) (uint8_t)(((x) >> 8) & 0xff)
const int SPI_CS_PIN = 10;
const int CAN_INT_PIN = 2;
mcp2515_can CAN(SPI_CS_PIN); // Set CS pin
void sendIgnitionKeyOn()
{
uint16_t canId = 0x130;
uint8_t len = 5;
uint8_t buf[8] = {0, 0, 0, 0, 0, 0, 0, 0};
buf[0] = 0x45; // Key Status / T15 ON message
buf[1] = 0x42; // Transponder Detected
buf[2] = 0x69; // Terminal Status
buf[3] = 0x8F; // Steering lock?
buf[4] = 0xE2; // Counter and Checksum
CAN.sendMsgBuf(canId, 0, len, buf);
}
void sendRPM(uint16_t rpm)
{
uint16_t tempRpm = rpm * 4;
const uint16_t canId = 0x0AA;
const uint8_t len = 8;
uint8_t buf[8] = {0x5F, 0x59, 0xFF, 0x00, 0x34, 0x0D, 0x80, 0x99};
buf[4] = lo8(tempRpm);
buf[5] = hi8(tempRpm);
CAN.sendMsgBuf(canId, 0, len, buf);
}
void sendLightsOn()
{
const uint16_t canId = 0x21A;
const uint8_t len = 3;
uint8_t buf[3] = {0x00, 0x00, 0xf7};
CAN.sendMsgBuf(canId, 0, len, buf);
}
void leftBlinkerOnInitial()
{
const uint16_t canId = 0x1F6;
const uint8_t len = 2;
uint8_t buf[2] = {0x91, 0xF2};
CAN.sendMsgBuf(canId, 0, len, buf);
}
void rightBlinkerOnInitial()
{
const uint16_t canId = 0x1F6;
const uint8_t len = 2;
uint8_t buf[2] = {0xA1, 0xF2};
CAN.sendMsgBuf(canId, 0, len, buf);
}
void keepLeftBlinkerOn()
{
const uint16_t canId = 0x1F6;
const uint8_t len = 2;
uint8_t buf[2] = {0x91, 0xF1};
CAN.sendMsgBuf(canId, 0, len, buf);
}
void keepRightBlinkerOn()
{
const uint16_t canId = 0x1F6;
const uint8_t len = 2;
uint8_t buf[2] = {0xA1, 0xF1};
CAN.sendMsgBuf(canId, 0, len, buf);
}
void sendFuelLevel(uint16_t litres)
{
uint16_t canId = 0x349;
const uint8_t len = 5;
uint8_t buf[5] = {0x00, 0x00, 0x00, 0x00, 0x00};;
uint16_t sensor1 = litres * 160;
buf[0] = lo8(sensor1);
buf[1] = hi8(sensor1);
uint16_t sensor2 = sensor1;
buf[2] = lo8(sensor2);
buf[3] = hi8(sensor2);
CAN.sendMsgBuf(canId, 0, len, buf);
}
uint32_t timestamp100ms = 0;
uint32_t timestamp800ms = 0;
bool firstBlinkerTurnOn = true;
void setup()
{
while (CAN_OK != CAN.begin(CAN_100KBPS))
{
delay(100);
}
}
void loop()
{
if (millis() - timestamp100ms > 99)
{
sendIgnitionKeyOn();
sendRPM(800);
timestamp100ms = millis();
delay(100);
}
if (millis() - timestamp800ms > 799)
{
// Turn blinker on after 30 seconds to avoid kombi
// missing the initial message when its turning on
if (millis() > 30000)
{
if (firstBlinkerTurnOn == true)
{
leftBlinkerOnInitial();
firstBlinkerTurnOn = false;
delay(100);
}
keepLeftBlinkerOn();
delay(100);
}
timestamp800ms = millis();
}
}