Vehicle Data app icon

Case study · Master's thesis · IoT + Spring Boot + Android · 2021

Smart System For Vehicle Remote Monitoring and Control

Live OBD-II data from a running car, delivered over the internet to an Android app, at any distance.

Pythonpython-OBDELM327Raspberry Pi 3 B+MySQLJavaSpring BootSpring Data JPALombokAndroid SDKOkHttp
Explore the architectureMeet the app
Vehicle Data category menu
Vehicle Data live performance dashboard
Vehicle Data sensor graphs

An end-to-end IoT system that connects a regular car to the internet, from the OBD-II port to the palm of your hand.

Acquisition

An ELM327 interface links the car's OBD-II port to a Raspberry Pi 3 B+, where a Python script continuously queries the vehicle and stores the results in MySQL.

Server

A Spring Boot REST API running on the same board exposes the database to the internet through a layered architecture and a complete set of CRUD endpoints.

App

An Android app turns raw data into live dashboards, sensor graphs and diagnostics, and adapts to every car it is connected to.

55vehicle parameters
23sensors tracked
38REST endpoints
4vehicle profiles

THE IDEA

Modern cars are networks on wheels: dozens of electronic control units exchange data over the CAN bus, and the standardized OBD-II port gives access to much of it. Yet this information usually stays inside the car, visible only when a technician plugs in a diagnostic tool.

Developed as my master's dissertation in Advanced Microelectronics at the University POLITEHNICA of Bucharest, this project sets that data free. It reads a running vehicle in real time, makes its parameters available on the internet, and lets the driver monitor the car from any distance, and even act on it, from an Android phone.

Connected vehicles exchanging data over the internet

Connected vehicles: data that leaves the car, in real time

SYSTEM ARCHITECTURE

VEHICLERASPBERRY PI 3 B+ANDROID APPCAN busECU networkOBD-II portDiagnosticsREST APISpring BootMySQLvehicle_dataPython scriptpython-OBDOkHttp clientHTTP requestsUser interfaceLive dashboardsSerial · ELM327HTTP · internetVehicle dataRequests back VEHICLERASPBERRY PIANDROID APPCAN busECU networkOBD-II portDiagnosticsPython scriptpython-OBDMySQLvehicle_dataREST APISpring BootOkHttp clientHTTP requestsUser interfaceLive dashboardsSerial · ELM327HTTP · internetVehicle dataRequests back

System data flow: data travels from the car to the phone, requests travel back

1. Vehicle

Electronic control units share their data over the CAN bus, exposed through the OBD-II port.

2. ELM327 interface

A wired adapter translates the on-board diagnostic protocols into serial data over USB.

3. Raspberry Pi 3 B+

Powered from the car's 12 V socket and online through a mobile internet dongle, it hosts the Python script, the MySQL database and the API.

4. REST API

Spring Boot makes the database available on the internet through HTTP endpoints.

5. Android app

Displays the data in real time and sends the driver's requests back to the system.

Because the system is RESTful, client and server are fully decoupled: the app knows nothing about the car or the board, only about the API. Communication is also two-way. Data travels from the vehicle to the phone, while requests such as clearing trouble codes travel back the other way.

DATA ACQUISITION

On the hardware side, an ELM327-based cable connects the vehicle's OBD-II port to the USB port of a Raspberry Pi 3 B+. The ELM327 microcontroller speaks all major on-board diagnostic protocols, including ISO 15765-4 CAN, ISO 14230-4 KWP, ISO 9141-2, SAE J1850 PWM/VPW and SAE J1939, making the system compatible with most cars on the market.

On the board, a Python script built on the python-OBD library runs continuously. OBD communication is request-response: the script sends Parameter IDs (PIDs), the vehicle answers, and the library parses each response into a typed value, ready to be stored.

ELM327 OBD-II cable, Raspberry Pi 3 B+ and internet dongle

The acquisition hardware: ELM327 cable, Raspberry Pi 3 B+ and internet dongle

Capability discovery

Before collecting anything, the script asks the car which parameters it supports, using the PIDS_A, PIDS_B and PIDS_C commands (0x00, 0x20, 0x40). Only valid requests are sent from then on, so the same script works on any vehicle.

Parameter selection

The data set was defined by analyzing real driving data from my own car with a Bluetooth ELM327 reader. 55 parameters were selected and grouped into 5 categories: information, performance, sensors, emissions and trouble codes.

Continuous polling

The board constantly interrogates the vehicle. Each value is converted to the type and format of its database column and persisted right away, keeping the delay between the car and the app to a minimum.

Profile-aware writes

Data is written only for the profile marked active in the database, so every vehicle keeps its own current and historical records.

DATA MODEL

The vehicle_data MySQL database, administered with phpMyAdmin, is the data hub of the system. It is organized in 6 tables: one for each data category, plus a profiles table that lets a single installation serve up to four vehicles.

The profile name acts as the primary key across the category tables, so every query returns only the data of the selected vehicle. Creating a profile inserts an empty record in each table, ready to be filled by the acquisition script.

JAVA ENTITIESMYSQL TABLESProfileDataTBLPROFILEInfoDataTBLINFORMATIONPerformanceDataTBLPERFORMANCESensorDataTBLSENSOREmissionDataTBLEMISSIONDtcDataTBLDTC ENTITIESTABLESProfileDataTBLPROFILEInfoDataTBLINFORMATIONPerformanceDataTBLPERFORMANCESensorDataTBLSENSOREmissionDataTBLEMISSIONDtcDataTBLDTC

Each table is mapped to a JPA entity in the API

TBLPROFILE

Profiles

Name, brand, model and year for up to four vehicles, plus an Active flag marking the profile in use. Only one profile can be active at a time.

TBLINFORMATION

Vehicle information

Static identity data: VIN, engine and fuel type, main ECU name, ECU hardware and software versions, type approval number and last programming date.

TBLPERFORMANCE

Performance

Live driving parameters such as current and average speed, engine RPM, selected gear, throttle and torque, updated in real time.

TBLSENSOR

Sensors

Readings from 23 sensors, from coolant and intake air temperature to barometric pressure, fuel level and battery voltage. Each column keeps its last 10 values, feeding the app's graphs.

TBLEMISSION

Emissions

Emission monitor flags, each stored as N/A, FAILED or PASSED. A failure is raised when an emission sensor exceeds its threshold.

TBLDTC

Trouble codes

Every recorded DTC with its code, description and date. A profile can hold many codes, so this table uses an auto-incremented id as its key.

THE REST API

vehicledata-api is a Spring Boot web service running on the Raspberry Pi. It is the bridge between the database and the mobile app: it exposes the stored data on the internet and handles every create, read, update and delete operation.

It is built with Spring Web, Spring Data JPA, Spring Actuator and RestTemplate, packaged with Gradle, while Lombok removes the boilerplate from the entities. Each table has its own entity, repository, service and controller, keeping every data category cleanly separated.

Entities

JPA classes annotated with @Entity and @Table, with attributes mapped one-to-one to the table columns.

Repository layer

Interfaces extending CrudRepository. Spring derives queries such as findDtcDataByProfile from the method names.

Service layer

Business logic defined by an interface and its implementation, using the injected repository for every database operation.

Controller layer

@RestController classes that map GET, POST, PUT and DELETE requests to the service methods.

One contract for every data category

6 resources · 38 endpoints · base path /vehicledata-api

profilesinfoperformancesensorsemissiondtc
  • GET/{resource}/All records
  • GET/{resource}/{profileName}Records of one vehicle profile
  • POST/{resource}/postCreate from an object
  • POST/{resource}/post/jsonCreate from a JSON body
  • PUT/{resource}/putUpdate a record
  • DELETE/{resource}/delete/{profileName}Delete the records of a profile
  • GET/info/vin/{vinCode}Look up a vehicle by its VIN
  • POST/dtc/post/listStore a batch of trouble codes
  • DELETE/dtc/delete/{profileName}/{dtcName}Clear a single trouble code

THE MOBILE APP

Vehicle Data is the face of the system. Written in Java with the Android SDK, it is a client fully decoupled from the server: a dedicated networking class built on OkHttp handles every GET, POST, PUT and DELETE request, with connection pooling and response caching.

The interface is built from custom views and animated with an in-house library based on ObjectAnimator. Data is grouped exactly like the database, and every screen adapts to the selected vehicle, showing only what that car can actually report.

LaunchMainActivityProfilesMenuActivityCategoriesInfoActivityVehicle informationPerformanceActivityLive dashboardSensorActivitySensor graphsEmissionsActivityEmission monitorsDtcsActivityTrouble codes LaunchMainActivityProfilesMenuActivityCategoriesInfoActivityVehicle informationPerformanceActivityLive dashboardSensorActivitySensor graphsEmissionsActivityEmission monitorsDtcsActivityTrouble codes

Activity structure: from profile selection to each data category

Vehicle Data profile list

UP TO 4 VEHICLES

Profiles

Vehicles are listed as cards. A welcome screen guides the creation of the first profile, and Create Profile is disabled once four profiles exist.

Vehicle Data vehicle information screen

VEHICLE IDENTITY

Information

Brand, model and year, followed by the VIN, engine and fuel type, ECU details, type approval number and last programming date read from the car.

Vehicle Data performance dashboard

LIVE DASHBOARD

Performance

An instrument cluster of animated dials for speed and RPM, plus gear, throttle, torque and more. Values and dials change color to draw attention.

Vehicle Data sensor graphs

REAL-TIME GRAPHS

Sensors

Each sensor card shows the current value and a graph of the last 10 readings. Sensors the car does not have are hidden automatically.

Vehicle Data emissions screen

EMISSION MONITORS

Emissions

Each emission system is shown as PASSED, FAILED or N/A, making abnormal readings visible at a glance.

Vehicle Data diagnostic trouble codes

TWO-WAY CONTROL

Trouble codes

Recorded DTCs with description and date. Rescan on demand, then clear codes one by one or all at once, removing them from the system.

PROFILE MANAGEMENT

Create profile form with vehicle suggestions
Update profile form pre-filled with stored data
Delete profile confirmation
Create

A form asks for the profile name, brand, model and year. Every field is validated, and missing ones are highlighted.

Smart suggestions

Brand, model and year offer predefined lists. Picking a brand loads its models, and changing the brand clears the model.

Edit

The Options button or a long press reveals edit and delete controls. The update form opens pre-filled with the stored data.

Delete

After confirmation, the profile and all of its data are removed from every table.

Switch

Change profile in the category menu returns to the list, and the active profile is always shown at the bottom of the screen.

Real time

The board polls the car continuously, and the app reflects database changes instantly.

Any distance

Monitor the car over the internet, wherever it is.

Two-way

Read data from the vehicle and send requests back, such as clearing trouble codes.

Adaptive

Only the parameters supported by the current car are displayed.

RESULTS & NEXT STEPS

Results

A working vehicle monitoring system that can be used over the air, from any distance, as long as there is an internet connection. The RESTful design keeps client and server independent, the API follows good practices with clearly separated layers, and the app delivers a complete, modern monitoring experience for up to four vehicles.

Future direction

Raise the profile limit and monitor multiple vehicles in parallel. Thanks to the modular architecture, the board hosting the database and API could become a stationary server, while lightweight client boards in each car run the acquisition script and send their data over the air.