OBD car trip telemetry tracker
- Status
- Phase 1 complete
- Vehicle
- Toyota Yaris sedan, 2011
- Live demo
- mycar-telemetry.netlify.app
- Github
- Repo Link
- Tags
Overview
This is a personal car telemetry system built around a Raspberry Pi, which acts as the data collection device. The Pi connects to my car through a Bluetooth ELM327 OBD-II adapter and polls the car's ECU for live sensor data over the CAN bus. Everything is written to a local SQLite database on the Pi, so each trip is recorded like a small black box, with no internet connection needed.
Phase 1 is deliberately narrow: reliable local capture of tiered trip data to SQLite.
The problem
My car is older, and I wanted to track its health over time instead of waiting for a warning light. Then I found out about the OBD port, and my car (a 2011 Toyota Yaris sedan) is new enough to support it. Nearly every car exposes live sensor data through OBD-II, so the data was already there. I just needed a way to capture it.
Phone apps that connect to OBD-II adapters can show live gauges, but none of them fit what I wanted:
- Little control over the data. I couldn't choose which sensors to poll or how often. Fast-changing values like RPM and slow-moving ones like barometric pressure were all read the same way.
- No proper storage. Most apps show a live gauge and nothing more. I wanted every trip saved so I could look back and compare trips over time.
- Cost. The ones that offered logging or more advanced features were mostly paid.
So I built my own logger: one I fully control, that stores every trip, and that polls each sensor at a rate matching how quickly its value changes.
What it does
At the start of each trip, I connect the Raspberry Pi to the Bluetooth OBD-II adapter and run the logger script. Data is captured in three tiers:
- Once per trip: static and diagnostic values such as VIN, distance since DTC clear, MIL status and stored fault codes.
- Every second: the core live driving metrics: speed, RPM, engine load, throttle position, coolant temperature, MAF (mass air flow), intake air temperature and short-term fuel trim.
- Every 30 seconds: slower-moving context values: long-term fuel trim, control module voltage, ambient air temperature, barometric pressure, post-catalyst O2 sensor reading and catalyst temperature.
Every reading is timestamped and stored in a SQLite database, linked to the trip it belongs to.
Architecture
- Vehicle ECU system: the car's onboard computer exposes vehicle metrics through the OBD-II diagnostic port. An ELM327 Bluetooth adapter plugs into this port and sends the data out wirelessly.
- Raspberry Pi (datalogger): at the start of each trip, the logger script starts and connects to the adapter over Bluetooth. It then runs two scheduled loops: a 1-second loop for the core performance metrics and a 30-second loop for the secondary diagnostics.
- Local storage: the Python script parses and formats each reading, then writes it with a timestamp into a local SQLite database (
obd_data.db).
Why three tiers?
The Bluetooth link to the adapter is slow, and every query uses up some of that bandwidth. If I polled everything every second, the values I care most about would be read less often. So I sorted each sensor by how fast its value actually changes.
Every ~1 second: the live story of the trip
| Command | Why it earns a spot |
|---|---|
SPEED | Core trip metric |
RPM | Core trip metric. Pairs with speed for shift and driving-behavior analysis |
ENGINE_LOAD | Shows how hard the engine is working: hills, acceleration, towing |
THROTTLE_POS | Driver input, useful for judging how smooth the driving is |
COOLANT_TEMP | Tracks warm-up and flags overheating |
MAF | The basis for a live fuel-consumption estimate |
INTAKE_TEMP | Cheap to read, changes with conditions, feeds efficiency analysis |
SHORT_FUEL_TRIM_1 | Combustion health trend. Noisy, but useful once aggregated |
Every ~30 seconds: slow-moving context
These values don't change fast enough to justify 1 Hz polling. Reading them every second would just eat Bluetooth bandwidth that the 1-second list needs.
| Command | Why |
|---|---|
LONG_FUEL_TRIM_1 | A learned value that drifts slowly. Good for long-term health trends, pointless at 1 Hz |
CONTROL_MODULE_VOLTAGE | Battery and alternator health, which changes slowly |
AMBIANT_AIR_TEMP | Outside temperature doesn't change second to second |
BAROMETRIC_PRESSURE | Only really changes on long drives with a big change in elevation |
O2_B1S2 | Post-catalyst sensor. I care about the trend over the trip (it should stay steady), not a jittery live chart |
CATALYST_TEMP_B1S1 | Slow thermal mass, so it doesn't swing from second to second |
Once per trip: health checks
| Command | Why |
|---|---|
STATUS | MIL on/off and fault code count. My "all clear" badge |
GET_DTC | Only pulled if STATUS says there are stored codes |
RUN_TIME | Engine run time at the start of the trip |
DISTANCE_SINCE_DTC_CLEAR | A context stat rather than a trend line |
VIN | Identifies which car the trip belongs to, in case I add a second vehicle later |
SQLite schema
Each trip gets one row in trips, one row in trip_start_data, and many rows in the two sample tables.
trips
| Column | Type | Key |
|---|---|---|
| id | integer | PK |
| started_at | integer | |
| ended_at | integer |
trip_start_data
The once-per-trip values, which act as a kind of pre-drive inspection. I plan to build a separate inspection page or script on top of this table.
| Column | Type | Key |
|---|---|---|
| trip_id | integer | PK |
| vin | text | |
| distance_since_dtc_clr | integer | |
| run_time_s | integer | |
| mil_on | integer | |
| dtc_count | integer | |
| stored_dtcs | text |
samples_1s
| Column | Type | Key |
|---|---|---|
| id | integer | PK |
| trip_id | integer | FK |
| ts | integer | |
| speed_kmh | real | |
| rpm | real | |
| engine_load | real | |
| throttle_pos | real | |
| coolant_temp_c | real | |
| maf_gps | real | |
| intake_temp_c | real | |
| short_fuel_trim | real |
samples_30s
| Column | Type | Key |
|---|---|---|
| id | integer | PK |
| trip_id | integer | FK |
| ts | integer | |
| long_fuel_trim | real | |
| module_voltage_v | real | |
| ambient_temp_c | real | |
| baro_pressure_kpa | real | |
| o2_post_cat_v | real | |
| catalyst_temp_c | real |
Tech stack
- Hardware: Raspberry Pi with a small attached screen, ELM327 Bluetooth OBD-II adapter
- Protocol: OBD-II over CAN bus
- Language: Python
- Storage: SQLite
Challenges and what I learned
Unreliable connections and messy data
The Bluetooth link to the adapter isn't always stable. Dropped connections left gaps and occasionally bad readings in the data, and I had to clean up some of it in SQLite by hand. This taught me that a logger needs to expect failure: retry connections, handle empty responses, and never assume that every query returns a value.
OBD is request-response, and I have to ask for everything
The car doesn't stream sensor data to me. For each value I want, the Pi sends a request for one specific sensor (a PID), the ECU replies with that single reading, and the exchange is over. Setup happens once at the start of a trip: the Pi connects to the adapter over Bluetooth, the adapter is initialised, and it detects which protocol the car speaks. After that, each live-data query is independent and no session needs to be kept alive.
This shaped the whole design. Every query takes time on a slow Bluetooth link, and the readings arrive one at a time. Polling every sensor every second would crowd out the ones I care about most, so I split the sensors into polling tiers by how fast their values change. I also can't assume a reply will always come back. A sensor can return "no data", or the adapter can stall, so the logger has to handle empty and failed responses.
What's next
The next phase will focus on two things:
- A separate vehicle health check page. This would run occasionally rather than every trip, and would build on the data in
trip_start_data. - A better data pipeline. Right now, getting data from the car to the UI takes too many manual steps:
- I set up the Pi and start the script by tapping its small attached screen.
- After the drive, I copy the SQLite database over SSH.
- I convert the tables to JSON files with the SQLite command line and drop them in the UI's public folder.
There's a further question about what to show. A trip on its own isn't very useful unless something went wrong, so rather than listing every trip, the system should surface the ones where a fault or anomaly was detected. Syncing the data into a time-series store like TimescaleDB, visualizing it with Grafana, and possibly adding GPS and IMU data are on the longer-term list too.
Setup