This project offers a developer friendly interface to communicate with ELM 327 OBD devices via BLUETOOTH.
Add Dependency:
implementation 'com.pnuema.android:obd:1.4.3'
Code:
//Request MODE 1, PID 0C - RPM
val pid = PID(ObdModes.MODE_01, "0C")
val command = OBDCommand(pid)
command.run(bluetoothSocket.inputStream, bluetoothSocket.outputStream)
Log.d("PID", "${pid.description} : ${pid.calculatedResult}")
Log.d("PID Formatted Result", command.formattedResult)
//Clear DTCs - NonPermanent
val pid = PID(ObdModes.MODE_04) //Clear DTCs
val command = OBDCommand(pid)
command.run(bluetoothSocket.inputStream, bluetoothSocket.outputStream)
- Brad Barnhill (https://github.com/barnhill)