Skip to main content

A Python library for reading vehicle diagnostic data from ELM327 BLE OBD-II adapters

Project description

elm327_obdii

PyPI Version

A Python library for reading vehicle diagnostic data from ELM327 Bluetooth Low Energy (BLE) OBD-II adapters.

This library is used by the ELM327 OBD-II BLE integration in Home Assistant.

Features

  • Connect to ELM327 BLE OBD-II adapters via Bluetooth
  • Read standard OBD-II Mode 01 PIDs (engine speed, vehicle speed, coolant temperature, fuel level, etc.)
  • Read vehicle-specific custom PIDs from OBDb and WiCAN community profiles
  • Voltage-gated polling state machine to protect the vehicle's 12V auxiliary battery
  • Structured fmt formula representation for signal decoding (bit extraction, linear scaling, enumerations)
  • CAN context management (ATSH/ATCRA header/filter switching for multi-ECU vehicles)

Data Sources

The library fetches vehicle profile data at runtime from:

  • OBDb — community-maintained database of 160+ vehicle models with 11,000+ signal definitions. Licensed under CC-BY-SA 4.0.
  • WiCAN — meatpiHQ/wican-fw repository with 77 vehicle profiles. Licensed under GPL-3.0.

The fetched profile data is subject to those licenses. The library code itself is Apache 2.0 and does not distribute any profile data.

Installation

pip install elm327_obdii

Usage

import asyncio
from elm327_obdii import Poller, PollerConfig, ProfileConfig

async def main():
    config = PollerConfig(
        profile=ProfileConfig(),
        atrv_supported=True,
        voltage_check_enabled=True,
        voltage_on=13.1,
        voltage_off=13.0,
        grace_seconds=30,
    )
    poller = Poller(config)

    # Connect to the adapter (provide a BLEDevice from bleak)
    ble_device = await bleak.BleakScanner.find_device_by_address("AA:BB:CC:DD:EE:FF")
    poller.connect(ble_device, asyncio.get_event_loop(), uuid_write, uuid_read)

    # Poll once
    result = poller.poll_once()
    print(f"State: {result.state}, Voltage: {result.voltage}")
    print(f"Data: {result.data}")

asyncio.run(main())

Development

python3 -m venv .venv
source .venv/bin/activate
# for Windows CMD:
# .venv\Scripts\activate.bat
# for Windows PowerShell:
# .venv\Scripts\Activate.ps1

pip install -e ".[test]"
pytest

python -m pip install pre-commit
pre-commit install
pre-commit run --all-files

Live tests

Some tests require network access to fetch live vehicle profiles from OBDb and WiCAN:

pytest --run-network

License

Apache License 2.0 — see LICENSE for details.

The test fixtures in tests/fixtures/obdb_egolf/ are sourced from the OBDb Volkswagen e-Golf repository and are licensed under CC-BY-SA 4.0. See tests/fixtures/obdb_egolf/README.md for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

elm327_obdii-0.0.1.tar.gz (71.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

elm327_obdii-0.0.1-py3-none-any.whl (50.4 kB view details)

Uploaded Python 3

File details

Details for the file elm327_obdii-0.0.1.tar.gz.

File metadata

  • Download URL: elm327_obdii-0.0.1.tar.gz
  • Upload date:
  • Size: 71.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for elm327_obdii-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c32ff794f27682450388dc208eaaf84b414a29ee8e3eb6e65eee33695c624d2a
MD5 e6a1f4823f7e7ff8dd998ae2e366f4a4
BLAKE2b-256 92c52204fcdbe4886fbf3d0195ce1f5b75b1fbce8d53d5ed360375e0dc080741

See more details on using hashes here.

Provenance

The following attestation bundles were made for elm327_obdii-0.0.1.tar.gz:

Publisher: python-publish.yml on tronikos/elm327_obdii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file elm327_obdii-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: elm327_obdii-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 50.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for elm327_obdii-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fc318126c64fc72aceeedbbbb8ac0c86ca0d4526f7d070c8fc6e9236fbfe72c9
MD5 8551271cd9861907f80a374217ed46f8
BLAKE2b-256 6a4bf48f1183210170c23189a1d3f63af7e7965a224849d5ddb767abf9e67d3e

See more details on using hashes here.

Provenance

The following attestation bundles were made for elm327_obdii-0.0.1-py3-none-any.whl:

Publisher: python-publish.yml on tronikos/elm327_obdii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page