HEX to OBD Code Conversion: Complete Guide
Why Two Different Formats?
When working with ECU firmware and vehicle diagnostics, you will encounter two different formats for the same error codes:
- HEX format (0420) β How codes are stored internally in ECU memory
- OBD format (P0420) β How codes are displayed in diagnostic scanners
They represent the same error, just in different notation. For example, the catalytic converter efficiency code appears as 0420 in firmware files and P0420 in your scan tool.
Understanding the Formats
HEX Format (Firmware Internal)
- 4-digit hexadecimal code
- Examples:
0420,0115,C100 - Used directly in ECU memory and firmware files
- First digit determines error category
OBD Format (Diagnostic Display)
- 5-digit alphanumeric code
- Format: Prefix + Type + 3 digits
- Examples:
P0420,P0115,U0100 - Used in diagnostic tools and documentation
Conversion Reference Table
The conversion follows a pattern based on the first digit of the HEX code. Here is the complete conversion table:
| HEX First Digit | OBD Prefix | OBD Type | Example HEX | Example OBD | Category | Description |
|---|---|---|---|---|---|---|
| 0 | P | 0 | 0123 | P0123 | Powertrain | SAE Standardized |
| 1 | P | 1 | 1234 | P1234 | Powertrain | Manufacturer-specific |
| 2 | P | 2 | 2AAA | P2AAA | Powertrain | Manufacturer-specific |
| 3 | P | 3 | 3FFF | P3FFF | Powertrain | Reserved |
| 4 | C | 0 | 4050 | C0050 | Chassis | SAE Standardized |
| 5 | C | 1 | 5201 | C1201 | Chassis | Manufacturer-specific |
| 6 | C | 2 | 6789 | C2789 | Chassis | Manufacturer-specific |
| 7 | C | 3 | 7ABC | C3ABC | Chassis | Manufacturer-specific |
| 8 | B | 0 | 8001 | B0001 | Body | SAE Standardized |
| 9 | B | 1 | 9234 | B1234 | Body | Manufacturer-specific |
| A | B | 2 | A456 | B2456 | Body | Manufacturer-specific |
| B | B | 3 | B789 | B3789 | Body | Manufacturer-specific |
| C | U | 0 | C100 | U0100 | Network | SAE Standardized |
| D | U | 1 | D140 | U1140 | Network | Manufacturer-specific |
| E | U | 2 | E234 | U2234 | Network | Manufacturer-specific |
| F | U | 3 | F456 | U3456 | Network | Manufacturer-specific |
Note: This table shows every possible conversion from HEX to OBD format based on the first digit.
Detailed Category Breakdown
0x0-0x3: Powertrain (P-codes)
P0xxx β SAE standardized (common across all manufacturers)
- P0115: Engine Coolant Temperature Sensor
- P0300: Random/Multiple Cylinder Misfire
- P0420: Catalytic Converter Efficiency
P1xxx β Manufacturer-specific
- P1234: Varies by vehicle make
P2xxx-P3xxx β Additional manufacturer codes
0x4-0x7: Chassis (C-codes)
C0xxx β SAE standardized (chassis systems)
- C0050: Right Front Wheel Speed Sensor
C1xxx-C3xxx β Manufacturer-specific
0x8-0xB: Body (B-codes)
B0xxx β SAE standardized (body systems)
- B0001: Driver Airbag Circuit
B1xxx-B3xxx β Manufacturer-specific
0xC-0xF: Network (U-codes)
U0xxx β SAE standardized (network communication)
- U0100: Lost Communication With ECM/PCM
- U0140: Lost Communication With Body Control Module
U1xxx-U3xxx β Manufacturer-specific
Step-by-Step Conversion Examples
Example 1: HEX "0420" β OBD "P0420"
1. Input: "0420"
2. First digit: "0"
3. Prefix: 0 β "P"
4. Type: 0 β "0"
5. Last 3 digits: "420"
6. Result: "P" + "0" + "420" = "P0420"
Meaning: Catalytic Converter Efficiency Below Threshold (SAE Standardized)
Example 2: HEX "5201" β OBD "C1201"
1. Input: "5201"
2. First digit: "5"
3. Prefix: 5 β "C"
4. Type: 5 β "1"
5. Last 3 digits: "201"
6. Result: "C" + "1" + "201" = "C1201"
Meaning: Chassis manufacturer-specific code
Example 3: HEX "C100" β OBD "U0100"
1. Input: "C100"
2. First digit: "C"
3. Prefix: C β "U"
4. Type: C β "0"
5. Last 3 digits: "100"
6. Result: "U" + "0" + "100" = "U0100"
Meaning: Lost Communication With ECM/PCM (SAE Standardized)
Example 4: HEX "1234" β OBD "P1234"
1. Input: "1234"
2. First digit: "1"
3. Prefix: 1 β "P"
4. Type: 1 β "1"
5. Last 3 digits: "234"
6. Result: "P" + "1" + "234" = "P1234"
Meaning: Powertrain manufacturer-specific code (varies by vehicle make)
Practical Usage
When Reading ECU Firmware:
- Open firmware file in hex editor or analyzer
- Locate DTC table in memory
- Codes appear in HEX format:
0420,0115,1234
When Using Diagnostic Scanner:
- Connect OBD-II scanner to vehicle
- Read stored diagnostic codes
- Codes appear in OBD format:
P0420,P0115,P1234
When Removing Codes with Firmware Analyzer:
Our Firmware Analyzer accepts both formats, so you can enter codes exactly as you see them:
- From firmware editor: enter
0420 - From scan tool: enter
P0420 - Both will match the same error in the firmware
IMPORTANT: BMW Codes vs OBD Codes
BMW Has Two Separate Code Tables
Critical Information: BMW vehicles use TWO SEPARATE error code systems:
-
BMW-specific codes (stored in Primary/Secondary tables)
- 4-digit codes unique to BMW
- Examples:
4AB3,5F2D,CD3A - NO OBD equivalent exists
- These are proprietary BMW diagnostic codes
-
OBD-II codes (stored in OBD tables)
- Standard 4-digit HEX codes
- Follow HEX β OBD conversion rules
- Examples:
0420βP0420,C100βU0100
Why This Matters for Firmware Analysis
When using our Firmware Analyzer, you will see two separate input fields:
- BMW Codes field β For BMW-specific codes (NO conversion applied)
- OBD Codes field β For standard OBD codes (conversion applied)
Example:
BMW Code Input:
4AB3 β Stays as "4AB3" (no OBD equivalent)
5F2D β Stays as "5F2D" (BMW-specific)
OBD Code Input:
0420 β Converts to "P0420" for matching
P0420 β Works directly
C100 β Converts to "U0100" for matching
How to Know Which Field to Use?
Use BMW Codes field when:
- Code appears in BMW diagnostic software (ISTA, INPA, etc.)
- Code has 4 digits but doesn't follow standard patterns
- Code contains letters A-F in unusual positions
- No OBD equivalent can be found
Use OBD Codes field when:
- Code appears in generic OBD-II scanner
- Code starts with P, C, B, or U prefix
- Code follows SAE J2012 standard
- Code is documented in OBD databases
Technical Details
BMW Primary/Secondary Tables:
- Located at different memory addresses than OBD tables
- Use different encoding schemes
- Contain BMW-proprietary diagnostic information
- No conversion algorithm applies
OBD Tables:
- Follow SAE J2012 standard
- Use HEX β OBD conversion rules (as shown above)
- Located in standard OBD memory sections
- Compatible with generic scanners
Conversion Algorithm
HEX to OBD Conversion:
- Take first digit of HEX code
- Map to OBD prefix (0-3βP, 4-7βC, 8-BβB, C-FβU)
- Append remaining 3 digits
- Result:
0420βP0420
OBD to HEX Conversion:
- Remove OBD prefix (P/C/B/U)
- Take last 4 characters
- Result:
P0420β0420
Special Cases
Standardized vs Manufacturer Codes
SAE Standardized (P0xxx, C0xxx, B0xxx, U0xxx):
- Same meaning across all manufacturers
- International standards (SAE J2012)
- Reliable cross-reference
Manufacturer-Specific (P1xxx-P3xxx, etc.):
- Different meanings per manufacturer
- BMW P1234 β Mercedes P1234
- Consult manufacturer documentation
Why This Matters for Tuners
Understanding HEX/OBD conversion is crucial for:
- Firmware Analysis β Reading DTC tables in binary files
- Code Removal β Matching scanner codes to firmware codes
- Diagnostics β Understanding error origins
- Tool Development β Building custom diagnostic solutions
- Cross-Reference β Correlating firmware with scanner data
Best Practices
For Firmware Work:
- Always verify code format before removal
- Use both HEX and OBD references
- Document which codes were removed
- Keep backup of original firmware
For Diagnostics:
- Clear codes after firmware modifications
- Re-scan to verify removal
- Monitor for recurring codes
- Check related systems
Tools & Resources
Our Tools:
- Firmware Analyzer β Free DTC code analyzer for EDC16/17
- OBD Codes Database β Complete error code reference
External Resources:
- SAE J2012 Standard (official DTC specifications)
- Vehicle manufacturer technical documentation
- ECU manufacturer datasheets
Conclusion
Understanding the relationship between HEX codes in ECU firmware and OBD codes in diagnostic scanners is essential for modern automotive work. Whether you're analyzing firmware, removing DTCs, or developing diagnostic tools, this knowledge bridges the gap between raw binary data and user-friendly error codes.
The conversion is straightforward once you understand the pattern, and tools like our Firmware Analyzer make it even easier by accepting both formats automatically.
This guide is based on SAE J2012 standards, ECU manufacturer documentation, and practical firmware analysis experience.