Skip to content

Latest commit

 

History

History
91 lines (63 loc) · 2.55 KB

README.rst

File metadata and controls

91 lines (63 loc) · 2.55 KB

build version scrutinizer coverage

Python OBD Library

OBD Lib provides easy access to ELM327 OBD - II Interfaces in Python. It's been successfully used with ELM327 OBD - II bluetooth scanners and the Raspberry Pi to create portable automotive OBD - II logging devices. Data can be captured during test drives for later analysis. It may also be used as part of routine driving to gather information to determine an optimal vehicle maintenance schedule. Continuous logging may also help with vehicle troubleshooting when problems occur.

The library is still under development. Initial work focused on reading from and writing to ELM327 OBD - II interfaces.

Installation

Install using pip

$ pip install obdlib

Installation for micropython

For installing run:

$ MICROPYPATH='path-to-pyboard' pip-micropython install obdlib

Quick start

import obdlib.scanner as scanner
import time

# Example 1
# Retrieves value from one sensor
with scanner.OBDScanner("/dev/pts/6") as scan:
    while True:
        if scan.sensor:
            if scan.sensor.is_pids():
                # Engine coolant temperature
                sensor = scan.sensor[1]('05')
                # two or more ECU's respond to one request
                # we should be prepared for it
                for ecu, value in sensor.ecus:
                    print("ECU: {} Sensor {}: {} {}".format(ecu, sensor.title, value, sensor.unit))
                time.sleep(0.5)
            else:
                raise Exception("Pids are not supported")
        else:
            break

Supported Python Versions

OBDLib makes every effort to ensure smooth operation with these Python interpreters:

  • 2.7+
  • 3.4+
  • PyPy
  • micropython

License

See LICENSE for details.