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.
R2 Change from Original Design
Section titled “R2 Change from Original Design”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.
Required Components
Section titled “Required Components”| Ref | Value | Package | Qty | Notes |
|---|---|---|---|---|
| U1, U2 | PC817A+ | DIP-4 | 2 | Optocoupler, any grade (A/B/C/D). PC817A works; B+ adds margin |
| Q1 | BC547 | TO-92 | 1 | Or 2N3904. TX LED driver |
| R1 | 2k | 0805/TH | 1 | RX LED current limiter |
| R2 | 220 | 0805/TH | 1 | TX LED current limiter (reduced from 470 for 3.3V ESP32) |
| R3 | 10k | 0805/TH | 1 | Q1 base resistor |
| R4 | 1k | 0805/TH | 1 | RX pull-down (defines LOW when opto OFF) |
| R5 | 470 | 0805/TH | 1 | TX input series resistor |
| D1 | 1N4007 | DO-41 | 1 | Reverse polarity protection, 12V bridge |
| U3 | ESP32-C3 | Module | 1 | Any ESP32 with hardware UART |
| J1 | Bus connector | — | 1 | OBD-II, roundel, or direct wire to CD changer connector |
Optional for Permanent Install
Section titled “Optional for Permanent Install”- 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
Component Notes
Section titled “Component Notes”PC817 Grades
Section titled “PC817 Grades”The PC817 is available in four CTR (Current Transfer Ratio) grades:
| Grade | CTR Range | Notes |
|---|---|---|
| PC817A | 80-160% | Cheapest, most common. Works with R2=220 |
| PC817B | 130-260% | Extra margin, drop-in replacement |
| PC817C | 200-400% | More than needed for this circuit |
| PC817D | 300-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.
Q1 Substitutes
Section titled “Q1 Substitutes”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.
Resistor Packages
Section titled “Resistor Packages”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.
Bus Connector Options
Section titled “Bus Connector Options”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.
Parasitic Drain
Section titled “Parasitic Drain”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.