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.
Features Β· Demo Β· Screenshots Β· How It Works Β· Hardware Β· Quick Start Β· FAQ Β· Custom Development
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.
|
|
|
![]() Main Menu Battery voltage and quick access |
![]() Live Data Real-time sensor PIDs |
![]() Trouble Codes Read and clear DTCs |
![]() Freeze Frame Snapshot at fault time |
![]() 0β100 km/h Test Automatic acceleration timer |
![]() Vehicle Info VIN, CAL ID, supported PIDs |
![]() Settings Protocol, PIDs, WiFi, OTA |
![]() 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.
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"]
- 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 byStartCommunication:C1 33 F1 81 66). - Detect. In
Automaticmode it tries ISO 9141-2, then KWP2000 slow and fast init, and remembers whichever protocol the ECU answers on. - Request. Standard OBD-II service requests (Modes 01, 02, 03, 04, 07 and 09) are framed with the right header (
68 6A F1for ISO 9141 orCx 33 F1for KWP2000) plus a checksum. - Decode. Responses are validated, the K-Line echo is removed, and the values are converted to engineering units using the SAE J1979 formulas.
- Publish. Values go to the Serial Monitor, or to the web dashboard as JSON over a WebSocket about every 100 ms.
| 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.
| 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 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 |
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.
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Ξ©.
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.
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.
|
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 β |
git clone https://github.com/muki01/OBD2_K-line_Reader.git- Build the interface using one of the schematics and wire it to your board's UART.
- Choose a build and follow its step-by-step guide:
- π WebServer_Code: setup guide (ESP32 / ESP8266 web dashboard)
- π₯οΈ Basic_Code: setup guide (Arduino / ESP32 Serial Monitor)
- Plug into the OBD-II port, turn the ignition on, and wait a few seconds for the handshake.
- Web build: join the WiFi network
OBD2 Master(password12345678) and open http://192.168.4.1.
| 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.
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
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.
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.
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. | |
| 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. | |
| OBD2 CAN Bus Reader | Scan tool for CAN bus cars (ISO 15765-4) with the same web dashboard, for the ESP32. | |
| VAG KW1281 | KW1281 diagnostics for VW, Audi, Ε koda and SEAT: ECU information, measuring groups and fault codes. | |
| 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. | |
| OBD2 K-Line Library | K-Line diagnostics behind one API: ISO 9141-2, KWP2000, KW1281, DS2 and KW82. | |
| OBD2 CAN Bus Library | OBD-II diagnostics over ISO 15765-4 with the ESP32's built-in CAN controller. | |
| Interface | ||
| OBD2 Diagnostic UI | The web dashboard used by the two OBD2 readers. | |
π‘ Building your own firmware? The OBD2 K-Line Library wraps the K-Line protocol in a clean Arduino API.
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.
For custom development, collaboration, sponsorship or ready-made devices:
| Channel | Address |
|---|---|
| π§ Email | muksin.muksin04@gmail.com |
| πΌ LinkedIn | linkedin.com/in/muksin-muksin |
| π GitHub | @muki01 |
If this project helped you, consider supporting its development:
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.
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


















