Can LED be used for both light emission and sensing

Try this circuit:

schematic

simulate this circuit – Schematic created using CircuitLab

The transistor (non critical, any general purpose NPN will likely work) amplifies the weak photocurrent from the LED used as a photodiode. Make sure you get the polarity right on the LED or you will damage the LED and the transistor. Connect a 1K in series with the LED if you are not sure (the LED should not light!). A couple hundred nA from the LED/PD should drive the input low (assuming there is no additional loading from the input eg. pullup).

The LED will produce a current from wavelengths that are similar or less than the emission spectrum, so a green LED will respond to blue (or green) light but not respond to red light.


If you wanted an analog voltage to feed to an ADC to measure the light, you can use a high value resistor (eg. 20M\$\Omega\$) and an op-amp voltage follower buffer (eg. MCP6001). The resistor value may be higher or lower depending on the desired sensitivity and the particular LED you happen to find- commercial photodiodes with guaranteed specs can be quite cheap if you tire of characterizing parts yourself (or they can be very expensive if you need high performance - eg. 300ps response time, 50pA dark current and ~1A/W sensitivity)


Yes, a LED can be used as a sensor. It gives output current proportional to light intensity, similar to a solar cell. But because its area is very small, current is also very small.
You can measure photocurrent with a digital voltmeter. Most meters have input resistance of 10 MEGohms, and you will be measuring current through this resistance. So if your voltmeter displays "0.1V", then photocurrent is 10 nA.

Your stock RPI has no voltmeter function. Arduino is able to measure analog voltage, but it likely has smaller internal resistance than a standard voltmeter. You can either use an op-amp buffer circuit, or use an op-amp transimpedance amplifier that converts input current to output voltage.

schematic

simulate this circuit – Schematic created using CircuitLab

Supply connections to the op-amp are not shown in Circuit-Lab. Connect the negative supply to "Vss", and the positive supply to +3.6V or to +5V. The second circuit is better than the first. The LED in the first circuit self-limits to something less than a few volts, whereas the second circuit is limited by the DC supply voltage. Note that a single-supply op-amp is required whose common-mode input range includes the negative supply rail (Vss in this case)...not every op-amp has this feature.