Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tomiwa-ot/obd
Android library for getting vehicle diagnostics from ELM327 (USB/Bluetooth) connector over OBD protocol
https://github.com/tomiwa-ot/obd
android android-bluetooth android-java android-library android-obd-diagnostics android-usb canbus elm327 java obd obd-ii obd-port obd2 on-board-diagnostic
Last synced: 3 months ago
JSON representation
Android library for getting vehicle diagnostics from ELM327 (USB/Bluetooth) connector over OBD protocol
- Host: GitHub
- URL: https://github.com/tomiwa-ot/obd
- Owner: Tomiwa-Ot
- License: apache-2.0
- Created: 2023-06-18T14:59:25.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-02-25T09:08:40.000Z (12 months ago)
- Last Synced: 2024-02-26T07:37:14.307Z (12 months ago)
- Topics: android, android-bluetooth, android-java, android-library, android-obd-diagnostics, android-usb, canbus, elm327, java, obd, obd-ii, obd-port, obd2, on-board-diagnostic
- Language: Java
- Homepage: https://tomiwa-ot.github.io/obd/
- Size: 705 KB
- Stars: 10
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Java OBD
Android library for getting vehicle diagnostics from ELM327 (USB/Bluetooth) connector over OBD protocol.### Basic Usage
```java
// For USB connections
Obd obd = new Obd(getApplicationContext());// For bluetooth connections
final UUID SPP_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
// NB: BluetoothDevice device
Obd obd = new Obd(device.createRfcommSocketToServiceRecord(SPP_UUID), getApplicationContext());// Enable/disable headers
obd.enableHeaders(true);// Get device ID
String deviceId = obd.sendCommand(AT.DEVICE_IDENTIFICATION);// Get engine coolant temperature
String engineCoolantTemperature = obd.sendCommand(Mode01.ENGINE_COOLANT_TEMPERATURE);// Get vehicle speed (km/h)
double speed = obd.getVehicleSpeed();// Get engine oil temperature (°C)
double oilTemperature = obd.getEngineOilTemperature();// Register asynchronous requests
Map> commands = new HashMap>();
commands.put("Ethanol fuel", new AsyncCommand(Mode01.ETHANOL_FUEL));// Declare outside class or different file
class MyCallback implements AsyncCallback {
public T run(Object... params) {
// Your implementation
}
}commands.put("ECU name", new AsyncCommand(Mode09.ECU_NAME, new MyCallback(), new Object[]{}));
AsyncObd async = new AsyncObd(obd, commands, false);
Thread thread = new Thread(async);
thread.start();String response = commads.get("ECU name").getResponse(); // Get OBD response
boolean isCallbackNull = commads.get("ECU name").isCallbackNull(); // Check if async command has callback
Object callbackResult = commads.get("ECU name").getCallbackResult(); // Get callback output
async.stopExecuting() // To terminate thread
```### Installation
- Add it in your root build.gradle at the end of repositories
```
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```
- Add dependency```
dependencies {
implementation 'com.github.Tomiwa-Ot.obd:obd:1.21'
}
```
### Documentation
https://github.com/Tomiwa-Ot/obd/wiki