Skip to content

About

OBD2 K-line Reader (ISO9141 and ISO14230) with microcontrollers like ESP32, Arduino.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

235 stars

Watchers

3 watching

Forks

Latest commit

Β 

History

300 Commits

Folders and files

OBD2 K-Line Reader – open-source ESP32 and Arduino car diagnostic scanner for ISO 9141-2 and KWP2000 (ISO 14230)

OBD2 K-Line Reader

Open-source car diagnostic tool for ESP32, ESP8266 & Arduino.
Read live sensor data, read & clear trouble codes (DTCs), freeze-frame data and VIN from any K-Line vehicle
over ISO 9141-2 and KWP2000 (ISO 14230), straight from a web dashboard in your phone's browser.

GitHub stars GitHub forks GitHub issues GPL-3.0 license Last commit

ESP32 ESP8266 Arduino STM32 Raspberry Pi Pico RP2040 ISO 9141-2 KWP2000 ISO 14230 Sponsored by PCBWay

Features Β· Demo Β· Screenshots Β· How It Works Β· Hardware Β· Quick Start Β· FAQ Β· Custom Development


πŸ“– About

OBD2 K-Line Reader is complete, ready-to-flash firmware that turns a cheap microcontroller into a DIY OBD-II scan tool for vehicles that use the K-Line diagnostic bus. That covers most European and Asian cars built between roughly 2000 and 2010, before CAN became mandatory.

Plug it into the car's OBD-II port and you get real-time engine data, diagnostic trouble codes (read and clear), freeze-frame snapshots, VIN and ECU calibration IDs, a 0–100 km/h acceleration timer and battery voltage, all without an ELM327 adapter, PC software or a paid app.

It comes in two builds:

Build Best for Output Boards
🌐 WebServer_Code A standalone WiFi scan tool Mobile-friendly web dashboard (WebSocket), OTA updates ESP32 (incl. S3 / C3 / C6), ESP8266
πŸ–₯️ Basic_Code Quick tests, learning, porting Serial Monitor Arduino Uno / Nano / Pro Mini, ESP32

The project also includes six interface schematics, from a two-transistor circuit to dedicated automotive transceivers (L9637D, MC33290, Si9241, SN65HVDA195), so you can build the hardware for a few dollars.

Tip

If this project saves you a trip to the mechanic or helps you learn how cars talk, please give it a ⭐. It helps other makers find it.

🎬 See It in Action

Animated demo of the OBD2 K-Line Reader web dashboard: live data, trouble codes, freeze frame, 0-100 km/h speed test, vehicle info, settings and dark mode

A full scan tool in your pocket

The ESP32 hosts its own WiFi network. Connect your phone, open 192.168.4.1, and every diagnostic function is one tap away:

  • πŸ“Š Live Data: real-time PIDs streamed over WebSocket
  • ⚠️ Trouble Codes: read and clear DTCs, with ~1,000 built-in descriptions
  • ❄️ Freeze Frame: the sensor snapshot taken when the fault was logged
  • 🏁 0–100 km/h Test: starts and stops on its own, driven by the vehicle speed PID
  • πŸš— Vehicle Info: VIN, calibration ID and supported PID maps
  • βš™οΈ Settings: protocol, PID picker, WiFi and OTA firmware update
  • πŸŒ™ Dark Mode, remembered on each device

No app to install and no cloud. Works on Android, iOS and desktop browsers.

✨ Features

🩺 Diagnostics

  • Live sensor data (OBD-II Mode 01)
  • Freeze-frame data (Mode 02)
  • Stored DTCs (Mode 03)
  • Clear DTCs / reset MIL (Mode 04)
  • Pending DTCs (Mode 07)
  • VIN and calibration IDs (Mode 09)
  • ~1,000 DTC descriptions (P, C, B, U)
  • Battery voltage monitor

πŸ“‘ Protocols

  • ISO 9141-2 (5-baud init)
  • ISO 14230-4 KWP2000 slow init
  • ISO 14230-4 KWP2000 fast init
  • Automatic protocol detection
  • Protocol switchable at runtime
  • Auto-reconnect when the link drops
  • Correct 10.4 kbaud timing, echo cancellation and checksums

πŸ› οΈ Platform

  • ESP32 / S3 / C3 / C6, ESP8266
  • Arduino Uno, Nano, Pro Mini
  • Portable to STM32 and RP2040
  • WiFi Access Point or Station mode
  • OTA firmware updates (ESP32)
  • Settings stored in SPIFFS
  • Buzzer and LED status feedback
  • Six hardware interface options

πŸ“± Web Dashboard Screenshots

Screenshots switch between light and dark to match your GitHub theme.
OBD2 dashboard main menu with battery voltage
Main Menu
Battery voltage and quick access
Live OBD2 sensor data: RPM, coolant temperature, engine load, fuel trims, MAF
Live Data
Real-time sensor PIDs
Read and clear OBD2 diagnostic trouble codes (DTC) such as P0171 and P0420
Trouble Codes
Read and clear DTCs
OBD2 freeze frame data captured when a fault code was stored
Freeze Frame
Snapshot at fault time
0-100 km/h acceleration timer using the OBD2 vehicle speed PID
0–100 km/h Test
Automatic acceleration timer
Vehicle info page showing VIN, calibration ID and supported PIDs
Vehicle Info
VIN, CAL ID, supported PIDs
Settings page: dark mode, communication protocol selection and PID picker
Settings
Protocol, PIDs, WiFi, OTA
OBD2 Master splash screen
Splash Screen
Branded boot animation

Note

The dashboard front-end is developed in its own repository: OBD2 Diagnostic UI. A pre-built, gzipped copy ships in WebServer_Code/data.

🧭 How It Works

flowchart LR
    ECU["πŸš— Vehicle ECU"] <-->|"K-Line Β· OBD-II pin 7<br/>12 V Β· 10.4 kbaud"| IF["πŸ”Œ K-Line interface<br/>L9637D Β· MC33290 Β· LM393 Β· transistors"]
    IF <-->|"UART RX / TX<br/>3.3 V or 5 V logic"| MCU["🧠 Microcontroller<br/>ESP32 · ESP8266 · Arduino"]
    MCU -->|"USB serial"| PC["πŸ’» Serial Monitor<br/>Basic_Code"]
    MCU -->|"WiFi Β· WebSocket"| WEB["πŸ“± Browser dashboard<br/>WebServer_Code"]
Loading
  1. Wake-up. The firmware wakes the ECU with a 5-baud init (address 0x33) or a fast init (25 ms low / 25 ms high pulse followed by StartCommunication: C1 33 F1 81 66).
  2. Detect. In Automatic mode it tries ISO 9141-2, then KWP2000 slow and fast init, and remembers whichever protocol the ECU answers on.
  3. Request. Standard OBD-II service requests (Modes 01, 02, 03, 04, 07 and 09) are framed with the right header (68 6A F1 for ISO 9141 or Cx 33 F1 for KWP2000) plus a checksum.
  4. Decode. Responses are validated, the K-Line echo is removed, and the values are converted to engineering units using the SAE J1979 formulas.
  5. Publish. Values go to the Serial Monitor, or to the web dashboard as JSON over a WebSocket about every 100 ms.

πŸ“‘ Supported Protocols

Protocol Standard Initialization Header Status
ISO 9141-2 ISO 9141-2 5-baud slow init 68 6A F1 βœ… Tested
KWP2000 (slow init) ISO 14230-4 5-baud slow init Cx 33 F1 βœ… Tested
KWP2000 (fast init) ISO 14230-4 25 ms wake-up pattern Cx 33 F1 βœ… Tested
Auto-detect none Tries all of the above none βœ… Default

Important

Does my car use K-Line? Look at your OBD-II socket. If pin 7 has a metal contact, the car very likely speaks ISO 9141-2 or KWP2000. Cars that only have pins 6 and 14 use CAN (ISO 15765-4); for those, see OBD2 CAN Bus Reader.

πŸ”§ Hardware

What you need

Part Notes
Microcontroller ESP32 / ESP32-S3 / C3 / C6 or ESP8266 for the web dashboard; Arduino Uno / Nano / Pro Mini or ESP32 for Basic_Code
K-Line interface Any circuit from the schematics below
OBD-II male connector Or a cut OBD-II extension cable
12 V β†’ 5 V / 3.3 V regulator A small buck converter to power the board from OBD-II pin 16
Optional Buzzer and LED for status feedback, 47 kΞ© / 10 kΞ© divider for battery voltage

OBD-II connector pinout (K-Line)

OBD-II pin Signal Connect to
7 K-Line (ISO 9141-2 / ISO 14230) K pin of the interface
16 Battery +12 V (permanent) Interface VBAT + regulator input
4 / 5 Chassis / signal ground Common GND

πŸ”Œ Interface Schematics

K-Line is a single-wire, 12 V, open-collector bus, so it can't be wired straight to a 3.3 V or 5 V UART. Each circuit below does the level shifting and protection. Pick one.

Transistor-based β€” cheapest, great for prototyping

K-Line to UART interface schematic using discrete transistors

Built from discrete transistors, so it costs almost nothing. R6 is sized for 3.3 V microcontrollers; for a 5 V MCU, change R6 to 5.3 kΞ©.

Comparator-based (LM393) β€” better noise immunity

K-Line interface schematic using an LM393 comparator

A cheap comparator such as the LM393 gives a clean digital level with well-defined thresholds. It needs a few more parts than the transistor version but is noticeably more robust.

Dedicated automotive transceivers β€” L9637D, MC33290, Si9241, SN65HVDA195

L9637D K-Line transceiver schematic MC33290 ISO 9141 K-Line transceiver schematic

Si9241 K-Line transceiver schematic SN65HVDA195 LIN / K-Line transceiver schematic

Purpose-built ISO 9141 transceivers with built-in level shifting and protection. They are standards-compliant and the most reliable choice, which makes them the right pick for permanent and production designs.

🧩 Custom PCBs

MUKITECH OBD2 Diagnostic Tool v1.0 K-Line board with ESP32-C3 module and OBD-II enclosure ESP32 K-Line diagnostic board with buzzer, USB-C and 3D-printed enclosure MUKITECH OBD2 diagnostic dongle PCB with ESP32-S3 and orange enclosure

PCBWay logo The custom PCBs in this project were manufactured with sponsorship from PCBWay. Board quality, fast delivery and support were excellent, and I'm grateful for their help. Need boards for your own project? Check out PCBWay β†’

πŸš€ Quick Start

git clone https://github.com/muki01/OBD2_K-line_Reader.git
  1. Build the interface using one of the schematics and wire it to your board's UART.
  2. Choose a build and follow its step-by-step guide:
  3. Plug into the OBD-II port, turn the ignition on, and wait a few seconds for the handshake.
  4. Web build: join the WiFi network OBD2 Master (password 12345678) and open http://192.168.4.1.

Default pins

Board K-Line RX K-Line TX UART LED Buzzer Battery ADC
ESP32 / ESP32-S3 (WebServer & Basic) GPIO 10 GPIO 11 Serial1 GPIO 6 GPIO 8 (web) GPIO 1 (web)
ESP8266 (WebServer) GPIO 3 GPIO 1 Serial (UART0) GPIO 2 GPIO 4 GPIO 5
Arduino Uno / Nano / Pro Mini (Basic) D8 D9 AltSoftSerial D13 none none

Note

GPIO 10 / 11 fit ESP32-S3 / C3 / C6 boards. On a classic ESP32-WROOM they are connected to the SPI flash, so pick other free pins there (for example GPIO 16 / 17) by editing the #defines at the top of the sketch.

πŸ—‚οΈ Repository Structure

OBD2_K-line_Reader/
β”œβ”€β”€ WebServer_Code/        # ESP32 / ESP8266 firmware with WiFi web dashboard + OTA
β”‚   β”œβ”€β”€ data/              # Gzipped web UI (upload to SPIFFS)
β”‚   └── README.md          # Setup guide
β”œβ”€β”€ Basic_Code/            # Serial Monitor firmware for Arduino & ESP32
β”‚   └── README.md          # Setup guide
β”œβ”€β”€ Schematics/            # K-Line interface circuits (transistor, LM393, L9637D, MC33290, ...)
└── images/                # Banner, demo GIF and screenshots

❓ FAQ

What is K-Line?
K-Line is a single-wire, bidirectional serial bus on pin 7 of the OBD-II connector. It runs at 10.4 kbaud with 12 V logic levels and carries two diagnostic protocols: ISO 9141-2 and ISO 14230 (KWP2000). It was the dominant diagnostic bus on European and Asian vehicles until CAN (ISO 15765-4) replaced it.
Which cars are supported?
Any vehicle whose engine ECU answers generic OBD-II requests over ISO 9141-2 or KWP2000. In practice that is most European and Asian petrol cars from about 2000 to 2010, plus many diesels. Check that pin 7 of your OBD-II socket is populated. Manufacturer-specific protocols such as VAG KW1281 or BMW I/K-Bus are handled in related projects.
Is this an ELM327 replacement? Does it work with Torque or Car Scanner?
It replaces the ELM327 for K-Line vehicles, but it does not emulate the ELM327 AT command set, so third-party ELM327 apps won't connect to it. It comes with its own web dashboard (no app needed) and a Serial Monitor build that you can easily extend or integrate.
What is the difference between ISO 9141-2 and KWP2000?
Both run on the same physical K-Line at 10.4 kbaud. ISO 9141-2 always starts with a slow 5-baud init and uses the 68 6A F1 header. KWP2000 (ISO 14230) supports both slow and fast init, uses length-encoded headers (Cx 33 F1) and adds richer services. Leave the firmware on Automatic and it figures this out for you.
Can I clear the check-engine light (MIL)?
Yes. Clear Error Codes sends OBD-II Mode 04, which clears stored DTCs, freeze-frame data and the MIL. Fix the underlying fault first, or the code will come back.
Can I use it with my CAN-bus car?
Not with this firmware. Use the sister project OBD2 CAN Bus Reader, which shares the same web dashboard.

🀝 Contributing

Contributions are welcome: bug reports, new PIDs, tested vehicle reports, new board ports and documentation fixes. Please read the Contributing Guide and our Code of Conduct.

Tested it on your car? Open an issue with the make, model, year and detected protocol. Real-world compatibility reports help everyone.

πŸ”— Related Projects

This firmware is part of a family of open-source automotive projects. They share the same hardware approach, so what you build for one carries over to the others.

Firmware β€” flash it and use it
BMW I-Bus / K-Bus Firmware Phone control and key-fob light functions for the BMW E46, on the ESP32 and Arduino. GitHub stars of BMW_IBus_KBus
OBD2 K-Line Reader
you are here
Scan tool for K-Line cars (ISO 9141-2, KWP2000) with a web dashboard, for the ESP32, ESP8266 and Arduino. GitHub stars of OBD2_K-line_Reader
OBD2 CAN Bus Reader Scan tool for CAN bus cars (ISO 15765-4) with the same web dashboard, for the ESP32. GitHub stars of OBD2_CAN_Bus_Reader
VAG KW1281 KW1281 diagnostics for VW, Audi, Ε koda and SEAT: ECU information, measuring groups and fault codes. GitHub stars of VAG_KW1281
Libraries β€” build your own firmware
BMW IBus KBus Library Receives, checks and sends BMW I-Bus and K-Bus messages; the library behind the BMW firmware. GitHub stars of BMW_IBus_KBus_Library
OBD2 K-Line Library K-Line diagnostics behind one API: ISO 9141-2, KWP2000, KW1281, DS2 and KW82. GitHub stars of OBD2_KLine_Library
OBD2 CAN Bus Library OBD-II diagnostics over ISO 15765-4 with the ESP32's built-in CAN controller. GitHub stars of OBD2_CAN_Bus_Library
Interface
OBD2 Diagnostic UI The web dashboard used by the two OBD2 readers. GitHub stars of OBD2-Diagnostic-UI

πŸ’‘ Building your own firmware? The OBD2 K-Line Library wraps the K-Line protocol in a clean Arduino API.

πŸ’Ό Custom Development

I design automotive diagnostic tools, firmware and hardware professionally. Whether you need a complete product or only the communication layer, I can help.

Service Details
Protocol implementation BMW I/K-Bus, K-Line (ISO 9141-2 / KWP2000), CAN / UDS, VAG KW1281 and other manufacturer-specific protocols
ECU communication & reverse engineering Bus sniffing, packet decoding, module control, undocumented ECUs and buses
ECU security access Seed-key algorithms and unlock routines for KWP2000 / UDS
Embedded firmware Arduino, ESP32, ESP8266, STM32, Raspberry Pi Pico
Custom hardware Diagnostic dongles, shields and PCBs designed to your requirements
Companion apps Android, iOS and web apps to visualise, log and control your device

Have a project in mind? Reach out through the Contact section below.

πŸ“¬ Contact

For custom development, collaboration, sponsorship or ready-made devices:

Channel Address
πŸ“§ Email muksin.muksin04@gmail.com
πŸ’Ό LinkedIn linkedin.com/in/muksin-muksin
πŸ™ GitHub @muki01

β˜• Support the Project

If this project helped you, consider supporting its development:

Buy Me a Coffee Donate with PayPal GitHub Sponsors

πŸ“ˆ Star History

Star history chart for OBD2 K-Line Reader

⚠️ Disclaimer

Warning

This is a hobby and educational project provided as is, without warranty. Connecting custom hardware to a vehicle carries risk. The author is not responsible for any damage to vehicles, ECUs or equipment. Never operate the device or look at the dashboard while driving. Run the acceleration test only on closed roads or private property, in line with local law.

πŸ“„ License

Released under the GNU General Public License v3.0.

  • You are free to use, study, modify and share this firmware.
  • If you distribute it β€” on its own or as part of a product or firmware β€” you must make the complete source available under the same license.

Closed-source or commercial product? A separate commercial license is available. Get in touch through the Contact section.

Copyright Β© 2023–2026 Muksin Muksin.


Created by Muki · If this project helped you, please give it a ⭐

OBD2 Β· OBD-II Β· K-Line Β· KWP2000 Β· ISO 9141-2 Β· ISO 14230 Β· ESP32 Β· ESP8266 Β· Arduino Β· car diagnostics Β· DTC reader Β· scan tool

⬆ Back to top

About

OBD2 K-line Reader (ISO9141 and ISO14230) with microcontrollers like ESP32, Arduino.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

235 stars

Watchers

3 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages