Git Product home page Git Product logo

obd's Introduction

Java OBD

Android library for getting vehicle diagnostics from ELM327 (USB/Bluetooth) connector over OBD protocol.

Basic Usage

// 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<String, AsyncCommand<int>> commands = new HashMap<String, AsyncCommand<int>>();
commands.put("Ethanol fuel", new AsyncCommand(Mode01.ETHANOL_FUEL));

// Declare outside class or different file
class MyCallback<T> implements AsyncCallback {
    public T run(Object... params) {
        // Your implementation
    }
}

commands.put("ECU name", new AsyncCommand(Mode09.ECU_NAME, new MyCallback<int>(), 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

obd's People

Contributors

tomiwa-ot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mirlisboa

obd's Issues

Issue to send PID Code

Hi Tomiwa,

I used your library where I found one issue we are unable to send code when we are successfully connected with the ELM OBD device.

ISSUE Found :
dataOutputStream.writeChars(command);

Solution :
out = new BufferedWriter(new OutputStreamWriter(outStream), 1);
out.write(msg.toCharArray());

You can connect with me on Skype if you have any issue regarding that
davinder_syall or emailId : [email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.