Arduino Photodiode Light Sensor (BPW34) Circuit & Code Example

In this tutorial, you’ll learn how to do Arduino Photodiode Interfacing and use the BPW34 photodiode with Arduino as a light intensity sensor. We’ll also create a couple of Arduino Photodiode Light Sensor Example Projects which can be a very good starting point for your Arduino + Photodiode project idea. Without further ado, let’s get right into it!

Table of Contents

  1. Arduino With Photodiode
  2. Arduino Photodiode Circuit Diagram
  3. Arduino Photodiode Code Example
  4. Concluding Remarks

Arduino With Photodiode

A Photodiode is a semiconductor device that’s sensitive to light as it turns light energy into an electric voltage that can push some current into a load. Small photodiodes are typically used for light sensing (intensity measurement) applications, while large photodiode cells are used to generate electric power from natural renewable solar power.

Below is the BPW34 which is a photodiode device that we’ll be using in this tutorial with Arduino to create a light-intensity sensor application.

BPW34-Photodiode

The voltage developed across the photodiode terminals changes with the light intensity that hits the surface of the photodiode device. It can be easily measured with a DMM (digital multimeter) to also identify the diode pins’ polarity.

Photodiode-Light-Sensor-Voltage

Photodiode Applications

  • Solar Tracking
  • Light Intensity Meters
  • Position Sensing
  • Photo-interrupters
  • etc

Buy a BPW34 Photodiode: you can find it here on Amazon.com


Arduino Photodiode Circuit Diagram

We need to design a simple electronic circuit to interface the photodiode device with the Arduino microcontroller to read the output voltage developed across the photodiode when light hits it.

The first and easiest way to achieve this goal is to use a simple resistor as a load across the photodiode terminals and read the voltage developed across the photodiode with any Arduino’s ADC analog input channel pins. The output voltage swing from darkness to full sunlight will be relatively small, therefore the system’s sensitivity is considered a little bit low.

The second circuit design that we’ll go through hereafter adds an OpAmp for signal amplification which makes our system more sensitive to light changes as it amplifies the output voltage developed across the photodiode terminals.

Arduino Photodiode Light Sensor Circuit #1

Here is the Arduino with Photodiode circuit diagram. Note that we’re using a 4.7kΩ resistor here in this circuit.

Arduino Photodiode Light Sensor OpAmp Circuit #2

This is the second circuit design for Arduino with Photodiode + OpAmp.

Note that we’re using the UA741 opAmp, a 10kΩ resistor, and a 100nF capacitor here in this circuit.

Arduino-Photodiode-Light-Sensor-OpAmp-Circuit-Wiring-BPW34

Arduino LDR Light Sensor Interfacing Tutorial

This article will give more in-depth information about LDR light sensors interfacing with Arduino and how to use the LDR for light intensity measurement with Arduino.


Arduino Photodiode Code Example

In this example project, we’ll use an Arduino + Photodiode (BPW34) as a light intensity sensor to measure the ambient light intensity. The analog voltage reading will be sent back to the PC over the serial port and we’ll display it on the serial monitor and the serial plotter.

We’ll test both circuits shown earlier in this project. Using the photodiode only and with the opAmp for output signal amplification.

Arduino Photodiode Circuit Wiring

The wiring diagram for this example project is shown in the previous section, scroll up and check it out. Below is an image of how the whole setup looks like at the end, ready for the test.

Arduino Photodiode Light Sensor Circuit #1

Arduino Photodiode Circuit Example BPW34 Wiring Connection

Arduino Photodiode Light Sensor OpAmp Circuit #2

Arduino-Photodiode-OpAmp-Circuit-Example-BPW34-Wiring-Connection

Code Example

Here is the full code listing for this example.

Code Explanation

setup()

in the setup() function, we’ll initialize the serial port to operate @ 9600bps.

loop()

in the loop() function, we’ll read the analog voltage on the A0 pin, convert the digital value to an analog voltage, and send it over the serial port to the PC where we’ll be monitoring it.

Arduino + Photodiode TinkerCAD Simulation

Here is the simulation result for the first circuit design on the TinkerCAD simulator. You can run it as is, or make a copy, add your own code, and start simulating to see how it’s going to behave.

You can check this simulation project on TinkerCAD using this link.

Arduino Photodiode OpAmp Circuit Example Simulation

Here is the simulation result for the second circuit design (Arduino Photodiode + OpAmp) for signal amplification.

You can check this simulation project on TinkerCAD using this link.

❕ Note

The simulation results are only for logic verification and you should not expect to get the exact same output voltage levels on the real hardware. The results may vary depending on: the resistor value you’re using, the photodiode silicon device itself, or the light source used while testing.

In the hardware testing that I’ve done, the output voltage for the first photodiode circuit swings from 0v (darkness) up to 0.4v (intense light). And for the photodiode + opAmp circuit, the output swings from 2v (darkness) up to 4.2v (intense light).


Required Parts List

Here is the full components list for all the parts that you’d need to perform the practical LABs mentioned here in this article and for the whole Arduino Programming series of tutorials found here on DeepBlueMbedded. Please, note that those are affiliate links and we’ll receive a small commission on your purchase at no additional cost to you, and it’d definitely support our work.

QTY.Component NameBuy Link
1Photodiode (BPW34)Amazon
1741 OpAmp ICAmazon
1Arduino UNO KitAmazon
1BreadBoardAmazon
1LEDs KitAmazon
1Capacitors KitAmazon Amazon
1Jumper Wires PackAmazon Amazon
19v Battery or DC Power SupplyAmazon
1Push ButtonsAmazon
1PotentiometerAmazon

Download Attachments

You can download all attachment files for this Article/Tutorial (project files, schematics, code, etc..) using the link below. Please consider supporting my work through the various support options listed in the link down below. Every small donation helps to keep this website up and running and ultimately supports our community.


Concluding Remarks

To conclude this tutorial, we can say that you can easily interface a photodiode with Arduino and use it as a light sensor for measuring the ambient light intensity. Try the provided example circuits on your hardware setup or at least run them in the TinkerCAD simulation environment to maximize the information gained from this tutorial.

If you’re just getting started with Arduino, you need to check out the Arduino Getting Started [Ultimate Guide] here.

And follow this Arduino Series of Tutorials to learn more about Arduino Programming.

Arduino Phototransistor Circuit & Code Example Tutorial

In this tutorial, you’ll learn how to interface Arduino with Phototransistor devices and use it as a light-intensity sensor or darkness-light detector.

Share This Page With Your Network!
Join Our +25,000 Newsletter Subscribers!

Stay Updated With All New Content Releases. You Also Get Occasional FREE Coupon Codes For Courses & Other Stuff!

Photo of author
Author
Khaled Magdy
Embedded systems engineer with several years of experience in embedded software and hardware design. I work as an embedded SW engineer in the Automotive & e-Mobility industry. However, I still do Hardware design and SW development for DSP, Control Systems, Robotics, AI/ML, and other fields I'm passionate about.
I love reading, writing, creating projects, and teaching. A reader by day and a writer by night, it's my lifestyle. I believe that the combination of brilliant minds, bold ideas, and a complete disregard for what is possible, can and will change the world! I will be there when it happens, will you?

1 thought on “Arduino Photodiode Light Sensor (BPW34) Circuit & Code Example”

Leave a Comment