// Define the analog input pin connected to the photodiode and the op-amp output
const int photodiodePin = 12 ;
const int amplifierPin =10;
// Define the LED pin if necessary
const int ledPin = 4;
void setup() {
// Initialize the LED pin as an output if used
pinMode(ledPin, OUTPUT);
// Initialize the analog input pin
pinMode(photodiodePin, INPUT);
pinMode(amplifierPin, INPUT);
// Initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
void loop() {
// Read the input on the amplifier pin:
int photodiodeValue = analogRead(photodiodePin);
int amplifierValue = analogRead(amplifierPin);
// Turn on the LED for indication
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(photodiodePin,HIGH);
// Turn on the LED for indication
digitalWrite(ledPin, LOW);
delay(1000);
// Convert the analog readings (which range from 0 - 1023) to voltage
float photodiodeVoltage = photodiodeValue * (3.3 / 1023.0);
float amplifierVoltage = amplifierValue * (3.3 / 1023.0);
//Print out the raw analog values and voltage values you read:
Serial.print("Photodiode Value: ");
Serial.print(photodiodeValue);
Serial.print(" | Amplifier Value: ");
Serial.print(amplifierValue);
Serial.print(" | Photodiode Voltage: ");
Serial.print(photodiodeVoltage);
Serial.print(" V | Amplifier Voltage: ");
Serial.println(amplifierVoltage);
// Wait for a second before the next loop
delay(1000);
this is a snippet of my code. However the photodiode isnt printing any value. but the amplfier prints values. I'm wondering how thats possible. The photodiode is connected in reverse bias
the image i have uploaded is the actual project i am working on. however the photodiode doesnt seem to print any value. The photodiode used is BPW21R, the amplifier is OPA380, ADC is ADC121C021. The reason for giving 3.3V was test the project with that before supplying the circuit with 5V
It is real project i'm working on, the idea of tinkercard was to get the photodiode to work. I just uploaded a schematic of the entire project im working on. Let me know if you can see it.
Nope, they don't. My actual circuit doesnt work and I cant also read values from the photodiode. I'm also wondering why the amplifier gives an output but the photodiode doesn't. The amplifier value is also very low. I get a value around 0.5V. which is too small.
I'm sorry about that. In the actual hardware, I am using esp32-wroom-32E. I couldnt not exact components in KiCad thats why i used those components. for the photodiode, i uploaded the spice models for the photodiode, amplifier and ADC. I hope this clarifies the schematics. Also, the resistor and capacitor values are same as my hardware
No it doesn't. I have no idea if you have thing connected the right way if you use substitute components, that may or may have the same pinout.
Also the image is very blurry and I can't make out part numbers
Where is the photodiode?
Hint: using pencil and paper, it is quite easy to make a schematic that has the correct parts, legible pin numbers, legible device IDs and correct connections. Post a photo.
how is d2 connected to the op-amp ( I think you need to connect the catode to the inverting input )?
did you also connect the catode to an analog pin of the esp32 ( don't do that )?
ADDITION
also the capacitor in series with the output of the op-amp what is used for ( remove it )
and why connecting io4 directly to vcc ( quite dangerous )?