Practical case: Basic Infrared Light Barrier

Basic Infrared Light Barrier prototype (Maker Style)

Level: Basic. Build a simple alarm system that detects the interruption of a light beam.

Objective and use case

In this project, you will build an optical detector system consisting of a transmitter (IR LED) and a receiver (Photodiode) that controls a transistor switch. When the invisible infrared beam is interrupted by an object, an alarm LED will light up.

  • Security systems: Used in door or window frames to detect unauthorized entry.
  • Automation: detecting objects on a conveyor belt for counting or sorting.
  • Safety: Emergency stop mechanisms when a hand crosses a dangerous boundary.
  • Touchless switching: Activating devices without physical contact.

Expected outcome:
* Beam Intact (Clear path): The Red Alarm LED is OFF.
* Beam Interrupted (Object present): The Red Alarm LED turns ON.
* Signal: The voltage at the sensing node will transition from Logic Low (approx. 0.1 V – 0.5 V) to Logic High (> 0.7 V) when the beam is broken.
* Target audience: Beginners familiar with breadboarding and basic discrete components.

Materials

  • V1: 5 V DC supply
  • D1: IR LED (Infrared Emitter), function: Beam transmitter (Tx)
  • R1: 220 Ω resistor, function: Current limiting for D1
  • D2: Photodiode, function: Beam receiver (Rx)
  • R2: 100 kΩ resistor, function: Pull-up resistor for the sensing node
  • Q1: 2N2222 (or 2N3904) NPN Transistor, function: Electronic switch
  • R3: 1 kΩ resistor, function: Base current limiter for Q1
  • D3: Red LED, function: Alarm indicator
  • R4: 330 Ω resistor, function: Current limiting for D3

Wiring guide

This circuit is divided into two parts: the Transmitter (Tx) and the Receiver (Rx). Construct them facing each other.

Transmitter (Tx):
* VCC connects to R1.
* R1 connects to the Anode of D1 (Node: TX_ANODE).
* D1 (Cathode) connects to 0 (GND).

Receiver (Rx) – Dark Detector Configuration:
* VCC connects to R2.
* R2 connects to the Cathode of D2 (Node: V_SENSE). Note: Photodiodes are used in reverse bias.
* D2 (Anode) connects to 0 (GND).
* VCC connects to R4.
* R4 connects to the Anode of D3.
* D3 (Cathode) connects to the Collector of Q1 (Node: V_ALARM).
* Q1 (Emitter) connects to 0 (GND).
* Node V_SENSE connects to R3.
* R3 connects to the Base of Q1.

Conceptual block diagram

Conceptual block diagram — Light Barrier Detection
Quick read: inputs → main block → output (actuator or measurement). This summarizes the ASCII schematic below.

Schematic

+------------------------------------------------------------------------------+
|                   PRACTICAL CASE: BASIC INFRARED LIGHT BARRIER               |
+------------------------------------------------------------------------------+

      [ INPUTS / SENSORS ]              [ LOGIC / CONTROL ]               [ OUTPUT / LOAD ]

      (Transmitter)
      [ VCC ]
         |
         v
      [ R1: 220 ]
         |
         v
      [ D1: IR LED ] ~~~~~(IR Beam)~~~~~> [ D2: Photodiode ]
         |                                (Rx Sensor)
         v                                      |
      [ GND ]                                   |
                                                |
      (Receiver Bias)                           |
      [ VCC ]                                   |
         |                                      |
         v                                      |
      [ R2: 100k ]                              |
         |                                      |
         +-----------(Node: V_SENSE)------------+
         |
         |
         v
      [ R3: 1k ]
         |
         v
      [ Q1: NPN Base ] ----------------> [ Q1: Collector ] <--(Switched Path)-- [ D3: Red LED ]
      (Transistor Switch)                (Sinks Current)                              ^
                                                |                                     |
                                                v                                [ R4: 330 ]
                                         [ Q1: Emitter ]                              ^
                                                |                                     |
                                                v                                  [ VCC ]
                                             [ GND ]

+------------------------------------------------------------------------------+
| SIGNAL FLOW ANALYSIS:                                                        |
| 1. Tx generates IR Beam.                                                     |
| 2. If Beam hits D2 (Clear) -> D2 conducts -> V_SENSE is LOW -> Q1 OFF.       |
| 3. If Beam blocked (Dark)  -> D2 blocks   -> V_SENSE is HIGH -> Q1 ON.       |
| 4. Q1 ON connects D3 to GND -> ALARM ACTIVATED.                              |
+------------------------------------------------------------------------------+
Schematic (ASCII)

Electrical diagram

Electrical diagram for case: Basic Infrared Light Barrier
Generated from the validated SPICE netlist for this case.

🔒 This electrical diagram is premium. With the 7-day pass or the monthly membership you can unlock the complete didactic material and the print-ready PDF pack.🔓 See premium access plans

System Logic Table

Physical State IR Beam Status Photodiode (D2) Mode V_SENSE Voltage Transistor (Q1) Alarm LED (D3)
Normal Reaching Rx Conducting (Low Resistance) Low (< 0.6 V) OFF (Cut-off) OFF
Intrusion Blocked/Broken Blocking (High Impedance) High (~VCC) ON (Saturation) ON

Measurements and tests

  1. Tx Verification: Connect power. Use a smartphone camera to look at the IR LED (D1). You should see a faint purple/pink glow on the screen (human eyes cannot see IR).
  2. Rx Voltage Test (Beam Intact): Align D1 and D2 perfectly. Measure voltage at V_SENSE relative to GND. It should be low (typically < 0.6 V) because the light causes the photodiode to conduct current to the ground.
  3. Rx Voltage Test (Beam Broken): Place a card or your hand between D1 and D2. Measure voltage at V_SENSE. It should rise significantly (close to 4 V–5 V) as the photodiode stops conducting and R2 pulls the node high.
  4. Functional Test: Ensure the Red LED (D3) turns ON immediately when the beam is blocked and turns OFF when the path is clear.

SPICE netlist and simulation

Reference SPICE Netlist (ngspice) — excerptFull SPICE netlist (ngspice)

* Practical case: Basic Infrared Light Barrier

* --- Component Models ---
* Standard NPN Transistor
.model 2N2222 NPN (IS=1E-14 BF=200 VAF=100)
* Infrared LED (Tx) - Approx Vf=1.2V
.model IR_LED D (IS=1p N=1.5 RS=5)
* Red LED (Alarm) - Approx Vf=1.8-2.0V
.model RED_LED D (IS=1u N=2 RS=10)
* Photodiode (Rx) - Modeled as diode with low capacitance
.model PD_DIODE D (IS=10p N=1 RS=10 CJO=10p)

* --- Power Supply ---
V1 VCC 0 DC 5

* --- Transmitter (Tx) Circuit ---
* Connectivity: VCC -> R1 -> D1(Anode). D1(Cathode) -> GND.
R1 VCC TX_ANODE 220
D1 TX_ANODE 0 IR_LED

* ... (truncated in public view) ...

Copy this content into a .cir file and run with ngspice.

🔒 Part of this section is premium. With the 7-day pass or the monthly membership you can access the full content (materials, wiring, detailed build, validation, troubleshooting, variants and checklist) and download the complete print-ready PDF pack.

* Practical case: Basic Infrared Light Barrier

* --- Component Models ---
* Standard NPN Transistor
.model 2N2222 NPN (IS=1E-14 BF=200 VAF=100)
* Infrared LED (Tx) - Approx Vf=1.2V
.model IR_LED D (IS=1p N=1.5 RS=5)
* Red LED (Alarm) - Approx Vf=1.8-2.0V
.model RED_LED D (IS=1u N=2 RS=10)
* Photodiode (Rx) - Modeled as diode with low capacitance
.model PD_DIODE D (IS=10p N=1 RS=10 CJO=10p)

* --- Power Supply ---
V1 VCC 0 DC 5

* --- Transmitter (Tx) Circuit ---
* Connectivity: VCC -> R1 -> D1(Anode). D1(Cathode) -> GND.
R1 VCC TX_ANODE 220
D1 TX_ANODE 0 IR_LED

* --- Receiver (Rx) Circuit ---
* Sensor Stage: VCC -> R2 -> D2(Cathode). D2(Anode) -> GND.
* Node V_SENSE is the junction of R2 and D2.
R2 VCC V_SENSE 100k
D2 0 V_SENSE PD_DIODE

* PHYSICAL STIMULUS: IR Beam Simulation
* In a real circuit, D1 emits light which D2 receives.
* We model this optical coupling with a Current Source (Photocurrent) in parallel with D2.
* Direction: Photocurrent flows Cathode to Anode (V_SENSE to GND).
* Logic:
*   - 50uA = Light Detected (Beam Intact) -> V_SENSE pulled Low -> Alarm OFF.
*   - 0A   = Dark (Beam Broken) -> V_SENSE pulled High by R2 -> Alarm ON.
* Timing: Start with Light (50uA), break beam at 1ms (0A), restore at 3ms.
I_Beam V_SENSE 0 PULSE(50u 0 1m 10u 10u 2m 5m)

* Switch Stage: V_SENSE -> R3 -> Q1(Base)
R3 V_SENSE Q1_BASE 1k
* Q1: Collector=V_ALARM, Base=Q1_BASE, Emitter=GND
Q1 V_ALARM Q1_BASE 0 2N2222

* Alarm Indicator Stage: VCC -> R4 -> D3(Anode). D3(Cathode) -> Q1(Collector).
R4 VCC LED_ANODE 330
D3 LED_ANODE V_ALARM RED_LED

* --- Analysis Directives ---
* Transient analysis for 5ms to capture the beam break event
.tran 10u 5m

* Print required voltages for verification
.print tran V(V_SENSE) V(Q1_BASE) V(V_ALARM) V(TX_ANODE)

.op
.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Show raw data table (1072 rows)
Index   time            v(v_sense)      v(q1_base)      v(v_alarm)
0	0.000000e+00	5.009804e-07	5.059904e-07	4.999999e+00
1	1.000000e-07	5.009804e-07	5.059904e-07	4.999999e+00
2	2.000000e-07	5.009804e-07	5.059904e-07	4.999999e+00
3	4.000000e-07	5.009804e-07	5.059904e-07	4.999999e+00
4	8.000000e-07	5.009804e-07	5.059904e-07	4.999999e+00
5	1.600000e-06	5.009804e-07	5.059904e-07	4.999999e+00
6	3.200000e-06	5.009804e-07	5.059904e-07	4.999999e+00
7	6.400000e-06	5.009804e-07	5.059904e-07	4.999999e+00
8	1.280000e-05	5.009804e-07	5.059904e-07	4.999999e+00
9	2.280000e-05	5.009804e-07	5.059904e-07	4.999999e+00
10	3.280000e-05	5.009804e-07	5.059904e-07	4.999999e+00
11	4.280000e-05	5.009804e-07	5.059904e-07	4.999999e+00
12	5.280000e-05	5.009804e-07	5.059904e-07	4.999999e+00
13	6.280000e-05	5.009804e-07	5.059904e-07	4.999999e+00
14	7.280000e-05	5.009804e-07	5.059904e-07	4.999999e+00
15	8.280000e-05	5.009804e-07	5.059904e-07	4.999999e+00
16	9.280000e-05	5.009804e-07	5.059904e-07	4.999999e+00
17	1.028000e-04	5.009804e-07	5.059904e-07	4.999999e+00
18	1.128000e-04	5.009804e-07	5.059904e-07	4.999999e+00
19	1.228000e-04	5.009804e-07	5.059904e-07	4.999999e+00
20	1.328000e-04	5.009804e-07	5.059904e-07	4.999999e+00
21	1.428000e-04	5.009804e-07	5.059904e-07	4.999999e+00
22	1.528000e-04	5.009804e-07	5.059904e-07	4.999999e+00
23	1.628000e-04	5.009804e-07	5.059904e-07	4.999999e+00
... (1048 more rows) ...

Common mistakes and how to avoid them

  1. Reversed Photodiode: Unlike regular LEDs, photodiodes must be connected in reverse bias (Cathode to positive side, Anode to negative side) to detect light. If connected forward, it acts like a normal diode and clamps the voltage, disabling the sensor.
  2. Misalignment: IR light is highly directional. If the Tx LED and Rx Photodiode are not pointing directly at each other, the alarm will stay ON permanently.
  3. Ambient Light Interference: Strong sunlight or overhead lamps can flood the photodiode, keeping the voltage low even when you block the IR beam. Use a small tube or black tape around the photodiode to shield it from side light.

Troubleshooting

  • Alarm never turns ON:
    • Cause: Transistor base not receiving enough voltage.
    • Fix: Check if the object is truly blocking the light. Increase R2 (e.g., to 220 kΩ) to make the pull-up stronger against leakage.
  • Alarm never turns OFF:
    • Cause: Photodiode not receiving enough IR light to pull the base voltage down.
    • Fix: Re-align the LEDs. Decrease R1 to make the IR LED brighter (do not go below 100 Ω). Ensure the photodiode is inserted with the correct polarity.
  • System flickers:
    • Cause: Edge detection or unstable light source.
    • Fix: Ensure the power supply is stable. Add a small capacitor (e.g., 100 nF) between V_SENSE and GND to filter noise (note: this slows response slightly).

Possible improvements and extensions

  1. Schmitt Trigger: Replace the simple transistor driver with a Schmitt Trigger (or 555 timer) to prevent the LED from fading in/out effectively creating a «snap» action switch.
  2. Modulation: Use a 38 kHz receiver module (like a TSOP sensor) and pulse the IR LED at 38 kHz. This makes the system completely immune to sunlight and room lighting.

More Practical Cases on Prometeo.blog

Find this product and/or books on this topic on Amazon

Go to Amazon

As an Amazon Associate, I earn from qualifying purchases. If you buy through this link, you help keep this project running.

Quick Quiz

Question 1: What is the primary function of the IR LED (D1) in this project?




Question 2: Which component acts as the 'Beam receiver' in this circuit?




Question 3: What happens to the Red Alarm LED when the infrared beam is interrupted by an object?




Question 4: What is the expected voltage state at the sensing node when the beam is broken?




Question 5: Based on the context, what is the role of resistor R2 (100 kΩ)?




Question 6: What is the function of the NPN Transistor (Q1) in this circuit?




Question 7: Which of the following is a listed use case for this alarm system?




Question 8: What is the state of the Red Alarm LED when the beam path is clear (intact)?




Question 9: What is the purpose of resistor R1 (220 Ω) connected to D1?




Question 10: What is the target audience for this project?




Carlos Núñez Zorrilla
Carlos Núñez Zorrilla
Electronics & Computer Engineer

Telecommunications Electronics Engineer and Computer Engineer (official degrees in Spain).

Follow me:


Practical case: Photodiode vs photoresistor comparison

Photodiode vs photoresistor comparison prototype (Maker Style)

Level: Basic – Analyze speed and linearity differences between an LDR and a photodiode.

Objective and use case

You will build a dual comparison circuit featuring a Light Dependent Resistor (LDR) and a Photodiode side-by-side, both stimulated by a pulsed LED light source. This setup demonstrates why specific sensors are chosen for different applications based on response time and linearity.

  • High-speed data transmission: Photodiodes are essential for fiber optics and remote controls where signals switch rapidly.
  • Ambient light sensing: LDRs are cost-effective for streetlights (dusk-to-dawn) where reaction speed does not matter.
  • Precision metering: Photodiodes provide a linear current output proportional to light intensity, ideal for lux meters.

Expected outcome:
* LDR Output: A slow, curved voltage response («shark fin» shape) when exposed to a fast-blinking light.
* Photodiode Output: A sharp, square voltage response tracking the light source accurately.
* Voltage Levels: Distinct voltage changes at nodes V_LDR and V_PD corresponding to light intensity.
* Target Audience: Students and hobbyists interested in analog sensors and optoelectronics.

Materials

  • V1: 5 V DC supply, function: Main circuit power.
  • V2: 0 V to 5 V Pulse Generator (100 Hz), function: Driver for the test LED (Stimulus).
  • R1: 330 Ω resistor, function: Current limiting for the stimulus LED.
  • D_STIM: Green LED, function: Light source to trigger sensors (Chosen for distinct forward voltage).
  • R_LDR: Light Dependent Resistor (LDR), function: Slow photo-resistive sensor.
  • R2: 10 kΩ resistor, function: Voltage divider bottom leg for LDR.
  • D_PD: Silicon Photodiode (e.g., BPW34), function: Fast photo-current sensor.
  • R3: 220 kΩ resistor, function: Load resistor to convert photo-current to voltage.

Wiring guide

The circuit consists of three distinct sections: the Stimulus (pulsing light), the LDR divider, and the Photodiode divider.

Stimulus Section:
* V2 (Pulse Source) connects between V_PULSE and 0 (GND).
* R1 connects between V_PULSE and NODE_LED.
* D_STIM (Anode) connects to NODE_LED.
* D_STIM (Cathode) connects to 0 (GND).
* Note: Place D_STIM physically close to both R_LDR and D_PD to ensure they receive the light.

LDR Sensor Section:
* V1 (DC Source) connects between VCC and 0 (GND).
* R_LDR connects between VCC and V_LDR.
* R2 connects between V_LDR and 0 (GND).

Photodiode Sensor Section:
* D_PD (Cathode) connects to VCC. (Note: Photodiodes operate in reverse bias for photoconductive mode).
* D_PD (Anode) connects to V_PD.
* R3 connects between V_PD and 0 (GND).

Conceptual block diagram

Conceptual block diagram — Light Sensor Comparison
Quick read: inputs → main block → output (actuator or measurement). This summarizes the ASCII schematic below.

Schematic

Title: Practical case: Photodiode vs photoresistor comparison

      [ INPUT SOURCES ]               [ SENSOR / OPTICAL BLOCK ]             [ OUTPUTS ]

                                   +--> [ R_LDR: Photoresistor ] --+------> < V_LDR >
                                   |    (Light Dependent Res.)     |
                                   |             ^                 v
                                   |             ~            [ R2: 10k ]
                                   |             ~ Light           |
    ( V1: 5 V DC Supply ) ----------+             ~                GND
                                   |             ~
                                   |             ~
                                   +--> [ D_PD: Photodiode ] ------+------> < V_PD >
                                        (Reverse Biased)           |
                                                 ^                 v
                                                 ~            [ R3: 220k ]
                                                 ~ Light           |
                                                 ~                GND
                                                 ~
                                                 ~
    ( V2: Pulse Gen ) --> [ R1: 330 ] --> [ D_STIM: Green LED ] ----------> GND
Schematic (ASCII)

Electrical diagram

Electrical diagram for case: Practical case: Photodiode vs photoresistor comparison
Generated from the validated SPICE netlist for this case.

🔒 This electrical diagram is premium. With the 7-day pass or the monthly membership you can unlock the complete didactic material and the print-ready PDF pack.🔓 See premium access plans

Measurements and tests

To validate the differences between the sensors, follow these steps:

  1. Static Testing (DC):

    • Turn off V2 (Pulse). Keep V1 (5 V) on.
    • Cover both sensors (Dark condition). Measure voltage at V_LDR and V_PD. Both should be close to 0 V.
    • Shine a constant light (using the Green LED or a flashlight). Measure voltage at V_LDR and V_PD. Both voltages should rise significantly.
  2. Dynamic Testing (AC/Response Time):

    • Enable V2 (Pulse Generator) at 100 Hz (50% duty cycle).
    • Connect Oscilloscope Channel 1 to V_PULSE (Reference).
    • Connect Oscilloscope Channel 2 to V_LDR.
    • Connect Oscilloscope Channel 3 to V_PD.
    • Observation: Compare the waveforms. Channel 3 (Photodiode) should look like a square wave, matching Channel 1. Channel 2 (LDR) will look distorted, with slow rising and falling edges («shark fin»), failing to reach full amplitude if the frequency is too high.

SPICE netlist and simulation

Reference SPICE Netlist (ngspice) — excerptFull SPICE netlist (ngspice)

* Practical case: Photodiode vs photoresistor comparison

* --- Component Models ---
* Generic Green LED Model
.model DLED D(IS=1e-22 RS=5 N=1.5 CJO=10p)
* Silicon Photodiode Model (BPW34 - Dark Characteristics)
.model D_BPW34 D(IS=1e-9 RS=5 N=1 CJO=20p)

* --- Power Supplies ---
* V1: Main Circuit Power (5V DC)
V1 VCC 0 DC 5

* V2: Pulse Generator (Stimulus)
* 0V to 5V, 100Hz (10ms period), 50% Duty Cycle
* Rise/Fall time 100us to ensure convergence
V2 V_PULSE 0 PULSE(0 5 0 100u 100u 5m 10m)

* --- Stimulus Section ---
* R1: Current limiting resistor for LED
R1 V_PULSE NODE_LED 330
* ... (truncated in public view) ...

Copy this content into a .cir file and run with ngspice.

🔒 Part of this section is premium. With the 7-day pass or the monthly membership you can access the full content (materials, wiring, detailed build, validation, troubleshooting, variants and checklist) and download the complete print-ready PDF pack.

* Practical case: Photodiode vs photoresistor comparison

* --- Component Models ---
* Generic Green LED Model
.model DLED D(IS=1e-22 RS=5 N=1.5 CJO=10p)
* Silicon Photodiode Model (BPW34 - Dark Characteristics)
.model D_BPW34 D(IS=1e-9 RS=5 N=1 CJO=20p)

* --- Power Supplies ---
* V1: Main Circuit Power (5V DC)
V1 VCC 0 DC 5

* V2: Pulse Generator (Stimulus)
* 0V to 5V, 100Hz (10ms period), 50% Duty Cycle
* Rise/Fall time 100us to ensure convergence
V2 V_PULSE 0 PULSE(0 5 0 100u 100u 5m 10m)

* --- Stimulus Section ---
* R1: Current limiting resistor for LED
R1 V_PULSE NODE_LED 330

* D_STIM: Green LED (Light Source)
* Anode to NODE_LED, Cathode to GND
D_STIM NODE_LED 0 DLED

* --- Light Coupling & Physics Simulation (Behavioral) ---
* These elements simulate the physical behavior of light transfer
* from the LED to the sensors.

* 1. LDR Latency Simulation (RC Filter)
* Simulates the slow response time of the photo-resistive material.
* R_PHYS and C_PHYS create a delay on the control signal.
R_PHYS NODE_LED V_LIGHT_LDR 10k
C_PHYS V_LIGHT_LDR 0 1u

* --- LDR Sensor Section ---
* R_LDR: Light Dependent Resistor
* Modeled as a behavioral resistor (ngspice syntax).
* Resistance varies from ~1Meg (Dark) to ~2k (Light).
* Controlled by the delayed light signal (V_LIGHT_LDR) with a sigmoid transition.
R_LDR VCC V_LDR R = '2k + (1Meg - 2k) / (1 + exp(10 * (V(V_LIGHT_LDR) - 1.0)))'

* R2: Voltage divider bottom leg (10k)
R2 V_LDR 0 10k

* --- Photodiode Sensor Section ---
* D_PD: Silicon Photodiode (BPW34)
* Connected in reverse bias: Cathode to VCC, Anode to V_PD.
D_PD V_PD VCC D_BPW34

* Photocurrent Source (Behavioral)
* Represents the current generated by light (Cathode to Anode).
* Controlled directly by NODE_LED (Fast response).
* Generates ~20uA when LED is ON.
B_PD_PHOTO VCC V_PD I = '20u * (1 / (1 + exp(-10 * (V(NODE_LED) - 1.0))))'

* R3: Load resistor for Photodiode (220k)
* Converts photocurrent to voltage.
R3 V_PD 0 220k

* --- Simulation Directives ---
.op
* Transient analysis: 100us step size, 30ms duration (3 full cycles)
.tran 100u 30m

* Print directives for logging results
.print tran V(V_PULSE) V(NODE_LED) V(V_LDR) V(V_PD)

.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Show raw data table (764 rows)
Index   time            v(v_pulse)      v(node_led)     v(v_ldr)
0	0.000000e+00	0.000000e+00	2.716431e-145	4.950717e-02
1	1.000000e-06	5.000000e-02	4.824684e-02	4.950717e-02
2	1.083830e-06	5.419150e-02	5.230192e-02	4.950717e-02
3	1.251490e-06	6.257451e-02	6.041598e-02	4.950717e-02
4	1.586811e-06	7.934053e-02	7.664554e-02	4.950717e-02
5	2.257451e-06	1.128726e-01	1.091032e-01	4.950717e-02
6	3.598733e-06	1.799366e-01	1.740197e-01	4.950717e-02
7	6.281296e-06	3.140648e-01	3.038499e-01	4.950717e-02
8	1.164642e-05	5.823211e-01	5.635005e-01	4.950718e-02
9	2.048297e-05	1.024149e+00	9.911337e-01	4.950719e-02
10	3.049268e-05	1.524634e+00	1.474550e+00	4.950722e-02
11	3.675621e-05	1.837811e+00	1.660693e+00	4.950724e-02
12	4.338068e-05	2.169034e+00	1.711124e+00	4.950727e-02
13	4.777134e-05	2.388567e+00	1.729852e+00	4.950729e-02
14	5.403581e-05	2.701791e+00	1.750179e+00	4.950731e-02
15	6.656476e-05	3.328238e+00	1.778506e+00	4.950737e-02
16	9.162266e-05	4.581133e+00	1.819947e+00	4.950748e-02
17	1.000000e-04	5.000000e+00	1.831535e+00	4.950751e-02
18	1.050116e-04	5.000000e+00	1.831601e+00	4.950754e-02
19	1.150347e-04	5.000000e+00	1.831470e+00	4.950759e-02
20	1.350811e-04	5.000000e+00	1.831473e+00	4.950768e-02
21	1.751737e-04	5.000000e+00	1.831478e+00	4.950788e-02
22	2.553590e-04	5.000000e+00	1.831491e+00	4.950831e-02
23	3.553590e-04	5.000000e+00	1.831507e+00	4.950895e-02
... (740 more rows) ...

Common mistakes and how to avoid them

  1. Reversing the Photodiode: A photodiode in a divider setup usually requires reverse bias (Cathode to VCC). If connected forward (Anode to VCC), it acts like a normal diode, clamping the voltage and ruining the sensing range.
  2. Using too small a resistor for the Photodiode: Photodiodes generate very small currents (microamps). Using a 1 kΩ resistor for R3 will result in tiny signals. We use 220 kΩ here to ensure the output voltage swing is large enough to see clearly on an oscilloscope.
  3. Expecting the LDR to react instantly: Students often think the circuit is broken because the LDR signal looks «rounded» or «wavy» at high frequencies. This is the inherent physical limitation of the chemical material (Cadmium Sulfide), not a wiring error.

Troubleshooting

  • Symptom: No voltage change on V_PD when light shines.
    • Cause: Photodiode might be reversed or R3 is too small for the ambient light level.
    • Fix: Ensure Cathode is at VCC and Anode is at the measurement node. Check that the Stimulus LED is actually blinking and bright enough.
  • Symptom: V_LDR is always stuck at High (near 5 V).
    • Cause: R_LDR resistance is too low compared to R2, or ambient light is too bright.
    • Fix: Ensure the «dark» test is actually dark. Decrease R2 if the LDR resistance is naturally low.
  • Symptom: V_PD signal is extremely noisy.
    • Cause: High impedance node (V_PD with 220 kΩ resistor) picks up mains hum (50/60Hz).
    • Fix: Use shorter wires or add a small capacitor (e.g., 100pF) in parallel with R3, though this slightly reduces speed.

Possible improvements and extensions

  1. Transimpedance Amplifier (TIA): Replace the passive resistor R3 with an Op-Amp configured as a transimpedance amplifier. This provides a much faster response and a low-impedance output suitable for driving other circuits.
  2. Frequency Sweep: Use a variable frequency generator for V2. Slowly increase the frequency from 10 Hz to 10 kHz to find the «cutoff frequency» where the LDR stops responding completely, while the photodiode continues to work.

More Practical Cases on Prometeo.blog

Quick Quiz

Question 1: What is the primary objective of the dual comparison circuit described?




Question 2: Which sensor is identified as essential for high-speed data transmission like fiber optics?




Question 3: What is a typical use case mentioned for LDRs where reaction speed is not critical?




Question 4: How is the LDR's voltage response described when exposed to a fast-blinking light?




Question 5: Which component acts as the light stimulus for the sensors in this experiment?




Question 6: Why are photodiodes preferred for precision metering applications?




Question 7: What is the expected shape of the Photodiode output voltage?




Question 8: Which characteristic makes LDRs suitable for streetlights but not fiber optics?




Question 9: What distinct outcome is expected at the voltage nodes V_LDR and V_PD?




Question 10: Who is the primary target audience for this circuit experiment?




Carlos Núñez Zorrilla
Carlos Núñez Zorrilla
Electronics & Computer Engineer

Telecommunications Electronics Engineer and Computer Engineer (official degrees in Spain).

Follow me:


Practical case: Simple twilight switch

Simple twilight switch prototype (Maker Style)

Level: Basic. Objective: Build a circuit that activates an LED when light levels drop.

Objective and use case

In this practical case, you will design and assemble a light-sensing circuit that automatically turns on an LED when the environment becomes dark. This circuit uses a photodiode to control an NPN transistor acting as a switch.

  • Real-world applications:
    • Automatic street lighting systems.
    • Emergency corridor lights that activate during power outages (if light absent).
    • Battery-saving garden solar lights.
    • Security systems triggered by shadows or obstruction of light beams.
  • Expected outcome:
    • Bright light: The LED remains OFF; the voltage at the transistor base is low.
    • Darkness: The LED turns ON; the voltage at the transistor base rises above 0.7 V.
    • Transition: The circuit reacts to the absence of light (dark sensor logic).
  • Target audience: Beginners and electronics students.

Materials

  • V1: 5 V DC supply, function: main power source.
  • R1: 100 kΩ resistor, function: base pull-up resistor (sets sensitivity).
  • R2: 330 Ω resistor, function: LED current limiting.
  • D1: Generic silicon photodiode, function: light sensor.
  • Q1: 2N2222 (or BC547) NPN Transistor, function: electronic switch.
  • D2: Red LED, function: visual output indicator.

Wiring guide

This guide uses specific node names to define the connections clearly.
* Nodes defined: VCC (5 V), GND (0 V), V_BASE (Control voltage), V_COL (Collector voltage).

  • V1 (Source): Connect positive terminal to VCC and negative terminal to GND.
  • R1 (Bias): Connect between VCC and V_BASE.
  • D1 (Photodiode):
    • Connect the Cathode to V_BASE.
    • Connect the Anode to GND.
    • Note: The photodiode is used in reverse bias mode.
  • Q1 (Transistor):
    • Connect the Base to V_BASE.
    • Connect the Emitter to GND.
    • Connect the Collector to V_COL.
  • R2 & D2 (Output Loop):
    • Connect R2 between VCC and the Anode of D2.
    • Connect the Cathode of D2 to V_COL (the Collector of Q1).

Conceptual block diagram

Conceptual block diagram — 74HC14 Photodiode
Quick read: inputs → main block → output (actuator or measurement). This summarizes the ASCII schematic below.

Schematic

[ INPUT / SENSING ]                     [ LOGIC / SWITCHING ]                   [ OUTPUT / LOAD ]

      [ VCC (5 V) ]                                                                       [ VCC (5 V) ]
           |                                                                                  |
           |                                                                                  |
           v                                                                                  v
    [ R1: 100k Bias ] --(Pull Up)--+                                                  [ R2: 330 Ohm ]
                                   |                                                          |
                                   |                                                          |
                                (V_BASE)                                                      v
                                   |                                                    [ D2: Red LED ]
                                   |                                                          |
                                   +--(Control Sig)--> [ Q1: NPN Base ]                       |
                                   |                   [              ]                       |
                                   |                   [ Q1 Collector ] <--(Sink Current)-----+
    [ D1: Photodiode ] --(Sensor)--+                   [              ]                 (V_COL Node)
    (Reverse Biased)               |                   [ Q1 Emitter   ]
           |                       |                          |
           |                       |                          |
           v                       |                          v
        [ GND ]                    +---------------------> [ GND ]
Schematic (ASCII)

Electrical diagram

Electrical diagram for case: Practical case: Simple twilight switch
Generated from the validated SPICE netlist for this case.

🔒 This electrical diagram is premium. With the 7-day pass or the monthly membership you can unlock the complete didactic material and the print-ready PDF pack.🔓 See premium access plans

Measurements and tests

Perform the following validation steps using a multimeter to ensure the circuit works as intended.

  1. Check Supply Voltage:
    • Measure between VCC and GND. It should read approximately 5 V.
  2. Test Light Condition (LED OFF):
    • Shine a bright light directly on the photodiode D1.
    • Measure voltage at V_BASE. It should be low (typically < 0.5 V) because the photodiode conducts current to ground.
    • Observe D2 (LED). It should be OFF.
    • Measure voltage at V_COL. It should be close to VCC (High) as the transistor is in cutoff.
  3. Test Dark Condition (LED ON):
    • Cover D1 completely with your hand or a dark cap.
    • Measure voltage at V_BASE. It should rise above 0.6 V – 0.7 V.
    • Observe D2 (LED). It should turn ON.
    • Measure voltage at V_COL. It should drop to near 0 V (saturation voltage ~0.2 V).

SPICE netlist and simulation

Reference SPICE Netlist (ngspice) — excerptFull SPICE netlist (ngspice)

* Practical case: Simple twilight switch

* --- Power Supply ---
* V1: 5 V DC supply
V1 VCC 0 DC 5

* --- Input Stage (Light Sensor) ---
* R1: 100 kΩ resistor (Base pull-up)
* Connect between VCC and V_BASE
R1 VCC V_BASE 100k

* D1: Generic silicon photodiode
* Connect the Cathode to V_BASE, Anode to GND (Reverse Bias)
* SPICE Syntax: Dname Anode Cathode Model
D1 0 V_BASE D_GENERIC

* OPTICAL STIMULUS SIMULATION
* The photodiode generates a photocurrent flowing from Cathode to Anode 
* (Reverse current) proportional to light intensity.
* We simulate this with a Current Source (I_LIGHT) in parallel with D1.
* ... (truncated in public view) ...

Copy this content into a .cir file and run with ngspice.

🔒 Part of this section is premium. With the 7-day pass or the monthly membership you can access the full content (materials, wiring, detailed build, validation, troubleshooting, variants and checklist) and download the complete print-ready PDF pack.

* Practical case: Simple twilight switch

* --- Power Supply ---
* V1: 5 V DC supply
V1 VCC 0 DC 5

* --- Input Stage (Light Sensor) ---
* R1: 100 kΩ resistor (Base pull-up)
* Connect between VCC and V_BASE
R1 VCC V_BASE 100k

* D1: Generic silicon photodiode
* Connect the Cathode to V_BASE, Anode to GND (Reverse Bias)
* SPICE Syntax: Dname Anode Cathode Model
D1 0 V_BASE D_GENERIC

* OPTICAL STIMULUS SIMULATION
* The photodiode generates a photocurrent flowing from Cathode to Anode 
* (Reverse current) proportional to light intensity.
* We simulate this with a Current Source (I_LIGHT) in parallel with D1.
* Logic: 
*   0uA = Dark (Night) -> Base High -> Q1 ON -> LED ON
*   100uA = Light (Day) -> Base Low -> Q1 OFF -> LED OFF
* Waveform: Dark (0uA) transitioning to Light (100uA)
I_LIGHT V_BASE 0 PULSE(0 100u 100u 100u 100u 2m 5m)

* --- Switching Stage ---
* Q1: 2N2222 NPN Transistor
* Base to V_BASE, Emitter to GND, Collector to V_COL
* SPICE Syntax: Qname Collector Base Emitter Model
Q1 V_COL V_BASE 0 2N2222

* --- Output Stage ---
* R2: 330 Ω resistor
* Connect between VCC and the Anode of D2 (Node V_LED_ANODE)
R2 VCC V_LED_ANODE 330

* D2: Red LED
* Connect Anode to V_LED_ANODE, Cathode to V_COL
D2 V_LED_ANODE V_COL LED_RED

* --- Models ---
* Standard NPN Transistor Model
.model 2N2222 NPN (IS=1E-14 VAF=100 BF=200 IKF=0.3 XTB=1.5 BR=3 CJC=8E-12 CJE=25E-12 TR=46.91E-9 TF=411.1E-12 ITF=0.6 VTF=1.7 XTF=3 RB=10 RC=1 RE=0.1)

* Generic Red LED Model (Approx 1.8V-2V drop)
.model LED_RED D (IS=93.2p RS=42m N=3.73 BV=5 IBV=10u CJO=2.97p VJ=0.75 M=0.333 TT=4.32u)

* Generic Silicon Diode Model for Photodiode (Dark characteristics)
.model D_GENERIC D (IS=1N N=1 RS=0.1)

* --- Analysis Directives ---
* Transient analysis to show the switching behavior
.tran 10u 5m

* Print required voltages to verify operation
* V(V_BASE): Sensor voltage (High = Dark, Low = Light)
* V(V_COL): Output state (Low = LED ON, High/Floating = LED OFF)
.print tran V(V_BASE) V(V_COL)

.op
.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Show raw data table (534 rows)
Index   time            v(v_base)       v(v_col)
0	0.000000e+00	7.119659e-01	4.863696e-01
1	1.000000e-07	7.119659e-01	4.863696e-01
2	2.000000e-07	7.119659e-01	4.863696e-01
3	4.000000e-07	7.119659e-01	4.863696e-01
4	8.000000e-07	7.119659e-01	4.863696e-01
5	1.600000e-06	7.119659e-01	4.863696e-01
6	3.200000e-06	7.119659e-01	4.863696e-01
7	6.400000e-06	7.119659e-01	4.863696e-01
8	1.280000e-05	7.119659e-01	4.863696e-01
9	2.280000e-05	7.119659e-01	4.863696e-01
10	3.280000e-05	7.119659e-01	4.863696e-01
11	4.280000e-05	7.119659e-01	4.863696e-01
12	5.280000e-05	7.119659e-01	4.863696e-01
13	6.280000e-05	7.119659e-01	4.863696e-01
14	7.280000e-05	7.119659e-01	4.863696e-01
15	8.280000e-05	7.119659e-01	4.863696e-01
16	9.280000e-05	7.119659e-01	4.863696e-01
17	1.000000e-04	7.119659e-01	4.863696e-01
18	1.006859e-04	7.117420e-01	5.075675e-01
19	1.020576e-04	7.110644e-01	5.716214e-01
20	1.044620e-04	7.094358e-01	7.222583e-01
21	1.068767e-04	7.077111e-01	8.743413e-01
22	1.096009e-04	7.056321e-01	1.048175e+00
23	1.150494e-04	7.009675e-01	1.400214e+00
... (510 more rows) ...

Common mistakes and how to avoid them

  1. Reversing the Photodiode:
    • Error: Connecting the Anode to Base and Cathode to Ground.
    • Result: The diode acts like a standard forward-biased diode, clamping the Base to ~0.7 V permanently or conducting fully, preventing the switching logic.
    • Solution: Ensure the Cathode (marked with a line or flat side) connects to the positive side (Base) for reverse bias operation.
  2. Incorrect Transistor Pinout:
    • Error: Swapping Collector and Emitter on the 2N2222.
    • Result: The gain is significantly reduced, and the LED may not turn on fully or the transistor might overheat.
    • Solution: Verify the pinout (E-B-C) in the datasheet before insertion.
  3. Wrong Resistor Value for R1:
    • Error: Using a very low value (e.g., 1 kΩ) for R1.
    • Result: The photodiode current cannot pull the voltage down enough in bright light, keeping the LED ON permanently.
    • Solution: Use a high value (100 kΩ to 330 kΩ) to allow the small photocurrent to control the voltage divider effectively.

Troubleshooting

  • Symptom: LED is always ON, even in bright light.
    • Cause: R1 is too small, or the ambient light is not strong enough to generate sufficient photocurrent.
    • Fix: Increase R1 to 220 kΩ or 330 kΩ, or bring the light source closer.
  • Symptom: LED is always OFF, even in total darkness.
    • Cause: Photodiode is shorted, R1 is open, or Transistor is blown.
    • Fix: Check continuity on R1. Remove D1; if LED turns on, D1 was shorted or installed backward (forward biased).
  • Symptom: LED glows dimly in the dark.
    • Cause: Q1 is not fully saturating.
    • Fix: Decrease R2 slightly (ensure it stays above 220 Ω) or check if V1 is actually 5 V.

Possible improvements and extensions

  1. Sensitivity Adjustment: Replace R1 with a 500 kΩ potentiometer (in series with a 10 kΩ safety resistor) to manually tune the light level at which the LED triggers.
  2. Hysteresis/Clean Switching: Add a second transistor or a Schmitt Trigger (e.g., 74HC14) between the photodiode node and the driver transistor to prevent the LED from flickering at the «twilight» threshold.

More Practical Cases on Prometeo.blog

Find this product and/or books on this topic on Amazon

Go to Amazon

As an Amazon Associate, I earn from qualifying purchases. If you buy through this link, you help keep this project running.

Quick Quiz

Question 1: What is the primary objective of the circuit described in the text?




Question 2: Which component acts as the electronic switch in this circuit?




Question 3: What happens to the LED when the environment is bright?




Question 4: What is the function of the 330 Ω resistor (R2)?




Question 5: Which voltage threshold at the transistor base is mentioned for turning the LED ON?




Question 6: What real-world application is listed for this type of circuit?




Question 7: What is the role of resistor R1 (100 kΩ)?




Question 8: What is the function of the V1 component in the materials list?




Question 9: How does the circuit behave during the transition from light to dark?




Question 10: Who is the target audience for this circuit project?




Carlos Núñez Zorrilla
Carlos Núñez Zorrilla
Electronics & Computer Engineer

Telecommunications Electronics Engineer and Computer Engineer (official degrees in Spain).

Follow me:


Practical case: Reverse Bias Photodiode Light Detection

Reverse Bias Photodiode Light Detection prototype (Maker Style)

Level: Basic – Understand how a reverse-biased photodiode acts as a light sensor.

Objective and use case

In this practical case, you will build a circuit that utilizes a photodiode in reverse bias mode to detect varying levels of light intensity. By measuring the voltage drop across a series resistor, you will observe the relationship between photon incidence and leakage current.

  • Real-world utility:

    • Optical communications: Used in fiber optic receivers to convert light pulses back into electrical data.
    • Smoke detectors: Detects light scattered by smoke particles in an optical chamber.
    • Ambient light sensors: Adjusts screen brightness on smartphones based on surrounding light.
    • Safety curtains: Stops industrial machinery when a light beam is interrupted.
  • Expected outcome:

    • Dark condition: The voltage output will be near 0 V (minimal dark current).
    • Light condition: The voltage output will rise proportionally to the light intensity.
    • Linearity: The photodiode acts as a current source where Iphoto is linear with respect to illuminance (Lux).
  • Target audience: Students and hobbyists introducing themselves to semiconductor sensors.

Materials

  • V1: 5 V DC supply, function: Reverse bias voltage source.
  • D1: Photodiode (e.g., BPW34 or generic silicon photodiode), function: Light sensor.
  • R1: 100 kΩ resistor, function: Current-to-voltage conversion (Load resistor).
  • L1: White LED or Flashlight, function: External light stimulus.
  • M1: Multimeter, function: Voltmeter for V_OUT.

Wiring guide

This circuit uses a series configuration to measure the reverse photocurrent. We define the nodes as VCC (5 V source), V_OUT (Measurement point), and 0 (Ground).

  • V1: Connect the positive terminal to node VCC and the negative terminal to node 0.
  • D1 (Photodiode): Connect the Cathode (marked side) to node VCC. Connect the Anode to node V_OUT. Note: This ensures the diode is reverse-biased.
  • R1: Connect one leg to node V_OUT and the other leg to node 0.
  • M1 (Voltmeter): Connect the positive probe to V_OUT and the negative probe to 0.

Conceptual block diagram

Conceptual block diagram — LM393 Reverse-Biased Photodiode
Quick read: inputs → main block → output (actuator or measurement). This summarizes the ASCII schematic below.

Schematic

[ STIMULUS & POWER ]               [ SENSOR LOGIC ]                     [ OUTPUT ]

    [ Light Source L1 ] ~~~(Light)~~~>+---------------------+
                                      |    Photodiode D1    |
                                      | (Sensor / Rev Bias) |
    [ 5 V Supply V1 ] -----(VCC)------>| Cathode       Anode |----(V_OUT)---> [ Multimeter M1 ]
                                      +----------+----------+      (Volts)
                                                 |
                                           (Photocurrent)
                                                 |
                                                 v
                                      +----------+----------+
                                      |     Resistor R1     |
                                      |      (100 kΩ)       |
                                      +----------+----------+
                                                 |
                                                 v
                                          [ GND (0 V) ]
Schematic (ASCII)

Electrical diagram

Electrical diagram for case: Reverse Bias Photodiode Light Detection
Generated from the validated SPICE netlist for this case.

🔒 This electrical diagram is premium. With the 7-day pass or the monthly membership you can unlock the complete didactic material and the print-ready PDF pack.🔓 See premium access plans

Measurements and tests

  1. Dark Test: Cover the photodiode completely with an opaque object or your hand. Measure the voltage at V_OUT.
    • Expectation: The reading should be very close to 0 V (typically in the microvolt or low millivolt range), representing the dark current.
  2. Ambient Light Test: Expose the sensor to normal room lighting.
    • Expectation: V_OUT should rise significantly (e.g., 0.5 V to 2.0 V, depending on brightness and the exact value of R1).
  3. High Intensity Test: Shine a flashlight or bright LED (L1) directly at D1.
    • Expectation: V_OUT should increase further, potentially approaching the supply voltage limit if the light is very intense.
  4. Calculation: Use Ohm’s Law to calculate the photocurrent at any specific light level: Ireverse = VOUT / R1.

SPICE netlist and simulation

Reference SPICE Netlist (ngspice) — excerptFull SPICE netlist (ngspice)

* Practical case: Reverse Bias Photodiode Light Detection

* --- Models ---
* Generic Photodiode Model (Approximation for BPW34)
* Parameters: IS (Sat Current), CJO (Junction Cap), BV (Breakdown), RS (Series Res)
.model BPW34 D(IS=10n RS=5 N=1.1 BV=60 IBV=10u CJO=70p M=0.45 VJ=0.75)

* --- Components ---

* V1: 5 V DC supply
* Wiring: Positive to VCC, Negative to 0 (Ground)
V1 VCC 0 DC 5

* D1: Photodiode (Sensor)
* Wiring Guide: Cathode to VCC, Anode to V_OUT
* Note: SPICE Diode syntax is D   
D1 V_OUT VCC BPW34

* L1: External Light Stimulus (White LED/Flashlight)
* Modeled as a Current Source (I_L1) representing the generated photocurrent.
* ... (truncated in public view) ...

Copy this content into a .cir file and run with ngspice.

🔒 Part of this section is premium. With the 7-day pass or the monthly membership you can access the full content (materials, wiring, detailed build, validation, troubleshooting, variants and checklist) and download the complete print-ready PDF pack.

* Practical case: Reverse Bias Photodiode Light Detection

* --- Models ---
* Generic Photodiode Model (Approximation for BPW34)
* Parameters: IS (Sat Current), CJO (Junction Cap), BV (Breakdown), RS (Series Res)
.model BPW34 D(IS=10n RS=5 N=1.1 BV=60 IBV=10u CJO=70p M=0.45 VJ=0.75)

* --- Components ---

* V1: 5 V DC supply
* Wiring: Positive to VCC, Negative to 0 (Ground)
V1 VCC 0 DC 5

* D1: Photodiode (Sensor)
* Wiring Guide: Cathode to VCC, Anode to V_OUT
* Note: SPICE Diode syntax is D   
D1 V_OUT VCC BPW34

* L1: External Light Stimulus (White LED/Flashlight)
* Modeled as a Current Source (I_L1) representing the generated photocurrent.
* In reverse bias, photocurrent flows from Cathode to Anode (internally),
* effectively injecting current from VCC into V_OUT.
* Simulation: Pulsing light from Dark (0A) to Light (30uA).
* Timing: Delay 100us, Rise/Fall 10us, Width 400us, Period 1ms.
I_L1 VCC V_OUT PULSE(0 30u 100u 10u 10u 400u 1m)

* R1: 100 kOhm Load Resistor
* Wiring: One leg to V_OUT, other leg to 0
R1 V_OUT 0 100k

* M1: Multimeter (Voltmeter)
* Function: Measure voltage at V_OUT relative to Ground.
* Implemented via .print output directives below.

* --- Analysis Directives ---

* Transient Analysis:
* Step: 10us, Stop: 3ms (Captures 3 full light pulses)
.tran 10u 3m

* Operating Point Analysis (Initial DC Check):
.op

* Output Printing:
* Prints the voltage at the output node (V_OUT) and supply (VCC)
.print tran V(V_OUT) V(VCC)

.end

Simulation Results (Transient Analysis)

Simulation Results (Transient Analysis)
Show raw data table (347 rows)
Index   time            v(v_out)        v(vcc)
0	0.000000e+00	1.000500e-03	5.000000e+00
1	1.000000e-07	1.000500e-03	5.000000e+00
2	2.000000e-07	1.000500e-03	5.000000e+00
3	4.000000e-07	1.000500e-03	5.000000e+00
4	8.000000e-07	1.000500e-03	5.000000e+00
5	1.600000e-06	1.000500e-03	5.000000e+00
6	3.200000e-06	1.000500e-03	5.000000e+00
7	6.400000e-06	1.000500e-03	5.000000e+00
8	1.280000e-05	1.000500e-03	5.000000e+00
9	2.280000e-05	1.000500e-03	5.000000e+00
10	3.280000e-05	1.000500e-03	5.000000e+00
11	4.280000e-05	1.000500e-03	5.000000e+00
12	5.280000e-05	1.000500e-03	5.000000e+00
13	6.280000e-05	1.000500e-03	5.000000e+00
14	7.280000e-05	1.000500e-03	5.000000e+00
15	8.280000e-05	1.000500e-03	5.000000e+00
16	9.280000e-05	1.000500e-03	5.000000e+00
17	1.000000e-04	1.000500e-03	5.000000e+00
18	1.010000e-04	7.978912e-02	5.000000e+00
19	1.030000e-04	3.507154e-01	5.000000e+00
20	1.070000e-04	1.270928e+00	5.000000e+00
21	1.100000e-04	2.076364e+00	5.000000e+00
22	1.108000e-04	2.250021e+00	5.000000e+00
23	1.124000e-04	2.525718e+00	5.000000e+00
... (323 more rows) ...

Common mistakes and how to avoid them

  1. Forward Biasing the Photodiode: Connecting the Anode to VCC makes the photodiode act like a regular diode (or LED), conducting current constantly regardless of light.
    • Solution: Ensure the Cathode (stripe) connects to the positive supply (VCC).
  2. Resistor Value too Low: Using a 100 Ω or 1 kΩ resistor might result in a voltage output too small for a standard multimeter to read easily.
    • Solution: Use a high value resistor (100 kΩ to 1 MΩ) to convert the small microampere photocurrent into a readable voltage.
  3. Multimeter in Current Mode: Connecting the multimeter in parallel while set to Ammeter mode effectively shorts V_OUT to ground.
    • Solution: Always ensure the multimeter is set to DC Volts and connected in parallel with R1.

Troubleshooting

  • Symptom: Output voltage is always constant near 5 V (VCC).
    • Cause: The photodiode is likely connected in forward bias (Anode to VCC), or the photodiode is shorted.
    • Fix: Reverse the photodiode orientation.
  • Symptom: Output voltage stays at 0 V even with bright light.
    • Cause: Open circuit connections, R1 is shorted, or the photodiode is damaged.
    • Fix: Check continuity on the breadboard; verify D1 is actually a photodiode and not a standard LED (which also produces current but much less).
  • Symptom: Readings are unstable or «jumpy».
    • Cause: Interference from AC powered lights (50/60 Hz flicker) picked up by the high-impedance node V_OUT.
    • Fix: Test using a DC light source (flashlight) or add a small capacitor (e.g., 100 nF) in parallel with R1 to filter noise.

Possible improvements and extensions

  1. Transimpedance Amplifier (TIA): Replace R1 with an Operational Amplifier configured as a TIA. This provides a much faster response time and linear output voltage buffered from the load.
  2. Light Threshold Alarm: Feed V_OUT into a voltage comparator (like an LM393) to trigger a buzzer or LED when the light level exceeds a specific setpoint.

More Practical Cases on Prometeo.blog

        <div class="amazon-affiliate">
          <p><strong>Find this product and/or books on this topic on Amazon</strong></p>
          <p><a class="amazon-affiliate-btn" href="https://amzn.to/4mt8r4C" target="_blank" rel="nofollow sponsored noopener">Go to Amazon</a></p>
          <p class="amazon-affiliate-disclaimer">As an Amazon Associate, I earn from qualifying purchases. If you buy through this link, you help keep this project running.</p>
        </div>

Quick Quiz

Question 1: What is the primary function of the photodiode in the described circuit?




Question 2: In which mode is the photodiode operated in this practical case?




Question 3: What is the role of the series resistor in the circuit?




Question 4: What is the expected voltage output in a 'dark condition'?




Question 5: How does the photodiode behave with respect to illuminance (Lux)?




Question 6: Which of the following is listed as a real-world utility for this circuit?




Question 7: What physical phenomenon is observed when measuring the voltage drop across the resistor?




Question 8: What happens to the voltage output when the light condition changes from dark to light?




Question 9: How are photodiodes utilized in optical communications?




Question 10: What is the function of a photodiode in a smoke detector?




Carlos Núñez Zorrilla
Carlos Núñez Zorrilla
Electronics & Computer Engineer

Telecommunications Electronics Engineer and Computer Engineer (official degrees in Spain).

Follow me: