🔬

Photodetectors


Lesson Objectives:

  1. Understand how a photodiode converts light into current and voltage.
  1. Use Arduino to measure ambient light, darkness, and LED flicker.
  1. Deploy Red Pitaya STEMlab 125-14 to visualize high-speed light fluctuations

Theory & Introduction

Modern sensing systems often need to monitor not only slow changes—like a day/night cycle—but also fast fluctuations, such as flicker in lighting. Flicker can arise from AC mains, poorly regulated LED drivers, or purposeful modulation (e.g. IR remote signals). A photodiode is an ideal sensor for this task: under illumination it produces a current proportional to light intensity, which we can convert to a voltage and digitize with a microcontroller.

Photodiode Basics

  • Structure:
    • A photodiode is a p–n junction operated in reverse bias (or zero bias) so that incoming photons generate electron–hole pairs, resulting in a photocurrent.
  • Linear Response: Iph=R×PI_{\text{ph}} = R \times P
    • Within its operating range, photocurrent IphI{ph} is approximately proportional to incident light power P, where R (A/W) is the responsiveness of the device.
  • Voltage Conversion:
    • To measure this current with an Arduino (which reads voltage), we use a pull-up resistor (here 10 kΩ). The tiny current flowing through the resistor develops a voltage V=Iph×Rpull-up,V = I_{\text{ph}} \times R_{\text{pull-up}}, which the ADC samples.

Why Flicker Matters

  • Health & Comfort:
    • Flicker at 50–60 Hz (or higher harmonics) can cause headaches, eye strain, or neurological effects.
  • Signal Integrity:
    • In optical communications (IR remote controls, LiFi), flicker is the information carrier—so sensing speed and fidelity matter.
  • Performance Diagnosis:
    • Mechanical or electrical faults in lighting fixtures often reveal themselves as irregular flicker patterns.

Arduino vs. High-Speed Analysis

  • Arduino ADC:
    • Pros: Simple, built-in, direct.
    • Cons: Limited sample rate (~10 kS/s), averaging hides fast events.
  • Red Pitaya Oscilloscope:
    • Pros: 125 MS/s sample rate, real-time waveform, FFT analysis.
    • Cons: Requires external setup.
In this lab you will:
  1. Quantify ambient and dark conditions with Arduino’s ADC.
  1. Drive LEDs at controlled flicker rates and observe the photodiode’s analog readings.
  1. Visualize the same flicker in fine detail on the Red Pitaya—capturing fast edges, envelope shape, and spectral content.
By comparing Arduino’s coarse readings to Red Pitaya’s high-speed plots, you’ll learn both the capabilities and limitations of embedded ADCs—and see why high-speed instruments are indispensable for characterizing transient phenomena like light flicker.
 

Hardware Setup

A. Materials Required:

Component
Quantity
Purpose
BPW34 Photodiode
1
Light-to-current sensor
10 kΩ resistor
1
Pull-up resistor (converts current → voltage)
LED + 220 Ω resistor
1
Flicker source
Arduino Uno (or R4)
1
Analog sampling and LED drive
Breadboard & Jumper Wires
1
Prototyping connections
Red Pitaya STEMlab 125-14
1
High-speed oscilloscope & spectrum analyzer

B. Circuit Assembly

Wiring

Pull-up network & photodiode:
  • +5 V → 10 kΩ → junction
  • Photodiode anode → junction → Arduino A0 & Red Pitaya IN1
  • Photodiode cathode → GND
  • Arduino GND ↔ Red Pitaya GND
 
notion image

C. Circuit Diagram

notion image
 

Procedure: Measuring Light Levels

A. Ambient vs. Darkness

// Part A: Ambient vs. Dark const int photoPin = A0; void setup() { Serial.begin(115200); } void loop() { int v = analogRead(photoPin); // 0–1023 Serial.println(v); delay(200); // 200 ms between readings }
  1. Upload the sketch.
  1. Open Tools → Serial Plotter.
  1. Ambient: point photodiode at room light → ~600–800.
  1. Dark: cover photodiode → near 0.
*note that some photodiodes might produce inverted result.

B. Single-LED Steady Illumination

Wiring Update

LED₁ (steady):
  • Arduino D9 → 220 Ω → LED₁ anode
  • LED₁ cathode → GND
Photodiode network remains unchanged.
notion image

Code:

// Part B: Steady LED const int photoPin = A0; const int ledPin = 9; void setup() { pinMode(ledPin, OUTPUT); Serial.begin(115200); } void loop() { digitalWrite(ledPin, HIGH); // LED₁ ON Serial.println(analogRead(photoPin)); delay(200); }

Observation & Explanation

  • When LED₁ turns ON, the photodiode sees maximum light, reading ~1023.
  • Plot: a flat high line—confirms full-scale photodiode response.

C. Single-LED 100 Hz Flicker

Wiring (no change)

  • LED₁ on D9 + photodiode as before.

Code: 100 Hz Blink

// Part C: Manual 100 Hz Flicker const int photoPin = A0; const int ledPin = 9; void setup() { pinMode(ledPin, OUTPUT); Serial.begin(115200); } void loop() { digitalWrite(ledPin, HIGH); delayMicroseconds(5000); // 5 ms ON @100 Hz Serial.println(analogRead(photoPin)); digitalWrite(ledPin, LOW); delayMicroseconds(5000); // 5 ms OFF Serial.println(analogRead(photoPin)); Serial.println("---"); // cycle marker }
  1. Upload the code.
  1. Observe the signal using the red pitaya oscilloscope. The signal captured on the photodiode resembles the square signal (on/off) we are powering the LED with.
    1. notion image
  1. Adjust the 5000 value to explore other frequencies.

D. Dual-LED Flicker & Photodiode Response

In this section, we drive two LEDs at different blink rates and observe how the photodiode “sees” their combined light on the Red Pitaya oscilloscope.

Wiring Update

Add LED₂:
  • Arduino D10 → 220 Ω → LED₂ → GND
Photodiode remains the same:
  • Anode → A0 & Red Pitaya IN1 via 10 kΩ pull-up to +5 V
  • Cathode → GND
notion image

Code: Two-Rate Flicker

// Dual-LED Flicker const int led1Pin = 9; // LED₁ const int led2Pin = 10; // LED₂ void setup() { pinMode(led1Pin, OUTPUT); pinMode(led2Pin, OUTPUT); Serial.begin(115200); } void loop() { // Blink LED₁ at 50 Hz (10 ms on/off) digitalWrite(led1Pin, HIGH); digitalWrite(led2Pin, HIGH); delay(5); digitalWrite(led2Pin, LOW); delay(5); digitalWrite(led1Pin, LOW); digitalWrite(led2Pin, HIGH); delay(5); digitalWrite(led2Pin, LOW); delay(5); }
  • LED₁ toggles at 50 Hz (20 ms period).
  • LED₂ toggles at 100 Hz (10 ms period).
  • The photodiode sees the superposition of both flickers.

Red Pitaya Oscilloscope

  1. Run the dual-blink sketch.
  1. Open Oscilloscope on Red Pitaya.
  1. Set oscilloscope that you see at least 2 periods.
notion image
*differences in 50% signal combinations come from setting up your LEDs unequally in respect to the photodiode.

Connecting Results

  • Envelope (50 Hz): The taller peaks correspond to LED₁ on-cycles.
  • Sub-peaks (100 Hz): Within each 20 ms window, LED₂ adds a faster modulation.
  • Photodiode Output: Shows how two light sources at different frequencies combine into a single analog signal.
By comparing the captured waveform to our code, students can visually confirm superposition of flicker rates and appreciate how the photodiode plus Red Pitaya reveal complex light patterns—insights that simple Arduino sampling alone cannot capture cleanly.

Conclusion

This experiment demonstrated how photodiodes can be used to detect both slow and fast changes in light intensity, and how different tools—Arduino and Red Pitaya—offer complementary insights into signal behavior.
Using the Arduino, we measured ambient light and LED flicker with basic analog readings, suitable for slow or steady signals. However, when analyzing high-frequency flicker (e.g., 100 Hz or dual-LED modulation), the Arduino’s limited sampling rate proved insufficient to capture fine details.
By contrast, the Red Pitaya STEMlab 125-14 provided high-resolution waveform and spectral analysis, revealing the true shape and frequency content of the flicker signals. This allowed us to visualize how multiple light sources interact and how flicker manifests in real-world lighting systems.
The experiment highlighted:
  • The linear response of photodiodes to light intensity.
  • The importance of pull-up resistors for voltage conversion.
  • The limitations of low-speed ADCs in capturing transient phenomena.
  • The value of high-speed tools like Red Pitaya in diagnosing flicker and validating signal integrity.
Overall, this lab provided a practical understanding of light sensing, signal acquisition, and the trade-offs between embedded and high-performance measurement systems—skills essential for designing reliable optical and electronic systems.