Arduino sketch for exporting vehicle telemetry over Serial via the OBD-II CAN bus.
- Initializes MCP2515-based CAN interface at 500 kbps and sets masks/filters for ECU responses.
- Functions to request and parse standard PIDs:
- Vehicle speed
- Engine RPM
- Accelerator pedal position
- Reads brake status from an analog input.
loop()queries these values and prints formatted data/S<speed>/R<rpm>/P<pedal>/B<brake>over Serial.
- Requires a board with an MCP2515 CAN controller (e.g., CANBed, CAN Bus Shield).
- Tested with: Longan Labs RP2040 CANBed
- Uses
SPI_CS_PINto select the CAN controller (default9). BRAKE_PIN(A1) monitors a brake switch.
- Connect the hardware to the vehicle's OBD-II port.
- Compile and upload
OBD2_data_export.inoto the microcontroller. - Open the Serial Monitor at 115200 baud to view the telemetry output.