PC817 Overview
The PC817X series optocoupler IC is comprised of an IRED (Infrared Emitting Diode, or IR LED) and a phototransistor optically coupled to it. It functions as the inner phototransistor conducts when receiving the IR LED's emitting light. These two parts are not hard-electrically connected; thus, it provides convenient optical noise isolation compared with using resistors and capacitors. Simple but useful, the PC817 is trustworthy in low voltage DC devices and MCUs in transferring the signal from one part of the circuit to the other.
PC817 Pinout

Infrared LED Input
• Pin-1: The Anode (+) pin inputs the logic signal to the internal IR
• Pin-2: The Cathode (-) pin is connected to the common ground with the circuit and power supply
Phototransistor Output
• Pin-3: The Emitter pin is similar to the Cathode pin. It provides the ground connection
• Pin-4: The Collector pin transfers the logical output when receiving IR signal
Optocoupler Electronic Symbol

(image credit: https://commons.wikimedia.org/wiki/File:Optoisolator_Pinout.svg)
Optocouplers allow you to send a signal to a circuit that is completely isolated from the electronic world. Consider an optocoupler to be a type of transistor, except that it sends light and a phototransistor from another circuit picks up the signal and opens or closes the circuit. From an electrical standpoint, complete isolation is achieved.
PC817 Specs and Features
High VCEO (collector-emitter voltage): 80V MAX
4pin DIP package and SMT package
Internal protection for input and output
CTR (Current transfer ratio) are available for several ranks
Fall time: 18μs
Rise time: 18μs
Max collector current: 50mA
Max power dissipation: 200mW
High isolation voltage between input and output: 5.0kV
Cut-off frequency: 80 kHz
PCB817 Applications
As an optocoupler, the PC817 IC is advantageous for reducing noise between the input signal and electrical appliances/circuits, typical applications include:
I/O Isolation for microcontrollers
Regular electrical isolation purposes
Basic noise coupling circuit in switching circuit
IoT devices
Signal transmission
PC817 Application Circuits

A phototransistor-based optocoupler circuit is used in the upper circuit. It will function similarly to a standard DC transistor switch. A low-cost photo-transistor-based optocoupler PC817 is used in the schematic. The S1 switch will control the infrared led. When the switch is turned on, the 9V battery source will supply current to the LED through the 10k current limiting resistor. The R1 resistor controls the intensity. If we change the value and reduce the resistance, the intensity of the led will be high, resulting in a high transistor gain.
On the other side, the transistor is a phototransistor that is controlled by the internal infrared led; when the led emits infrared light, the phototransistor contacts and the VOUT becomes zero, turning off the load connected across it. It is important to remember that the transistor's collector current is 50mA according to the datasheet. The VOUT 5v is supplied by R2. The R2 resistor is a pull-up resistor.
PC817 Application Note
The output current of optocouplers is low. The maximum output current of the PC817, for example, is 50 mA. As a result, high current components (such as motors, etc.) cannot be directly connected to the optocoupler output. In such cases, a transistor must be used to supply current.
PC817 Arduino Project

(image credit: https://www.instructables.com/Isolating-circuits-from-your-arduino-with-optocoup/)
Above is an Arduino interface circuit wiring example based on the PC817 optocoupler, the Arduino Uno Board, and the 2N2222 transistor.
The first 220 resistors are connected between pin 9 on the Arduino board and the positive side of the optocoupler led in the chip; this resistor reduces the voltage from the board so that it does not overpower the led and burn it out. If you use a different optocoupler than the SHARP PC817, you may need to adjust this resistor to compensate; the PC817 has a maximum led input voltage of 1.4 volts, and the resistor reduces the Arduino's 5 volts to 1.25 volts.
The second 220Ω resistor limits the current flow through the phototransistor in the chip, the SHARP PC817 will handle 35 volts at 50mA but it will get very hot and not last long under those conditions so you can put a current limiting resistor in the circuit to keep it way under those conditions.
For Arduino codes of the example, go to: https://www.instructables.com/Isolating-circuits-from-your-arduino-with-optocoup/
PC817 Alternative Photocouplers
TLP521, HCNR201, MOC3021, MOC3041, 6N136
PC817 Dimensions

PC817 Optocoupler FAQ
1. What is the difference between PC817 and 4N35?
The PC817 is a photo-transistor type of optocoupler while the 4N35 is a photo-triac optocoupler. The photo-transistor devices are primarily used in DC circuits, whereas the photo-triac devices allow control of AC-powered circuits.
2. How does an optocoupler work?
An optocoupler is made up of a Transmitter, which is an IR LED, and a Receiver, which is a photosensitive component. When light is emitted by an LED and strikes a photosensor (Photodiode, Phototransistor, Phototriac), the photosensor begins to flow current. In this system, the Input Light is proportional to the output current.
3. What is the forward voltage of PC817?
The input voltage (forward) of PC817 is 1.25V.