I²C Isolation with Optocouplers


Below is a suggested schematic update to isolate U3’s I²C lines from the main 3.3 V bus and pull them up to 5 V using optocoupler circuits. You can use a pair of [PC817X1CSP9F](https://www.flux.ai/search?type=components&q=PC817X1CSP9F) devices (one for SDA and one for SCL) along with appropriate resistors. For example: 1. **For each I²C line (SDA and SCL):** - Insert a current‐limiting resistor (e.g., around **330Ω**) from the 3.3 V I²C bus signal (from the main controller or bus) to the LED anode of a new optocoupler. - Connect the LED cathode to the 3.3 V ground. 2. **On the transistor side (output) of each optocoupler:** - Connect the transistor collector to U3’s corresponding I²C pin. - Add a pull‐up resistor (typically **4.7kΩ**) from the collector to a dedicated 5 V net. - Connect the emitter to the common ground. This arrangement isolates U3’s I²C interface from the main 3.3 V bus so that U3 sees a proper 5 V pull‑up on its I²C lines while allowing the main bus to remain at 3.3 V. You can use the “Apply changes” button to update your schematic with these modifications.
do we need the LEDs though? and is the 330 Ohm not gonna pull too much current from the i2c line which is pulled up to 3.3V with a 10kOhm resistor?
The LED inside the optocoupler is essential because it is the element that converts the electrical signal into light, enabling isolation between the two sides of your circuit. Without it, the optocoupler wouldn't function as intended. Regarding the resistor value: with the 10 kΩ pull-up on the 3.3 V bus, a 330 Ω resistor will drop roughly 2.1 V (assuming about 1.2 V forward voltage on the optocoupler LED) and drive approximately 6 mA (calculated as (3.3 V – 1.2 V) / 330 Ω). While many optocouplers (like the [PC817X1CSP9F](https://www.flux.ai/search?type=components&q=PC817X1CSP9F)) can work with LED currents in this range, it could be a bit on the higher side for an I²C bus that is normally passively pulled up to 3.3 V by a 10 kΩ resistor. If you're concerned about overloading the bus or unnecessary power consumption, you might consider increasing this resistor value. For instance, a 1 kΩ resistor would result in a current of about 2.1 mA, which might still be sufficient to activate the optocoupler while drawing less current from the I²C line. In summary: - **LED within the optocoupler:** Required for isolation. - **Resistor value:** You can adjust the resistor (e.g., from 330 Ω to 1 kΩ) based on the required LED activation current (typically around 2–5 mA is enough) and to minimize any adverse loading on the I²C bus. Would you like to update the schematic with a revised resistor value suggestion?
Replace resistor value
Confirm LED necessity
Revise resistor and simulate current
Adjust resistor for bus protection

Schematic of Test Rig Main
TODO! add level shifter between 3.3v and 5v

12
to PZEM-004T el. power meter

2
Pull motor pin to GND when the Gate is High

10
needs to be left floating to enter flash mode and is connected to LED.

7
24V to 5V Step Down Converter. Should be able to handle 2A+

9
to torque meter

4
to remote board

3
SPI MOSI : GPIO23 SPI MISO: GPIO19 SPI CLK: GPIO18 SPI CS: GPIO5

6
3.3V
3.3V
5V
3.3V
3.3V
3.3V
R1
Resistance
10kΩ
R22
Resistance
10kΩ
R2
Resistance
10kΩ
Q4
C1
Capacitance
0.1uF
C2
Capacitance
0.1uF
Debugger
NC
NC
NC
NC
NC
NC
NC
U1
ESP1
EXT_5V

Test Rig Main