OBD-II CAN Bus Data Logger
bare-metal stm32 project. wanted to actually learn the peripherals so i built something real with it. plugs into my toyota's obd-ii port, reads engine data, shows live metrics on an lcd, logs to an sd card. wrote the can, spi, and i2c drivers myself off the reference manual.
firmware is working. haven't put it all together physically yet.
what's done / what's left
-
✓can driver + bit timingdone
bit timing registers calculated by hand. filter banks set to only pass the ecu response id so the interrupt doesn't fire on every frame on the bus.
-
✓ring buffer for can rxdone
sd writes stall sometimes and frames were dropping. moved reception into an interrupt with a ring buffer and the main loop drains it separately.
-
✓ecu queries + metric displaydone
polls for rpm, speed, temps, o2 voltage, maf. derives mpg and afr from those and shows them on the lcd.
-
✓sd loggingdone
-
physical assemblycurrent
got everything wired up in a breadboard and tested it in the actual car.
-
custom pcbnext
replace the breadboard version with a single kicad board.
-
3d printed enclosureplanned
-
wireless split via bleplanned
split into two sides: transmit side stays at the obd port and runs off car power, receive side sits anywhere in the cabin on a usb-c rechargeable lipo module i have. two separate microcontrollers talking over ble.
-
web app, live dashboard + controlsplanned
once the ble side is done, a web app that shows live data and lets you configure what gets logged, polling rates, alert thresholds. no more reflashing to change settings.
Tech Stack
STM32F103, C, CAN, SPI, I2C, FATFS
Hardware
STM32F103 Blue Pill, SN65HVD230 CAN transceiver, 2007 Toyota Avalon, SPI LCD, MicroSD module