MCP ExplorerExplorer

Canbus Arduino Mcp2515

@lilwesyyon 16 days ago
1 MIT
FreeCommunity
AI Systems
Library to hack canbus from BMW

Overview

What is Canbus Arduino Mcp2515

Canbus-Arduino-MCP2515 is a library designed for hacking the CAN bus in BMW vehicles, enabling users to perform gauge sweeps when the vehicle ignition is turned on.

Use cases

Use cases include performing gauge sweeps during vehicle startup, monitoring ignition states, and customizing vehicle dashboard behaviors through Arduino programming.

How to use

To use Canbus-Arduino-MCP2515, connect an Arduino board compatible with the CAN.h library to a CAN transceiver module and a 12V power source. Upload the provided sketch, which will automatically trigger a gauge sweep upon ignition.

Key features

Key features include connecting to the CAN bus at 100 kbps, monitoring CAN messages to detect ignition state, performing gauge sweeps for speedometer and tachometer, and the option to include fuel and oil gauges.

Where to use

Canbus-Arduino-MCP2515 is primarily used in automotive applications, specifically for BMW vehicles, where it can enhance the functionality of dashboard gauges.

Content

CAN BUS E9X & more (Arduino + CAN.h)

This Arduino sketch performs a gauge sweep (full-scale needle movement) via CAN bus when vehicle ignition is turned on. It is intended for vehicles where Arduino is powered through a 12V cigarette lighter, so the sweep is triggered automatically at ignition.


🚗 Features

  • Connects to the CAN bus at 100 kbps.
  • Monitors CAN messages with ID 0x130 to detect ignition state.
  • Performs gauge sweep only when ignition is in RUN or START mode.
  • Moves speedometer and tachometer to max, then resets them.
  • Optionally includes fuel and oil gauges in the sweep.
  • Sweep runs once per power-up, ideal for ignition-powered setups.

🧰 Requirements

  • Arduino board compatible with the CAN.h library (e.g. ESP32 + transceiver, Arduino MKR CAN, etc.)
  • CAN transceiver module (e.g. MCP2551, TJA1050, SN65HVD230…)
  • 12V power source from the vehicle (e.g. cigarette lighter)
  • Access to a 100 kbps CAN bus

🗂 Code Overview

Section Description
setup() Initializes CAN and sets receive callback
loop() Empty — all logic is handled by onReceive()
onReceive() Detects ignition state and triggers sweep
gauge_sweep() Moves selected gauges to max, then resets them
hijack_gauge() Sends a CAN message to move a gauge
reset_gauge() Sends a CAN message to reset a gauge

⚙️ Configuration Options

You can configure sweep behavior directly in the .ino file:

#define CAN_SPEED 100E3           // CAN bus speed (typically 100 kbps)
#define SERIAL_BAUD 250000        // Serial monitor baud rate

const bool gauge_sweep_enable = true;      // ⬅️ Master switch: enable/disable sweep logic
const bool sweep_small_gauges  = true;     // ⬅️ Include fuel and oil gauges in sweep

const int steps_max_large = 4667;          // Max step value for speedometer and tachometer
const int steps_max_small = 1800;          // Max step value for fuel and oil gauges

Tools

No tools

Comments