Skip to content

Bill of Materials

Components for the PC817 optocoupler interface between a 12V automotive bus (BMW I-Bus or K-Bus) and a 3.3V ESP32 microcontroller.

The original muki01/I-K_Bus schematic specifies R2=470 ohm, designed for 5V Arduino. At 3.3V, the TX LED current drops from ~7.9mA to ~4.3mA — insufficient to saturate the phototransistor against bus impedances below 2k ohm. SPICE parameter sweeps identified R2=220 ohm as the fix. This doubles the LED current to 9.71mA (still only 19% of the PC817’s 50mA max rating), supporting bus pull-ups down to ~530 ohm. See the circuit design reference for full sweep data and validation results.

RefValuePackageQtyNotes
U1, U2PC817A+DIP-42Optocoupler, any grade (A/B/C/D). PC817A works; B+ adds margin
Q1BC547TO-921Or 2N3904. TX LED driver
R12k0805/TH1RX LED current limiter
R22200805/TH1TX LED current limiter (reduced from 470 for 3.3V ESP32)
R310k0805/TH1Q1 base resistor
R41k0805/TH1RX pull-down (defines LOW when opto OFF)
R54700805/TH1TX input series resistor
D11N4007DO-411Reverse polarity protection, 12V bridge
U3ESP32-C3Module1Any ESP32 with hardware UART
J1Bus connector1OBD-II, roundel, or direct wire to CD changer connector
  • Voltage regulator: AMS1117-3.3 or MP1584 buck converter for 12V to 3.3V
  • Decoupling caps: 10uF + 100nF ceramic on the 3.3V rail
  • TVS diode: SMBJ16A on the bus line for transient protection
  • Status LED: On a spare GPIO (not in the signal path) for activity indication

The PC817 is available in four CTR (Current Transfer Ratio) grades:

GradeCTR RangeNotes
PC817A80-160%Cheapest, most common. Works with R2=220
PC817B130-260%Extra margin, drop-in replacement
PC817C200-400%More than needed for this circuit
PC817D300-600%Overkill, but harmless

With R2=220 ohm, even worst-case PC817A pulls the bus below 0.27V against a 1k ohm pull-up. Higher grades provide additional margin with no circuit changes — same pinout, same package.

BC547 and 2N3904 are interchangeable here. Both are general-purpose NPN transistors with sufficient gain (hFE > 100) and collector current rating (> 100mA) for driving the U2 LED. The base current through R3 (10k) is approximately 0.2mA, so any small-signal NPN with hFE > 50 will saturate.

All resistors work in either 0805 SMD or through-hole. For breadboard prototyping, through-hole is more convenient. For a permanent PCB, 0805 keeps the board compact. No precision requirements — 5% tolerance is fine for all values.

The connection to the BMW bus depends on the installation point:

  • CD changer connector (E46 trunk, driver’s side): Connector X18180. K-Bus wire is White/Red with Yellow dots. Ground is Brown. 12V is Red/Green.
  • K-Bus junction block (above fuse box): Same K-Bus wire color. Use a separate 12V and GND source.
  • OBD-II port: Pins vary by model. Check vehicle-specific documentation.
  • Direct wire: Solder to a bus node with appropriate strain relief.

The interface draws approximately 5.4mA continuously from the bus 12V through R1 (the U1 RX LED is always on when the bus is at idle voltage). U2’s LED only draws current during TX (~9.7mA pulses). For long-term parking, either disconnect the interface or add a MOSFET sleep circuit on R1, controlled by a GPIO or the vehicle’s terminal 15 (ignition accessory) signal.