Home Wiki > SDB:ELM327 based ODB2 scan tool
Sign up | Login

SDB:ELM327 based ODB2 scan tool

tagline: From openSUSE

Icon-cleanup.png This article is in need of attention because it does not follow our wiki guidelines. See Help:Style#General_usability
If you want to contribute, please read the rules for this wiki and if you have any questions, don't hesitate to contact the wiki team, we are more then willing to help you! :-)


With this ELM327 based gizmo it's possible to interface with the on-board computer of a (usually post 1996) car and retrieve lot's of very interesting information, like speed, engine characteristics and Diagnostic Trouble Codes.

Bluetooth OBD-II scann tool

Using the seller's list, some of the specs:

  • Feautures:
    • Read Codes display diagnostic Code(DTCs)
    • Clear DTC and Reset MIL(check Engine Light )
    • Support the latest vehicles with the new CAN-BUT protocols
    • No battery required power is supplied by the OBD port
    • LED indicate power and show communication staus
  • OBD-II protocols
    • SAE J1850 PWM (41.6 kbaud, 10.4 kbaud)
    • SAE J1939
    • ISO 9141-2? (5 baud init.10.4 kbaud)??
    • ISO14230-4 KWP (5 baud init.10.4 kbaud, fast init.10.4 kbaud)
    • ISO15765-4 CAN (11 baud init.500 kbaud, 29 baud init.500 kbaud, 11 baud init.250 kbaud, 29 baud init.250 kbaud, 29 /11baud init.250 kbaud)
  • Compatible with following vehicles:
    • Car in Europe market form 2001
    • Diesel cars in Europe from year 2004
    • Car (Domestic & Import) in the USA market from 1996
    • Light trucks (US Domestic & Import ) from 1996

Look for it on eBay

OBD-II resources

Open Source Software and Interfaces

as mentioned on this page

How to get it working on openSUSE / Linux

Unfortunately the package - and the CD inside it - only contained software and usage information for Windows. Good thing is that it is quite easy to get the scan tool working under openSUSE and of course also under other Linux distributions.

Communication schematics

                          PC ---> |               | <--ODB II scan tool -------> | <- Car
[Serial console, e.g. minicom]    |               |                              |
   |                              |               |                              |
   |                              |               |                              |
   +--[RS-232]--[rfcomm / Bluez]--|--[Bluetooth]--|--[console]--[ODB interface]--|--[ODB II interface ]--[car's on-board computer]
   |                              |               |                              |
   |                              |               |                              |
[ODB II program]                  |               |                              |

A more detailed block diagram of the ELM327 chip itself is shown on page 1 of the ELM327 data sheet (see References)

Required Software

Drivers

The Bluez package provides everything you need to connect with the device. Besides openSUSE and derivate distro's, Bluez is present in all mainstream Linux distributions that I'm aware of.

OBD-II program

Though the scan tool will make it possible to interface with the car's on-board computer (also know as ECU or Engine Control Unit), but in addition to this a specialized program is needed to interrogate it.

There seem to be numerous options on Windows but the choice on Linux is more limited. I've tried pyobd, which - after some tweaking on the initialization routine - was able to take a reading of the ECU.

Preparations

Bluetooth pairing code

The pairing code of this device is: 1234

It is probably not possible to change this, so theoretically anyone in range could connect to the scan tool. Besides being able to take some readings on the engine settings, the thread is quite limited though.

Bluetooth address

Attach the device to the OBD-II port on your car, and use the hcitool to discover the available Bluetooth devices. The scan tool will show up something like this:

   $ hcitool scan
   Scanning ...
       00:02:03:ac:a1:d3   EDT

Obviously the address will be different.

Getting connected

Create the device file

In this step we'll create a character device in /dev, which can be used by above mentioned OBD-II diagnostic programs. To do this, we'll need two additional parameters:

  • The number of the rfcomm channel the device is providing the serial port profile. The OBD-II scanner provides the serial port profile on channel 1.
  • A unique number x for our device file (/dev/rfcommx). Since it is possible to use other Bluetooth devices on the same computer, it is good practice to use unique device names for each Bluetooth device and make them persistent. This way one can avoid accidentally trying to open a GPS device with the OBD-II diagnostic program, or attempt to go on-line through a Bluetooth mouse because yesterday there used to be an UMTS modem on that device number.

Use this to create the device file /dev/rfcomm99

   # rfcomm bind 99 00:02:03:ac:a1:d3 1

To get a list with the state of all active rfcomm devices, use this:

   # rfcomm

To remove the device, execute this:

   # rfcomm release 99

This also will delete the device file /dev/rfcomm99

Connect to the scanner for the first time

   # rfcomm connect 99

It is more easy to do this step while running a Gnome session since it has a nice PIN entry applet.

Make the configuration persistent

Pairing code

After the first connection with the scan tool, the pairing PIN will be stored in /var/lib/bluetooth/<local macaddr>/linkkeys, so all subsequent connections will be automatic.

rfcomm settings

Edit the /etc/bluetooth/rfcomm.conf to reflect these settings.

   # cat /etc/bluetooth/rfcomm.conf
   rfcomm99 {
       bind yes;
       device 00:02:03:ac:a1:d3;
       channel 1;
       comment "ELM327 based OBD II test tool";
   }

Allow non-root users to use the scan tool

By default the device file /dev/rfcomm99 is created with ownership and group set to root and read-write access rights to owner and group.

   # ls -l /dev/rfcomm99
   crw--w---- 1 root root 4, 0 Aug 15 20:30 /dev/rfcomm99

With this simple udev rule one can automate the following actions every time the /dev/rfcomm99 device is created:

  • assign ownership to user "joe"
  • assign group ownership to group "dialout"
  • create the symbolic link /dev/obd-ii-scan-tool to /dev/rfcomm99

   # cat /etc/udev/rules.d/99_custom.rules 
   KERNEL=="rfcomm[0-9]*", ATTR{address}=="00:02:03:ac:a1:d3", ATTR{channel}=="1", NAME="%k", OWNER="joe", GROUP="dialout", SYMLINK+="elm327"

Use this to obtain more information about possible criteria for udev rules on the scan tool:

   # udevadm info -a -p  $(udevadm info -q path -n /dev/rfcomm99)

Using OBD-II software

Control the connection to the scan tool

An easy option is to use this script to control the connection to the scan tool.

cat /etc/init.d/elm327
#!/bin/bash
### BEGIN INIT INFO
# Provides: elm327
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop: $null
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: Start elm327
# Description: starts the elm327 bluetooth device
### END INIT INFO

DevNum=99       # DevNum is depending on the rfcom settings /etc/bluetooth/rfcom.cfg
case $1 in
start)
	 rfcomm bind $DevNum
	 ;;
stop)
	 rfcomm release $DevNum
	 ;;
status)
	rfcomm show $DevNum
	;;
*)
	cat<<EOF
Usage:
	$0 [ start | stop | status ]

EOF
esac

The start (and stop) operation will require root privileges, so non-root users should use the script with sudo.

sudo /etc/init.d/elm327 start

OBD-II software configuration

These programs require a serial port through which they can communicate with the ECU, so just point them to use the /dev/rfcomm99 or /dev/elm327 device.

ODB-II codes

There are lots of codes that ECU's are sending about the state of the numerous monitored parts. Some of these codes are standardized, others a manufacturer of maybe even model dependent.

References