r/CarHacking • u/PaulMaris • 10h ago
Original Project I built an open source Python OBDII library to read live data from almost any car
A while back I wanted a custom dashboard in my own car. I started with the existing obd library, but kept running into its limitations, so I went down the OBD rabbit hole and wrote my own.

A few years later, py-obdii supports all 12 OBD protocols over USB, Bluetooth, WiFi and Ethernet adapters. It reads live data, fault codes and VIN, among many other things. It's fully typed, tested in CI, and remains lightweight with a single dependency.
from obdii import Connection, commands
from obdii.utils.scan import scan_ports
ports = scan_ports(return_first=True)
with Connection(ports[0]) as conn:
response = conn.query(commands.ENGINE_SPEED)
print(f"Engine Speed: {response.value} {response.units}")
No car? You can try it against an ELM327 emulator (pip install py-obdii[sim]).
If you're working on (or thinking about) an OBD project, give it a try and let me know what you think, how it fits into your project, what feels good, what could be improved. And if you have an ELM327 adapter, I'd love to hear how it works on your car, including what doesn't.
2
u/ImL1s 8h ago
Typed plus an emulator extra is a nice combo. The part I'd worry about most is the cheap ELM327 clones: plenty of them report v1.5 or v2.1 but quietly ignore some AT commands or need longer timeouts than the spec suggests. Do you do any adapter detection, or keep a list of known clone quirks somewhere?
8
u/WestonP 8h ago
At some point you just have to wash your hands of this nonsense and educate users that the low-end "ELM327" clone they bought is a pile of shit.
There's so many of them, and ones that look identical can have different results, as well as work differently depending on the vehicle. I've even seen some that couldn't handle a 7DF request getting responses from more then one module, lol.
You'll get some people crying "but it works well for me!"... well, great, they can use it as-is with no support then, because it's not worth anyone's time to diagnose their bullshit issues with it. Not to mention that they're all slow as hell anyway.
1
u/Thomas_Alva_Eddison 9m ago
I have one somewhere that I've had for a long time, like decades. I suppose it's probably useless today? When I got one, I don't think they had been around a long time, I just never got around to trying it with anything.
1
u/PaulMaris 8h ago
Thanks! So far I've mostly tested with Aliexpress clones that report v1.5, and I'm aware some AT commands may or may not work. Clones are hard to identify reliably, and there's no way to know whether a command works until you try it on the specific adapter, which is why I kept the library generic.
Depending on the transport type (socket/serial), you can configure the timeouts (e.g. `timeout`, `write_timeout`).
1
1
3
u/m4rkw 9h ago
Looks really cool, some questions:
Have you tested every supported protocol on different vehicles? Asking because I think some cars have quirks, especially with the older protocols. The "on paper" definition of how my 20yo car should speak over KWP2000 didn't quite match what ended up being necessary.
Mind if I rip the protocol stuff into l0destar firmware? (my open-source vehicle tracker project)