Quickstart

This page helps you get started quickly with the library. It assumes the library is already installed, if not check the Installation section.

Overview

This library can operate in two main scenarios:

  1. Simulated Environment: No car or adapter needed, ideal for development and testing.

  2. Real Vehicle Connection: Connects to an actual car using an OBDII adapter.

Internally, both scenarios works the same way, your code remains the same, so you can switch between scenarios seamlessly. The only difference is the port you provide when establishing the connection.

Minimal Example

main.py
1from obdii import commands, Connection
2
3with Connection("PORT") as conn:
4    response = conn.query(commands.ENGINE_SPEED)
5    print(f"Engine Speed: {response.value} {response.units}")

Note

Replace "PORT" with the appropriate port. See Determining Your Port section below.

You can find more detailed examples and usage scenarios in the repository.

Determining Your Port

Scenario 1: No Car or No Adapter

This scenario is ideal for development, it doesn’t require any physical OBDII adapter or vehicle.

Refer to the Emulating a Vehicle page for setup instructions and usage details.

Scenario 2: Car and OBDII Adapter

This scenario is ideal for real-world applications, it connects to an actual vehicle via a physical OBDII adapter.

As mentioned, you will need:

  1. A vehicle with an OBDII port (most vehicles manufactured after 1996 have one).

  2. An OBDII adapter.

Refer to the Connection page for detailed instructions and more information on adapters.