Close

Light Sensor based on an LED

A project log for Sensors Based on the Padauk RFC Peripheral

Exploring the undocumented Resistance to Frequency Converter (RFC) peripheral of the Padauk PFS173 Microcontroller

timTim 09/14/2020 at 23:310 Comments

Using LEDs as light sensors is a hack tried by many. If operated under reverse bias conditions, LEDs act as photodiodes. Due to their small size, the generated photocurrent is extremely small, so some tricks have to be employed to measure it.
The RFC allows for a very simple implementation. The circuit is shown above - the LED is connected with the anode to the RFC pin and the cathode to VDD. During the reset, the ground switch will charge the junction capacitance of the LED to 0.8xVDD negative bias. The photocurrent generated in the LED will slowly discarge this capacitance until the upper threshold is reached. The photocurrent is directly proportional to the number of counts within a certain time internal.


I tested the concept with a red 5mm LED. Counting time was 500 ms. With these settings it was clearly possible to discern different light level from total darkness to direct bright light as shown in the table above.

Since the GPIO can be reconfigured, it would be possible to use an LED in dual function as a light detector and indicator without having to add additional parts.

A quick estimation how much current we are measuring:

=> Iph = cnts * 50pF*3V/500ms = cnts * 300 pA

One count corresponds to only 300 pA of photocurrent!

Of course, there are numerous imperfections in this set up, including leakage currents and nonlinear C(V) behavior, so we cannot expect a highly linear light sensor from this. But it should be sufficient if only a threshold needs to be detected.

Discussions