Emulating a Vehicle
Let’s be honest, developing OBDII tools directly from your car isn’t the most practical setup. For convenience (and comfort), we use a vehicle emulator during development. It simulates real car responses at your desk, allowing you to test and build features without constantly connecting to a real vehicle.
This is especially handy when you’re iterating quickly, writing tests, or just don’t want to sit in the driveway with a laptop balanced on your knees.
To simulate a vehicle, you can use the ELM327-Emulator, a third-party tool included automatically when you install the library with the sim extra:
pip install py-obdii[sim]
The emulator simulates a vehicle’s responses and can be connected to just like a real car through a virtual serial port.
Run and use the emulator on Linux.
Install the library with development dependencies
Start the ELM327 Emulator
$ python -m elm -s car --baudrate 38400The emulator will display the virtual port (e.g., /dev/pts/1) to use for connection.
Connect your Python code to the emulator (e.g., /dev/pts/1):
To run and use the emulator on Windows, you will need to create virtual serial ports.
Install the library with development dependencies
Install a kernel-mode virtual serial port driver like com0com
Note
On Windows 10 and 11, Secure Boot may block unsigned drivers. So make sure you download and install the signed version of com0com.
Files: SourceForge Repository
Direct Download: com0com-3.0.0.0-i386-and-x64-signed.zip
Create a virtual COM port pair (e.g., COM5 ↔ COM6)
Start the ELM327 Emulator on one end of the virtual connection (e.g., COM6):
python -m elm -p COM5 -s car --baudrate 38400This command launches the emulator in car simulation mode on COM5.
Connect your Python code to the other end of the virtual pair (e.g., COM6):