Establish a serial connection to the ELM327 adapter (USB, Bluetooth SPP, or Wi-Fi TCP socket) using a standard serial/socket library; common baud rates for USB are 38400 or 115200
Initialize the adapter by sending ATZ (reset), then AT E0 (echo off), AT L0 (linefeeds off), and AT SP 0 (auto-select OBD protocol); read and discard responses until you receive a prompt character
Query a live PID by sending the mode and PID in hex, e.g., 01 0C for engine RPM or 01 0D for vehicle speed; parse the response bytes according to the OBD-II PID formula for that PID
To read diagnostic trouble codes, send 03 (request stored DTCs); parse each 2-byte code in the response and decode the first character from the byte's high nibble (0=P, 1=C, 2=B, 3=U)
Clear DTCs by sending mode 04; confirm the clear was accepted by re-querying mode 03 and verifying an empty or no-DTC response
Known gotchas
ELM327 clones (non-genuine chips) are extremely common and often have firmware bugs — they may silently drop bytes, misparse multi-frame ISO-TP responses, or fail on certain protocols; test against a known-good vehicle before blaming the vehicle
Multi-frame responses (ISO-TP / CAN frames longer than 7 bytes) require the adapter to handle flow control; if AT CFC (automatic flow control) is off, you must send flow control frames manually or you will receive only the first frame of long responses
Not all PIDs are supported by all vehicles; a NO DATA response does not indicate an adapter error — it means the ECU did not respond to that PID, so always handle NO DATA, ?, and UNABLE TO CONNECT responses gracefully
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp