6
\$\begingroup\$

I read some articles about using an LED as a light sensor. I chose an IR LED and checked the voltage levels produced in different light situations resulting in about 200-300mV in full artificial light and around 30 mV in the dark, which seemed to be fine enough for an analog Arduino/AtTiny pin. The IR sensor LED also worked sufficient on the breadboard, but unfortunately the values seem to get messed up in my soldered setting which is an AtTiny dimming a 10W LED when a PIR gets activated and the light sensor value is low. In this setting I get much less sensitive analog readings from the sensor LED. The main difference are longer connecting cables as I want to place the sensor LED in some distance from the rest of the circuit.

  • Can it be that the current of the LED is too low and therefore the reading gets disturbed by the circuit in some way?

  • May I need a very high pull-down resistor for the sensor because without it the sensor pin floats in the dark?

  • IR is supposed to be the most sensitive but actually I want to measure daylight which has a lower IR part than warm electric light. So maybe another LED would make more sense?

I know there should also be a resistor between the PWM and the MOSFET, but it seemed to work fine on the breadboard without it.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
2
  • \$\begingroup\$ Try connecting a 1M resistor across D2. Think of D2 generating a small current which you pass through a high value resistor to get a measurable voltage. If this doesn't work then reduce the length of the cable between the MCU and the IR LED and see if that has an effect. \$\endgroup\$
    – Steve G
    Nov 16 '18 at 15:14
  • \$\begingroup\$ I think you need to check on the recommended input resistance for your microcontroller's input pin...it is probably in the 10s of kilohm range. You will probably need a buffer amplifier between the sensor LED and the microcontroller, and the buffer will need to have a very high input impedance. \$\endgroup\$ Nov 16 '18 at 15:39
1
\$\begingroup\$

Photo current available from LEDs is tiny. When used in photo-voltaic mode as is done here, a very high-impedance load is required, else measured voltages are reduced. Where you measure 300 mV across the LED with a 10 Megohm voltmeter, LED current is only 30 nA.

Your initial tests on the bare IR LED, using a high-impedance voltmeter (10Megohm) are typical, and suggest that the LED is operating correctly.
The path from a remote LED to microcontroller input pin can be tested in two stages to determine where those tiny photocurrents flow:

  • LED + wires to microcontroller

  • Microcontroller input pin leakage.

Try disconnecting microcontroller input pin. Its leakage current could represent a loading resistance that sucks LED current. Measure LED voltage with a known light source, with microcontroller input pin disconnected.

Microcontroller analog input ADC resistance is specified as "typical" 100 Meg ohms (10X higher than many digital multimeters). Leakage current on a I/O pin is "typical" 50 nA at room temperature, but at high temperature leakage current could be as high as 1000 nA. Your LED is generating currents of similar magnitude - microcontroller leakage could easily be the cause of reduced LED voltage.

Be aware that a long path between LED and microcontroller input pin having high impedance should be avoided - the extra capacitance will make response time slow. And those high-impedance lines allow noise to find its way in. Each and every connection point is a potential leakage path. A high-impedance buffer stage next to the LED would help avoid these problems. A JFET source-follower would be appropriate. A CMOS rail-to-rail opamp could perform a buffer function instead. If an opamp is used, a trans-impedance circuit (requiring only one extra resistor) can provide gain, and low output impedance too. However, these buffer solutions require a third wire to power the buffer.

\$\endgroup\$
1
  • \$\begingroup\$ I'm choosing this as the answer as it points out the various problems when using an LED as a light sensor. I found it best to avoid the effort and now use a standard photo resistor, which gives me far better values. Thanks all for your answers! \$\endgroup\$ Nov 16 '18 at 23:28
0
\$\begingroup\$

An unbuffered photodiode (or LED being used as a photodiode) is not a good stand-alone sensor, particularly to be placed far away from a micro controller ADC pin. It is a very high impedance device so your line might as well be floating.

You should put some additional circuitry that amplifies and buffers its signal so that it is reliable. This is commonly done with an op-amp in a trans-conductance configuration, however this would require providing power to the remote node. You could design a simple circuit with a transistor to amplify the photodiode current that is only connected via a two-wire current loop.

I haven't given too much thought to this, but the following circuit might do the job:

schematic

simulate this circuit – Schematic created using CircuitLab

However, in your case given that this is basically a DC signal, you might be able to get away with just adding a relatively large capacitor (>1µF low-leakage) in parallel with your photodiode and a high-impedance (e.g., 5MΩ) pull-up to provide bias to the node.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.