Same-day dispatch before 2 PM · Free delivery over ₹999 · GST invoices Get the appPrices incl. GST
Geekobot
Snap & SendNEWGeeko AIWhere's myOrder
Log in
Products
  • Projects
    • Component guidesHow parts work, with code you can run
    • Learning pathsFrom your first LED to your first robot
    • Workshops & eventsOnline sessions for makers and classes
    • ElectrolarkFree guided builds, simulator and certificates
    • Students & teachersStudent discount and classroom help
    • CommunityShare builds and ask other makers
    • CalculatorsOhm's law, LED resistor, 555 and 100+ more
    • Circuit builderWire parts and run the circuit, powered by Electrolark
    • Geeko AIAsk what to buy or how to wire it
    • Snap & SendPhotograph a part or list, we find it
    • Part finderAnswer a few questions, get the right part
    • Compatibility checkWill these two parts work together?
    • Compare partsSpecs side by side
    • Business & bulk ordersGST invoices, credit and volume prices
    • Request a quotationSend your list, get a quote
    • Classroom kitsPer-student kits and lab bundles
    • Gift cardsFor students, teams and events
  • Atal Tinkering Lab
BOM to cart
Geekobot

Components, kits and know-how for makers, students, engineers, labs and businesses across India.

Ask Geeko AIOrders, parts and projects, any timeEmail supportReply within 1 working dayGet the Geekobot appAdd it to your home screen, free

Follow us

Shop

  • Boards & SBCs
  • Sensors & Modules
  • IoT & Wireless
  • Drone & FPV
  • 3D Printing
  • Filaments & Resins
  • Motors & Drivers
  • Power & Batteries
  • Semiconductors
  • Passive
  • Displays & LEDs
  • Switches & Relays
  • Wires & Cables
  • Prototyping
  • Tools & Test
  • Robotics
  • STEM Kits
  • Atal Tinkering Lab
  • Mechanical Parts
  • Audio

Orders

  • Track your order
  • Help & support
  • Shipping and delivery
  • Refunds and cancellation
  • Contact us

Learn

  • Projects
  • Geeko AI project assistant
  • Learning paths
  • Guides
  • Calculators
  • Electrolark: free guided builds

Part tools

  • Part finder
  • Compare parts
  • Will it work with my board?

Institutions

  • Classroom kits
  • Atal Tinkering Lab
  • Students & teachers
  • Workshops & Events

Business

  • Business & education
  • Request a quotation
  • BOM bulk upload
  • Quick order by SKU

Company

  • About Geekobot
  • Community
  • Gift cards
  • Terms & conditions
  • Privacy policy
  • Product directory
  • Sitemap

© 2026 Geekobot, a trade name of OLatus Systems Private Limited. All rights reserved.

20, 1st Floor, Neeladri Complex, 10th Cross, Sampige Rd, 2nd Main, Malleshwaram, Bengaluru, Karnataka 560003 · GSTIN 29AACCO0462F1ZM

+91 91810 15607 · connect@geekobot.in · Monday to Saturday, 10 AM to 2 PM IST

UPI · CARDS · NETBANKING · GST INVOICES

ShopProjectsGeeko AIGuides
Compare 0 parts →
Log in

Shop by category

Shop all components
  • Boards & SBCs1,910 products
    • Alternative Single Board Computers
    • Arduino Ecosystem
    • FPGA & Logic Boards
    • Microcontroller & Wireless Boards
    View all
  • Sensors & Modules4,701 products
    • Biomedical & Heart Rate
    • Current, Voltage & Power
    • Force, Weight & Pressure
    • Gas, Weather & Environmental
    View all
  • IoT & Wireless2,314 products
    • RF Modules
    • RFID & NFC
    • Antennas & RF Accessories
    • Cameras & Smart Vision
    View all
  • Drone & FPV3,558 products
    • Flight Control & Navigation
    • FPV Video & Optics
    • Frames & Structural Parts
    • Motors & Propulsion
    View all
  • 3D Printing2,204 products
    • 3D Printers
    • 3D Scanners & Digitizers
    • Laser Engravers & Cutters
    • Material Management & Upgrades
    View all
  • Filaments & Resins1,472 products
    • Filaments
    • Photopolymer Resins
    View all
  • Motors & Drivers463 products
    • BLDC Motor Drivers
    • DC & Geared Motors
    • DC Motor Drivers
    • Linear Actuators & Solenoids
    View all
  • Power & Batteries557 products
    • Battery Holders & Connectors
    • Breadboard Power
    • Chargers & BMS
    • DC-DC Converters
    View all
  • Semiconductors295 products
    • Diodes & Rectifiers
    • Interface & RF Encoder ICs
    • Logic ICs (74xx)
    • Logic ICs (CD4000)
    View all
  • Passive67 products
    • Capacitors
    • Circuit Protection
    • Crystals & Oscillators
    • Inductors
    View all
  • Displays & LEDs572 products
    • 7-Segment & Dot Matrix
    • Addressable LEDs
    • Character LCDs
    • Graphic LCDs
    View all
  • Switches & Relays184 products
    • Keypads & Touch
    • Push Buttons & Tactile
    • Relay Modules
    • Relays
    View all
  • Wires & Cables233 products
    • Board-to-Wire Connectors
    • Crimp & Splice
    • Headers & Dupont
    • Heat Shrink & Sleeving
    View all
  • Prototyping101 products
    • Breadboards
    • Interface Modules
    • PCBs & Perfboards
    View all
  • Tools & Test717 products
    • Bench Power Supplies
    • Hand Tools
    • Measuring Tools
    • Meters & Testers
    View all
  • Robotics180 products
    • Humanoid & Legged Robots
    • Robot Chassis & Platforms
    • Robotic Arms & Grippers
    • Wheels & Casters
    View all
  • STEM Kits268 products
    • Arduino Learning Kits
    • Coding & IoT Kits
    • Early Coding (Ages 3-8)
    • Invention Kits
    View all
  • Atal Tinkering Lab196 products
    • Package 1: Electronics, Robotics, IoT and Sensors
    • Package 2: Rapid Prototyping Tools
    • Package 3: Mechanical, Electrical and Measurement Tools
    • Package 4: Power Supply, Accessories and Safety Equipment
    View all
  • Mechanical Parts212 products
    • Bearings
    • Brackets & Mounts
    • Couplers
    • Fasteners & Standoffs
    View all
  • Audio109 products
    • Amplifier Modules
    • Buzzers & Sirens
    • Speakers
    View all
  1. Home
  2. ›Guides
  3. ›Semiconductors & ICs
  4. ›Optocouplers

Component guide · Intermediate · 3 min read

Optocouplers

How the PC817 Isolates Circuits

By Geekobot Learning Team · Updated 24 Oct 2026

On this page
Short answerWhy isolate?Wiring a PC817 as an isolated inputChoosing the resistorsSpeed and other typesTry itCommon mistakesFAQsParts and next steps
Short answer

An optocoupler contains an LED and a light-sensitive transistor in one package with no electrical connection between them. Turning on the LED switches the transistor, so a signal crosses between two circuits that do not share ground. The common PC817 needs a resistor on its LED (about 330 Ω to 1 kΩ from 5 V) and a pull-up on its output transistor for a clean logic signal.

Key specs at a glance

Input
Infrared LED, forward voltage about 1.2 V, 5 to 20 mA
Output
Phototransistor, up to 35 V, 50 mA
CTR
Current transfer ratio 50 to 600% (PC817 grades A to D)
Isolation
About 5000 V RMS for 1 minute (PC817)
Speed
Tens of kHz; use 6N137-type parts for fast signals
Package
4-pin DIP; 4-channel PC847
01

Why isolate?

Safety

keep a mains-side circuit (such as a zero-cross detector or a relay driver on a high-voltage board) separate from the low-voltage microcontroller.

Noise

stop motor or relay noise on one ground from upsetting a sensitive circuit.

Different grounds

read a 12 or 24 V industrial sensor or PLC output with a 3.3 V microcontroller.

Protection

a fault on the far side destroys a cheap optocoupler instead of your board.

The relay modules many people use have a PC817 on the input for exactly this reason; see relay modules.

02

Wiring a PC817 as an isolated input

PC817 pinFunctionConnect to
1 (anode)LED +Signal source through a resistor (for 24 V input, about 2.2 kΩ)
2 (cathode)LED -Source ground
4 (collector)OutputMicrocontroller input pin and a 10 kΩ pull-up to 3.3 or 5 V
3 (emitter)Output groundMicrocontroller ground
1 (anode)
Function:
LED +
Connect to:
Signal source through a resistor (for 24 V input, about 2.2 kΩ)
2 (cathode)
Function:
LED -
Connect to:
Source ground
4 (collector)
Function:
Output
Connect to:
Microcontroller input pin and a 10 kΩ pull-up to 3.3 or 5 V
3 (emitter)
Function:
Output ground
Connect to:
Microcontroller ground
03

Choosing the resistors

LED resistor: R = (Vin - 1.2 V) / I. For a 5 V source at 10 mA: (5 - 1.2) / 0.01 = 380 Ω, so 330 or 390 Ω. For 24 V at 10 mA: about 2.2 kΩ, rated 0.25 W or more. Output pull-up: 4.7 to 10 kΩ. The output current must stay below LED current x CTR; with 10 mA in and a CTR of at least 50%, the transistor can sink 5 mA, so a 10 kΩ pull-up (0.33 to 0.5 mA) switches cleanly. The output is inverted: LED on pulls the pin LOW.

04

Speed and other types

The PC817 switches in a few microseconds to tens of microseconds, fine for buttons, sensors and slow PWM, but too slow for fast serial links. Use a high-speed logic optocoupler (6N137, HCPL-2601) for UART or SPI isolation, or a digital isolator chip for very high speeds. For switching AC loads, a triac optocoupler (MOC3021 or MOC3041) drives a triac; this is how many SSRs work. See SSR vs relay.

05

Try it: LED resistor calculator

Change the values and the diagram and results update as you type.

06

Common mistakes to avoid

  • !No series resistor on the LED side.
  • !Joining the two grounds, which defeats the isolation.
  • !Forgetting the output is inverted.
  • !Using a PC817 for fast serial or high-frequency PWM.
  • !Too large a pull-up for the CTR, so the output never goes fully low.
07

Frequently asked questions

What does an optocoupler do?

It passes a signal between two circuits using light, so the circuits do not share an electrical connection or ground.

What resistor do I need for a PC817?

About 330 to 390 Ω for a 5 V input at 10 mA, and around 2.2 kΩ for 24 V. Use a 4.7 to 10 kΩ pull-up on the output.

Is the PC817 output inverted?

Wired with a pull-up on the collector, yes: when the LED is on, the output goes LOW.

Can an optocoupler switch AC mains?

A triac-output optocoupler such as the MOC3041 can trigger a triac that switches AC, but mains circuits need proper isolation, layout and safety knowledge.

How fast can a PC817 switch?

Up to roughly tens of kHz in typical circuits. Use a 6N137 or a digital isolator for faster signals.

Parts for this guide

  • 5V Relay Module with Optocoupler
    ₹74View
  • Solid State Relay Module (SSR)
    ₹129View
  • Resistor Assortment Kit (30 Values)
    ₹33View
Shop OptocouplersShop Relay Modules

Calculators

LED resistor calculatorOhm's law calculator

Terms in this guide

OptocouplerA component that passes a signal through light between an LED and a phototransistor, electrically isolating two circuits.Forward voltageThe voltage a diode or LED drops when conducting: about 0.7 V for silicon diodes, 1.8 to 3.3 V for LEDs.Pull-up resistorA resistor from a signal line to the supply that keeps the line high when nothing pulls it low.Active-lowA signal that is 'on' when pulled to 0 V. Many relay modules switch on when their input is LOW.Open-collectorAn output that can only pull LOW; it needs a pull-up resistor to go HIGH. Many sensor modules and the LM393 comparator work this way.

Projects that use it

Put this into practice: 161 step-by-step builds in our project library use parts from this guide.

Beginner · 1–2 hoursAutomatic plant watering systemView projectIntermediate · 2 hoursPlant waterer with moisture displayView projectBeginner · 45 minutesAutomatic dusk-to-dawn lightView project
Browse all 161 projects

Keep learning

Component guideBeginnerRelay ModulesA relay module is an electrically controlled switch that lets a microcontroller turn a separate circuit on or off, such as a 12 V pump or a mains lamp.4 min read · Switches, Relays & InputHow-toIntermediateTransistors and MOSFETs as SwitchesA transistor lets a small microcontroller signal switch a much larger current.4 min read · Semiconductors & ICsComponent guideBeginnerLEDs ExplainedAn LED (light-emitting diode) lights when current flows from its longer leg (anode, +) to its shorter leg (cathode, -).3 min read · Displays & LEDsHow-toIntermediate3.3 V vs 5 V LogicYou need level shifting when a 5 V device sends signals to a 3.3 V board such as an ESP32 or Raspberry Pi Pico, because 5 V on their pins can damage them.4 min read · Prototyping & Wiring

Sources

  • Sharp PC817 datasheet
  • Vishay optocoupler application notes
  • Onsemi MOC3041 datasheet

Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

On this page
Short answerWhy isolate?Wiring a PC817 as an isolated inputChoosing the resistorsSpeed and other typesTry itCommon mistakesFAQsParts and next steps
Need a hand?Ask Geeko AI which part fits your project, or talk to the Geekobot team.Ask Geeko AIHelp & support

Parts for this guide3 items · ₹236

5V Relay Module with Optocoupler · Solid State Relay Module (SSR) · Resistor Assortment Kit (30 Values)

Ask the Community

Ask a question