An optical transistor (commonly called a phototransistor) is a light-activated bipolar junction transistor (BJT). Instead of relying solely on electrical current at the base pin to control collector-emitter flow, it uses photons striking the base-collector junction to generate electron-hole pairs, effectively acting as base current. If you need to isolate a high-voltage control signal, build a break-beam sensor, or detect ambient light levels without the complexity of a dedicated digital IC, the optical transistor is your baseline component. For 90% of hobbyist and prototyping tasks, the BPW40 (for infrared) and the TEPT4400 (for visible light) are the safest, most available default part numbers.

Symbol, Pinout, and Safe Default Part Numbers

On a schematic, the optical transistor symbol looks like a standard NPN BJT, but the base connection is either omitted entirely or replaced by two inward-pointing arrows representing incident light. Physically, discrete phototransistors usually come in a 3mm or 5mm T-1 package with two leads. The longer lead is the Collector, and the shorter lead is the Emitter. Some specialized packages include a physical base lead to allow for electrical biasing alongside optical biasing, but this is rare in general-purpose parts.

Bench Tip: If you clip the leads short before testing, look for the flat edge on the plastic lens rim. The flat edge typically denotes the Emitter pin. Always verify with a multimeter before soldering.

Choosing the right part depends on your light source and required switching speed. Here are the benchmark defaults you should stock in your lab:

Part NumberType / SpectrumPeak WavelengthV_CE (max)I_C (max)Typical Cost
BPW40IR Phototransistor900 nm70 V100 mA$0.15
TEPT4400Visible Ambient570 nm (Green/Yellow)20 V50 mA$0.25
PC817 (LTV-817)Optocoupler (Contains PT)940 nm (Internal LED)35 V50 mA$0.10
PT334-6CIR Phototransistor940 nm30 V50 mA$0.12

For pure isolation where you are driving an internal LED, use the PC817 optocoupler. For detecting an external IR beam (like a tachometer or limit switch), the Vishay BPW40 is the undisputed workhorse due to its wide viewing angle and high sensitivity.

Biasing and Operation Regions

Unlike a standard BJT where you calculate base resistor values to set the bias point, an optical transistor is biased by sizing the collector or emitter load resistor to achieve your desired output voltage swing under specific lighting conditions. You have two primary wiring topologies:

  • Common-Emitter (Pull-up on Collector): The emitter is tied to ground. The collector is pulled up to V_CC via a resistor. In the dark, the output is HIGH (V_CC). When light hits the sensor, it conducts, pulling the output LOW. This is the preferred configuration for digital switching because it provides an inverted, sharp logic signal.
  • Common-Collector (Pull-down on Emitter): The collector is tied directly to V_CC. The emitter is pulled down to ground via a resistor. In the dark, output is LOW. In light, output rises. This configuration acts as an emitter follower, providing a non-inverted analog voltage proportional to light intensity, but it suffers from slower switching speeds.

Understanding the operation regions is critical for deciding whether you are using the part as a linear sensor or a digital switch.

Operation RegionV_CE VoltageI_C CurrentLight ConditionPrimary Use Case
CutoffV_CE ≈ V_CCI_C ≈ 0 A (Nanoamps)Total DarknessDigital HIGH state, baseline ambient reading
Active (Linear)0.5V < V_CE < V_CCI_C ∝ Light IntensityPartial / Varying LightAnalog light metering, flame sensing
SaturationV_CE < 0.2VLimited by Load ResistorBright / Direct IR BeamDigital LOW state, break-beam switches

Application Circuit: IR Break-Beam Tachometer

Let us build a digital tachometer using a BPW40 optical transistor and an ESP32 microcontroller. The goal is to read a slotted encoder wheel attached to a motor shaft. We will use the common-emitter topology for clean digital edges.

Component List

  • 1x BPW40 IR Phototransistor
  • 1x 940nm IR LED (e.g., TSAL6200) with a 150Ω current-limiting resistor
  • 1x 4.7 kΩ pull-up resistor (0.25W)
  • 1x 100 pF ceramic capacitor (speed-up cap)
  • ESP32 DevKit v1

Wiring Steps

  1. IR Emitter Setup: Connect the anode of the IR LED to the ESP32 3.3V pin through the 150Ω resistor. Connect the cathode to GND. This provides roughly 12 mA of forward current, creating a continuous invisible beam.
  2. Phototransistor Emitter: Connect the short lead (Emitter) of the BPW40 directly to the ESP32 GND pin.
  3. Pull-up Network: Connect one end of the 4.7 kΩ resistor to the ESP32 3.3V pin. Connect the other end to the long lead (Collector) of the BPW40.
  4. Speed-up Capacitor: Solder the 100 pF capacitor in parallel with the 4.7 kΩ pull-up resistor. This is critical for high-speed edge transitions.
  5. Signal Out: Wire the Collector pin (the junction of the resistor, capacitor, and phototransistor) to ESP32 GPIO 4.
  6. Software Config: Configure GPIO 4 as an input with an interrupt triggered on the FALLING edge. Refer to the official ESP32 GPIO documentation for the exact interrupt attachment API.

When the slotted wheel passes between the IR LED and the BPW40, the beam breaks. The phototransistor cuts off, and the 4.7 kΩ pull-up rapidly snaps GPIO 4 to 3.3V. When the slot aligns, the BPW40 saturates, pulling GPIO 4 down to roughly 0.1V. The ESP32 counts these pulses to calculate RPM.

Bench War Story: The 500 RPM Ghost Pulses

The Setup: I was retrofitting a closed-loop stepper motor controller on a custom CNC router. I used a BPW40 optical transistor and a 60-slot optical encoder wheel to verify shaft speed. The target speed was 500 RPM (8.33 revolutions per second). With 60 slots, the expected pulse frequency was exactly 500 Hz. To minimize power draw on the 5V rail, I initially sized the pull-up resistor at 100 kΩ.

The Numbers: 500 Hz means a 2 ms period. Assuming a 50% duty cycle, the signal should be HIGH for 1 ms and LOW for 1 ms. The ESP32 interrupt service routine (ISR) was set to increment a counter on every falling edge.

The Outcome: At 100 RPM, the system tracked perfectly. But as the motor ramped past 300 RPM, the ESP32 counter started registering wild spikes. At 500 RPM, the controller read 1,200+ pulses per second and immediately tripped the over-speed safety fault, killing the motor drive.

What Went Wrong: I hooked up my Rigol oscilloscope to the collector pin and saw the problem. The 100 kΩ pull-up resistor, combined with the BPW40's internal collector-base junction capacitance (the Miller effect), created an unintentional RC low-pass filter. When the light beam hit the sensor, the transistor turned on quickly, but when the beam broke, the 100 kΩ resistor took nearly 1.2 ms to charge the parasitic capacitance back up to 3.3V. The voltage ramp was so slow that as it crossed the ESP32's Schmitt trigger threshold (around 1.5V), high-frequency noise on the ramp caused the GPIO to register three or four distinct falling edges instead of one.

The Fix: I swapped the 100 kΩ resistor for a 4.7 kΩ resistor, which stiffened the pull-up and dropped the rise time to under 5 µs. I also added a 100 pF capacitor in parallel to provide a momentary surge of current during the logic transition. The edges became perfectly square, and the ghost pulses vanished.

This scenario highlights a fundamental rule of optical transistor design: higher pull-up resistance saves power but destroys switching speed. If you are doing analog light sensing, 100 kΩ is fine. If you are doing digital switching above 10 Hz, keep your pull-up between 2.2 kΩ and 10 kΩ.

Failure Modes and Multimeter Testing

Optical transistors are robust, but they do fail. The most common failure modes are junction degradation from excessive current (usually caused by wiring the collector directly to V_CC without a load resistor, resulting in thermal runaway) and lens opacity from prolonged UV exposure or physical scratching, which drastically reduces sensitivity.

You can definitively test an optical transistor on your bench using a standard digital multimeter (DMM) without needing to build a circuit. Here is the exact procedure:

  1. Set the DMM: Turn your multimeter to the Diode Test mode (the symbol with an arrow and a line).
  2. Dark Test (Reverse Bias): Place the red probe on the Emitter and the black probe on the Collector. The meter should read 'OL' (Open Loop) or '1', indicating no conduction. Cover the sensor with your finger to ensure total darkness.
  3. Dark Test (Forward Bias): Swap the probes: Red on Collector, Black on Emitter. In total darkness, this should also read 'OL'. If it reads a low voltage drop (like 0.4V) in the dark, the junction is shorted and the part is dead.
  4. Light Activation Test: Keep the Red probe on the Collector and the Black probe on the Emitter. While watching the DMM screen, shine a bright light source directly into the lens. For a visible-light sensor like the TEPT4400, a smartphone flashlight works perfectly. For an IR sensor like the BPW40, point a TV remote control at it and hold down a button.
  5. Evaluate the Reading: As photons hit the junction, the DMM should register a voltage drop, typically between 0.400V and 0.650V, as the internal junction begins to conduct the DMM's test current. If the reading drops, the optical transistor is healthy. If it stays at 'OL' under bright light, the internal bond wire is broken or the silicon is degraded.

For deeper circuit validation, remember that opto-isolators and phototransistors share the same underlying semiconductor physics. Treat the optical transistor not as a magical light-switch, but as a standard BJT where your flashlight is simply the base current source. Calculate your load resistors accordingly, respect the parasitic capacitance, and your optical circuits will run reliably for years.