This User Guide Covers: 2-Channel, 4-Channel, and 8-Channel Modules | Input 3.6V–24V | Output 3.6V–30V
Table of Contents
- What Is an Optocoupler and Why Use One?
- Module Overview
- Module Specifications
- Pin Descriptions
- Understanding the Jumper Settings
- How the Circuit Works
- Choosing the Right Input Resistor
- Wiring Hookup Diagrams
- Application Examples
- Arduino Example Code
- Important Design Considerations
- Troubleshooting
- PC817 IC Quick-Reference Specifications
- Frequently Asked Questions
- Tutorials and References
💡 What Is an Optocoupler and Why Use One?
An optocoupler (also called an opto-isolator or photocoupler) is a component that transfers an electrical signal between two isolated circuits using light. Inside the package, an infrared LED on the input side shines onto a phototransistor on the output side. Because the signal crosses as light — not through a wire — the two circuits share no electrical connection.
Why This Matters
- Electrical Isolation: Protects sensitive low-voltage electronics (Arduino, ESP32, Raspberry Pi) from high-voltage or noisy circuits (industrial sensors, PLCs, solenoids, motors)
- Noise Immunity: Eliminates ground loops and blocks electrical noise from crossing between circuits
- Voltage Level Shifting: Safely converts signals between different voltage domains (e.g., 24V industrial sensor → 3.3V microcontroller)
- Safety: Provides a galvanic isolation barrier rated up to 5,000 Vrms on the PC817
📦 Module Overview
These PC817 optocoupler isolation modules provide a convenient, pre-built breakout board that handles the supporting circuitry for you. Each module includes:
- PC817 optocoupler IC(s) — one per channel
- Current-limiting resistors on the input (LED) side
- Pull-up resistors on the output (phototransistor) side
- Screw terminals or pin headers for easy wiring
- Jumper for selecting the output pull-up configuration
- LED indicators — one per channel, showing input activation status
Available Configurations
| Module | Channels | Typical Board Size |
|---|---|---|
| 2-Channel | 2 isolated channels | ~50mm × 25mm |
| 4-Channel | 4 isolated channels | ~72mm × 25mm |
| 8-Channel | 8 isolated channels | ~100mm × 25mm |
Each channel is fully independent — you can use different input voltages and different output voltages on each channel simultaneously.

📊 Module Specifications
| Parameter | Value |
|---|---|
| Optocoupler IC | PC817 (1 per channel) |
| Input Voltage Range | 3.6V to 24V DC |
| Output Voltage Range | 3.6V to 30V DC |
| Isolation Voltage | 5,000 Vrms (per PC817 datasheet) |
| Channels | 2, 4, or 8 (fully independent) |
| Input Indicators | 1 LED per channel (lights when input is active) |
| Output Type | Open-collector (active LOW when triggered) |
| Connector Type | Pin headers (input & output sides) |
| Mounting | M3 mounting holes |
🏗️ Module Schematic
The schematic below shows one of the optocoupler channels. Each board has two, four, or eight of these channels, depending on the board model.

📌 Pin Descriptions
Input Side (Low-Voltage or High-Voltage Signal Side)
| Pin | Label | Description |
|---|---|---|
| VCC | Input Power (+) | Connect to the positive voltage of the input signal source (3.6V–24V) |
| GND | Input Ground (−) | Connect to the ground of the input signal source |
| IN1–INx | Signal Inputs | Each input pin triggers its corresponding channel. Active when pulled LOW (connected to GND through the signal source) |
Output Side (Isolated Side)
| Pin | Label | Description |
|---|---|---|
| VCC | Output Power (+) | Connect to the positive voltage of the output circuit (3.6V–30V) |
| GND | Output Ground (−) | Connect to the ground of the output circuit |
| OUT1–OUTx | Signal Outputs | Open-collector outputs. Active LOW when the corresponding input is triggered |
⚠️ Important: The input-side VCC/GND and output-side VCC/GND are completely separate power domains. Do NOT connect them together — this would defeat the purpose of isolation.
🔧 Understanding the Jumper Settings
The module includes a jumper (or solder bridge) that controls whether the on-board pull-up resistors on the output side are connected to the output VCC.
Jumper ON (Installed / Bridged)
- The output pull-up resistors are connected to the output-side VCC
- Output pins idle HIGH and go LOW when the corresponding input is activated
- Use this setting when connecting to a microcontroller's digital input pin (Arduino, ESP32, Raspberry Pi, etc.)
- This is the most common configuration
Jumper OFF (Removed / Open)
- The output pull-up resistors are disconnected
- The output pins are floating open-collector outputs
- Use this setting when you want to provide your own external pull-up resistor to a different voltage, or when interfacing with a circuit that already has its own pull-up
- Also useful when connecting to a PLC input that has its own internal pull-up/pull-down
⚡ How the Circuit Works
Understanding the internal circuit helps you wire the module correctly and troubleshoot issues.
Input Side (Per Channel)
Input VCC ──── [R_in (current-limiting resistor)] ──── [LED anode (+)]
│
Input Signal Pin (INx) ──────────────────── [LED cathode (−)]
When the input signal pin is pulled LOW (connected to input GND through your signal source), current flows through the resistor and the LED, causing it to emit infrared light. The on-board indicator LED also lights up.
Output Side (Per Channel)
Output VCC ──── [R_pull-up] ──── Output Pin (OUTx)
│
[Phototransistor Collector]
[Phototransistor Emitter]
│
Output GND
When the infrared LED is ON, the phototransistor turns ON (saturates), pulling the output pin LOW. When the LED is OFF, the phototransistor is OFF, and the pull-up resistor holds the output pin HIGH.
Signal Logic Summary
| Input Pin State | LED | Phototransistor | Output Pin |
|---|---|---|---|
| HIGH (no current) | OFF | OFF (open) | HIGH (pulled up) |
| LOW (current flows) | ON | ON (saturated) | LOW (pulled down) |
Note: The output is inverted relative to the input. Input LOW → Output LOW. Input HIGH → Output HIGH. (Both are active-LOW logic.)
🎯 Choosing the Right Input Resistor
The on-board input resistors are sized for a typical input voltage (usually around 5V–12V). If you're using a significantly different input voltage, you may want to verify the LED current is within the optimal range.
Calculating LED Forward Current
I_F = (V_input - V_F - V_indicator_LED) / R_input
Where:
- V_input = your input signal voltage
- V_F = PC817 LED forward voltage (~1.2V typical)
- V_indicator_LED = on-board indicator LED drop (~2.0V typical)
- R_input = on-board current-limiting resistor value
Recommended Operating Current
| Parameter | Value |
|---|---|
| Optimal I_F for reliable switching | 5mA–20mA |
| Minimum I_F for CTR spec | 5mA |
| Absolute Maximum I_F | 50mA (do not exceed) |
Example Calculations
5V Input with 1kΩ on-board resistor:
I_F = (5V - 1.2V - 2.0V) / 1000Ω = 1.8mA
This is on the low side. The module should still work but may be marginal with low-CTR PC817 variants.
12V Input with 1kΩ on-board resistor:
I_F = (12V - 1.2V - 2.0V) / 1000Ω = 8.8mA
This is well within the optimal range.
24V Input with 1kΩ on-board resistor:
I_F = (24V - 1.2V - 2.0V) / 1000Ω = 20.8mA
This is at the upper end of optimal — still safe but approaching higher power dissipation.
💡 Tip: If you're using a 3.3V input source and the module seems unreliable, the LED current may be too low. You can add an external resistor in parallel with the on-board resistor to increase current, or bypass the on-board resistor entirely with a lower-value external resistor (e.g., 220Ω–330Ω).
🔌 Wiring Hookup Diagrams
Basic Hookup: 24V Sensor → Arduino (5V)
Input Side:
- Input VCC → 24V sensor power supply (+)
- Input GND → 24V sensor power supply (−)
- IN1 → Sensor signal output (goes LOW when sensor triggers)
Output Side:
- Output VCC → Arduino 5V pin
- Output GND → Arduino GND pin
- OUT1 → Arduino digital input pin (e.g., D2)
- Jumper: ON (to use on-board pull-up)
Basic Hookup: Arduino (5V) → 24V PLC Input
Input Side:
- Input VCC → Arduino 5V pin
- Input GND → Arduino GND pin
- IN1 → Arduino digital output pin (e.g., D7) — set LOW to activate
Output Side:
- Output VCC → PLC 24V supply (+)
- Output GND → PLC 24V supply (−) / COM
- OUT1 → PLC digital input terminal
- Jumper: ON (or OFF if PLC provides its own pull-up)
Basic Hookup: ESP32 (3.3V) → 12V Relay
Input Side:
- Input VCC → ESP32 3.3V pin
- Input GND → ESP32 GND pin
- IN1 → ESP32 GPIO output pin — set LOW to activate
Output Side:
- Output VCC → 12V relay coil supply (+)
- Output GND → 12V relay coil supply (−)
- OUT1 → Relay coil trigger input
- Jumper: ON
⚠️ Note: The PC817's output phototransistor can only sink up to 50mA. Most relay coils draw more than this. If driving a relay directly, use a small-signal relay rated under 50mA, or use the optocoupler output to drive a MOSFET or transistor that switches the relay.
🚀 Application Examples
Industrial Monitoring
Monitor 24V proximity sensors, photoelectric sensors, or limit switches with a 3.3V/5V microcontroller while maintaining full galvanic isolation.
PLC Signal Interfacing
Convert 5V microcontroller outputs to 24V PLC-compatible inputs, or read 24V PLC outputs with a low-voltage microcontroller.
Home Automation
Isolate smart home controllers (ESP32, Raspberry Pi) from mains-adjacent circuits like doorbell transformers, HVAC control signals, or security system zones.
Noise Isolation in Audio/Sensor Systems
Break ground loops between a noisy motor driver circuit and sensitive analog sensor or audio circuits.
Multi-Voltage Systems
In systems with multiple voltage rails (3.3V, 5V, 12V, 24V), use the optocoupler module to safely pass signals between voltage domains without level-shifting ICs.
💻 Arduino Example Code
Reading an Isolated Input
This example reads a 24V sensor through the optocoupler module and prints the state to the Serial Monitor.
// PC817 Optocoupler Module - Reading an Isolated Input
// Output side connected to Arduino: OUT1 → Pin 2, VCC → 5V, GND → GND
// Jumper: ON (pull-up enabled)
const int OPTO_INPUT_PIN = 2; // Output from optocoupler module
void setup() {
Serial.begin(9600);
pinMode(OPTO_INPUT_PIN, INPUT); // Pull-up provided by module
Serial.println("PC817 Optocoupler Input Monitor");
Serial.println("-------------------------------");
}
void loop() {
int sensorState = digitalRead(OPTO_INPUT_PIN);
if (sensorState == LOW) {
// Output is LOW = input sensor is active (triggered)
Serial.println("Sensor: ACTIVE (triggered)");
} else {
// Output is HIGH = input sensor is inactive
Serial.println("Sensor: INACTIVE");
}
delay(250); // Read 4 times per second
}
Sending an Isolated Output
This example uses the optocoupler module to send a 5V Arduino signal to a 24V PLC input.
// PC817 Optocoupler Module - Sending an Isolated Output
// Input side connected to Arduino: IN1 → Pin 7, VCC → 5V, GND → GND
// Output side connected to PLC 24V input
const int OPTO_OUTPUT_PIN = 7; // Input to optocoupler module
void setup() {
pinMode(OPTO_OUTPUT_PIN, OUTPUT);
digitalWrite(OPTO_OUTPUT_PIN, HIGH); // Start with LED OFF (inactive)
Serial.begin(9600);
Serial.println("PC817 Optocoupler Output Control");
}
void loop() {
// Activate the optocoupler (send signal to PLC)
digitalWrite(OPTO_OUTPUT_PIN, LOW); // LOW = LED ON = output active
Serial.println("Signal: ON (sent to PLC)");
delay(2000);
// Deactivate the optocoupler
digitalWrite(OPTO_OUTPUT_PIN, HIGH); // HIGH = LED OFF = output inactive
Serial.println("Signal: OFF");
delay(2000);
}
⚠️ Important Design Considerations
Speed Limitations
The PC817 has a typical cut-off frequency of 80 kHz and rise/fall times of 4–18 µs. This makes it suitable for:
- ✅ Digital on/off signals, switch states, sensor triggers
- ✅ Low-frequency PWM (up to ~10 kHz with careful design)
- ❌ Not suitable for high-speed serial communication (UART at 115200 baud, SPI, I²C)
- ❌ Not suitable for analog signal transmission
For high-speed isolated serial communication, consider dedicated digital isolators (e.g., ISO7221, Si8621) or high-speed optocouplers (e.g., 6N137, HCPL-2630).
Current Sinking Limits
The output phototransistor can sink a maximum of 50mA with a maximum V_CE of 35V. Keep your load well within these limits. For higher-current loads, use the optocoupler output to drive a MOSFET or relay driver transistor.
Temperature Effects
Per the PC817 datasheet:
- CTR decreases at temperature extremes — at 100°C, CTR drops to approximately 50%–60% of its 25°C value
- Collector dark current increases with temperature — from ~0.1µA at 25°C to ~100µA at 100°C
- Design with margin if operating in high-temperature environments
LED Aging
Like all LEDs, the infrared LED inside the PC817 degrades over time, especially at higher forward currents. For long-life applications:
- Operate at 5mA–10mA forward current rather than the maximum 50mA
- This extends the useful life from ~10,000 hours to 50,000+ hours
🛠️ Troubleshooting
| Symptom | Possible Cause | Solution |
|---|---|---|
| Output stays HIGH (never triggers) | Input current too low | Check input voltage; verify I_F ≥ 5mA; try lower input resistor |
| Input wiring reversed | Verify input polarity — VCC to (+), signal to INx | |
| Faulty PC817 IC | Test with a different channel or swap the IC | |
| Output stays LOW (always triggered) | Input signal floating | Ensure input pin has a defined HIGH state when inactive |
| Output pull-up not connected | Check jumper is installed (ON position) | |
| Intermittent or noisy output | Marginal LED current | Increase I_F to 10mA+ for reliable switching |
| Long output wires picking up noise | Add 0.1µF capacitor across output pin to GND; use shielded cable | |
| Ground loop | Verify input and output grounds are NOT connected | |
| Indicator LED doesn't light | Input voltage too low | Minimum ~3.6V required |
| Wrong input polarity | Check VCC and GND connections on input side | |
| Module works but signal is inverted | This is normal behavior | The output is active-LOW; handle in software with !digitalRead(pin) or adjust your logic |
📋 PC817 IC Quick-Reference Specifications
Data sourced from the Sharp PC817 datasheet.
Absolute Maximum Ratings (T_a = 25°C)
| Parameter | Symbol | Max Rating | Unit |
|---|---|---|---|
| Forward Current | I_F | 50 | mA |
| Peak Forward Current | I_FM | 1 | A* |
| Reverse Voltage | V_R | 6 | V |
| Input Power Dissipation | P | 70 | mW |
| Collector-Emitter Voltage | V_CEO | 35 | V |
| Emitter-Collector Voltage | V_ECO | 6 | V |
| Collector Current | I_C | 50 | mA |
| Collector Power Dissipation | P_C | 150 | mW |
| Total Power Dissipation | P_tot | 200 | mW |
| Isolation Voltage | V_iso | 5,000 | Vrms |
| Operating Temperature | T_opr | -30 to +100 | °C |
| Storage Temperature | T_stg | -55 to +125 | °C |
*Peak: pulse width ≤ 100µs, duty ratio ≤ 0.001
Electro-Optical Characteristics (T_a = 25°C)
| Parameter | Symbol | Conditions | Min | Typ | Max | Unit |
|---|---|---|---|---|---|---|
| Forward Voltage | V_F | I_F = 20mA | — | 1.2 | 1.4 | V |
| Reverse Current | I_R | V_R = 4V | — | — | 10 | µA |
| Collector Dark Current | I_CEO | V_CE = 20V | — | — | 10⁻⁷ | A |
| Current Transfer Ratio | CTR | I_F = 5mA, V_CE = 5V | 50 | — | 600 | % |
| V_CE Saturation | V_CE(sat) | I_F = 20mA, I_C = 1mA | — | 0.1 | 0.2 | V |
| Isolation Resistance | R_ISO | DC 500V | 5×10¹⁰ | 10¹¹ | — | Ω |
| Cut-off Frequency | f_c | V_CE = 5V, I_C = 2mA | — | 80 | — | kHz |
| Rise Time | t_r | V_CE = 2V, I_C = 2mA | — | 4 | 18 | µs |
| Fall Time | t_f | V_CE = 2V, I_C = 2mA | — | 3 | 18 | µs |
❓ Frequently Asked Questions
Q: Can I use different voltages on different channels of the same module?
A: Yes. Each channel's input is independent. However, all input channels share the same input VCC and GND pins on the module, so the input-side voltage is common. The output side also shares VCC and GND. If you need truly different voltages per channel, you would need to modify the board or use separate modules.
Q: Can I use this module with AC signals?
A: No. The PC817 is designed for DC signals only. The internal LED is a diode and will block the negative half-cycle of an AC signal. For AC signal isolation, use an AC-compatible optocoupler or add a bridge rectifier on the input.
Q: Is this module suitable for PWM signals?
A: It depends on the frequency. The PC817 has a cut-off frequency of ~80 kHz, so it can handle PWM signals up to approximately 10 kHz with acceptable waveform fidelity. Above that, the output waveform will degrade. Standard Arduino analogWrite() PWM at 490 Hz or 980 Hz works fine.
Q: Can I use this to isolate I²C or SPI communication?
A: No. The PC817 is far too slow for these protocols. Use dedicated digital isolators (ISO7221, ADuM1250) for isolated I²C/SPI.
Q: What's the maximum cable length for the output side?
A: There's no hard limit, but longer cables pick up more noise. For runs over 1 meter, use shielded cable and add a 0.1µF decoupling capacitor at the output pin. For runs over 10 meters, consider using RS-485 or another differential signaling method instead.
Q: Can I drive a relay directly from the output?
A: Only if the relay coil draws less than 50mA at the output voltage. Most standard relays draw more than this. Use the optocoupler output to drive a transistor (e.g., 2N2222) or MOSFET that switches the relay, with a flyback diode across the relay coil.
📚 PC-817 Optocoupler Module Tutorials and References
Using the PC817 module as an Arduino digital input board by Michael Schoeffler: https://mschoeffler.com/2021/04/30/arduino-tutorial-hy-m154-817-pc817-optocoupler-module/
Using the PC817 module as an Arduino digital output board by cmheong: https://cmheong.blogspot.com/2020/06/more-power-hy-m154-4-channel.html
Sold and supported by Envistia Mall. Ships from the USA. The manufacturer and Envistia LLC (dba Envistia Mall) are not responsible for any damages or losses resulting from the use of this product. Always follow proper electrical safety practices when working with electronic components. Specifications are based on manufacturer data and are subject to change without notice.