Reading OBDII data with Java

3k Views Asked by At

Is there a simple way to make a Java program to read data from an OBDII v2.1 device (ELM 327) and specifically print the data human readable in screen.

For example:

public class OBDIIReader {
    public static void main(String[] args) {

        //
        //  Connecting to
        //  the OBDII via BT to
        //  the Raspeberry Pi
        //

        while(true) {
            System.out.println(Read.speed);
            System.out.println(Read.rpm);
            System.out.println(Read.engineTemp);
        }
    }
}
1

There are 1 best solutions below

0
On

There are thousands of libraries out there for ELM327 operation to connect to OBD2 and capture data. But you simply can't connect and expect it spit out things automatically, the ECU will only spit out data to the ELM327 when asked to do so.

This is very psuedo code but it would go something like this

ELM327 elm = ELM327.FindBluetoothDevice();
elm.Connect();
while(elm.Connected)
{
   System.out.println(elm.GetSpeed());
   System.out.println(elm.GetRPM());
   System.out.println(elm.GetECT());
}

A good example that might help you get started is something like this: http://gersic.com/connecting-your-raspberry-pi-to-a-bluetooth-obd-ii-adapter/