Skip to content

Java program for connect to obd2 Bluetooth adapter from Raspian. Based on https://github.com/pires/obd-java-api

Notifications You must be signed in to change notification settings

wojciechkocik/obd2

Repository files navigation

obd2 reader for RASPBIAN

Instruction

Prepare your system

  1. Install rxtx libs for java http://rxtx.qbang.org/
sudo apt-get install librxtx-java
  1. Instal bluetooth tools
sudo apt-get install bluetooth bluez blueman
sudo reboot
  1. Connect your OBD2 adapter with Bluez
  2. Scan connected devices and get your device address
hcitool scan

or

sudo apt-get install bluez-tools
bt-device -l
  1. Bind your device to rxtx
rfcomm bind 0 34:D2:12:02:82:72

Build and run app

  1. Build jar with Gradle
gradlew fatJar
  1. Run jar with java lib path (which contains rxtx libs)
java -Djava.library.path=/usr/lib/jni -jar obdpi-all-1.0.jar
  1. If running successful you will be asked for rxtx port to connect. Before that the program will prompt all available ports to use.

Example:

[main] INFO Main - Available ports:
[main] INFO Main - --> /dev/rfcomm0
[main] INFO Main - Enter binded com port:
/dev/rfcomm0
[main] INFO Main - Port /dev/rfcomm0 was chosen
[main] INFO Main - Starting service...
                          Reset OBDELM327v1.3aOBDGPSLogger
                           Echo Off    ATE0OK
                           Echo Off        OK
                      Line Feed Off        OK
                            Timeout        OK
               Select Protocol AUTO        OK
                      Vehicle Speed    37km/h
                         Engine RPM   5238RPM