LEDs are a wonderful technology. You put in a little bit of power, and you get out a wonderful amount of light. They’re efficient, cheap, and plentiful. We use them for so much!
What you might not have known is that these humble components have a secret feature, one largely undocumented in the datasheets. You can use an LED as a light source, sure, but did you know you can use one as a sensor?
Dual-Use Devices
The concept of using an LED as a sensor is much like using a speaker as a microphone. Flip things around, and instead of emitting light, the LED senses it instead. You can see the effect quite simply by using a multimeter. Hook up the leads of a multimeter to your LED, and set it to measure current. Point the LED towards the sun, and you’ll likely pick up a reading. While the LED is sensitive to light, it’s usually on quite a small range of wavelength, unlike traditional photodiodes.
![](https://hackaday.com/wp-content/uploads/2015/10/led-5-alt.jpg?resize=400,286)
But how to use this effect? Well, you can go multiple routes. If you’re of the analog tilt, you can hook the LED up to the inputs of an op-amp, using the device to amplify the output if you so desire. Just about any garden-variety op-amp can be used in such a way that it produces a higher output voltage the more light falls on the LED.
![](https://hackaday.com/wp-content/uploads/2024/07/Screenshot-2024-07-18-175501.png?w=400)
However, you can go so much further, as the bright minds at Mitsubishi Electric Research Laboratories (MERL) determined back in 2003. Following their example, you might like to hook the LED up to a microcontroller. Setting it up in a “reverse biased” mode allows it to act as a sensor when attached to an IO pin, instead of acting as a light emitter. To do this, simply attach the LED’s anode to ground, while connecting the cathode to an I/O pin in a high state. This achieves the “reverse bias,” and charges the inherent capacitance of the LED. The capacitance is small, so this only takes a fraction of a second. Then, the IO pin can be switched to an input, and the capacitance of the LED will discharge into the microcontroller pin. The more light, the more current induced in the LED, and the faster the LED’s capacitance will discharge. Measure how long it takes for the voltage to drop below the IO pin’s digital logic level, and you can sense light levels with a simple IO pin.
![](https://hackaday.com/wp-content/uploads/2024/07/Screenshot-2024-07-18-175637.png?w=400)
In fact, the team at MERL realized that you could go even further. The humble LED could become a “last centimeter” communications device, used as both light transmitter and receiver. To achieve this, one simply had to insert the LED between two tristate IO pins on a microcontroller. With the anode driven high and the cathode driven low, the LED would light. Flipped the other way, and the LED would be reverse biased. Then, one of the tristate pins could be set to input mode to read the LED as a sensor.
As suggested by the team at MERS, LEDs can be used as sensors in all kinds of innovative applications. You could use a TV’s power LED to detect light levels, and thus adjust screen brightness appropriately. You can even do simple proximity sensing, using an array of LEDs to act as emitters and sensors in turn. You could even use status LEDs on small devices to do bidirectional communication if you were so inclined.
And yet! We almost never use LEDs for any of these things. Realistically, while LEDs are sensors, they’re not excellent sensors. We have far better phototransistors, photodiodes, and other sensors available these days. This technique could be useful to you, if you’re trying to design a device with the bare minimum part count or as cheaply as possible. Or, if you want to put surprise functionality into a device that has just an LED on board. But in the real world, this technique doesn’t get a whole lot of use. Futzing around with nifty LED tricks takes more engineering time than just speccing a proper sensor, after all.
Still, the technique has found some real applications. LEDs used in this way do have the benefit of being quite selective as to wavelength, and can be quite stable over time. The legendary Forrest Mims took advantage of this, putting LED sensors to use in a variety of scientific apparatus. Indeed, his ozone measurement device relied on this technique, and was so reliable it proved there was a drift error in NASA’s own Nimbus-7 satellite.
![](https://hackaday.com/wp-content/uploads/2024/07/peLED_display_8a322f-e1721289220720.webp?w=309)
There’s also hope in the rapidly-advancing field of perovskite technology. Perovskite LEDs, or PerLEDs, could use advanced semiconductor materials to create devices that act as both good light sources and capable photodetectors. The hope is that they might be good enough to create touchable displays that need no additional sensor for touch. Instead, the PerLED array would act as both display and sensor. However, for now, the research is at an early stage, and the instability of perovskites means any practical applications are a long way off.
It’s also worth noting that this technique doesn’t work on a lot of modern LEDs. Namely, addressable LEDs, self-flashing LEDs, and anything of that ilk. That’s because this technique relies on hooking up a microcontroller directly to the LED die itself. Many modern “smart” LEDs don’t break out the pins themselves, only providing pins for the controller chip inside. Thus, don’t expect to use this technique with your NeoPixels, WS2812Bs, or anything like that.
Ultimately, using LEDs as a sensor is a fun technique. It’s also highly useful if you’re doing specific things with certain wavelengths of light. Barring that, though, it’s a great party trick to keep in your toolbox, because you never know when it’ll come in handy.
Do remember here that this is an unspecified and untested property of LED’s. Some do work quite well as light sensors, while others do not work at all as light sensors, even when they are just a bare die without extra electronics. Fun for experiments, but not good for a real design, as there may also big variances between different batches of the same manufacturer and model, etc.
I knew of this effect and tested this at home. Then a few months later I wanted to demonstrate this, and with that LED it did not work at all.
Also, a story of a design problem. With a old battery powered design, battery life was important, and thus low power design. With the particular microcontroller used, power could be reduced by switching the pins for the LED’s to inputs when the LED’s were of, and this worked nicely in the lab. Once a bunch of these things were sold, they started coming back from the field with premature empty batteries. It turned out that the voltage generated by the LED’s put the input stages into their linear region with enough ambient light, and thus a high current consumption.
Interesting!
Thanks!
I wonder if the LEDs are restricted in their “bandwidth” by the color of the plastic/epoxy that forms their lens.
Good point , as far as I know their sensitivity could extend a little in the Infrared (like cameras CCD). It depends a lot of the window material and its transmittance. The color of it clearly means that the window transmittance is non equal at all wavelength, and this for sure affect the received signal.
The LEDs may be restricted by the use of phosphors to modify the emitted wavelength, since they also modify the incoming wavelength away from where the die is sensitive (= original emitting wavelength)
This is my experience too!
Way back in 2010ish, I bought samples of about 10 different LEDs and picked the one that worked best as mutual sender/receiver. Then I ordered 200 of them for the project.
Maybe a couple months elapsed, but the part numbers were the same and it was a reputable parts house. They were about half as sensitive as the first batch.
Maybe this is why we don’t see this trick used so often in production. It can require a little tweaking. Of course, hackers like to tweak…
The BBC microbit uses this feature to convert its display into a light sensor.
https://microbit.org/projects/make-it-code-it/sunlight-sensor/
I recall an article years ago by Mims describing his legal entanglement with a company regarding the idea of using an LED for both transmission & reception. I don’t recall if he was defending his patent, contesting someone else trying to patent his prior art, or something else…
yup it was bell telephone back then; he presumably invented it, sent the idea to the bell lab who then incorporated it and patented it and did not give him credit
He did that back in 1973 (and the patent battle was in 1979)
https://www.gunn-lee.com/Attorneys/TedLee/Pubs/Siliconnections.pdf
Whenever I see a teardown of one of those ultra cheap fitnes trackers, they usually go “yeah only two LEDs, no sensor, so it’s a fake pulse sensor”. I always wonder if the chinese might use the LED for sensing. But IIRC there is usually just two traces going to the LEDs, so I kinda doubt that would work…
The Keithley 7002 uses LEDs as indicators and sensors with their “light pen” technique to program relay actuations from the front panel.
https://www.eevblog.com/forum/testgear/keithley-7002-switch-system-teardown/
I took a look at the documentation for the Keithley 7002, and it appears to use a traditional light pen where the pen is a sensor that detects the unique timing of each multiplexed LED. There’s no indication that they used the LEDs for sensing.
It makes me wonder if there are devices that are explicitly designed to do both. When I search for fiber optic transceivers, I mostly find SFP modules and similar, and those use two optic fibers, one for each direction. Optical audio has also always been one direction. Are there any modules that do single duplex optical communication through one fiber? (and do those have a light splitter or similar). I think the old IrDa modules also (always?) had separate send and receive channels.
I am guessing that if you attempt to optimize a led to do both, it will neither be a good transmitter nor a good receiver.
There are SFP modules that can send and receive using the same fiber by using different wavelengths (CWDM). Search for SFP Bidi. Youre right, LEDs used as receivers dont make for nice and fast optic communication receivers (<<1MBit afaik), since they arent designed for the task and due to the small DIE area.
And that read cycle requires re-charging
I found out about this back in the late 70’s/early 80s. A led actually can work as a micro solar panel. Place a meter on the led, let the sun hit it and it will make a measurable amount of power.
And before that Forrest used a solar cell as both the sender and receiver in a private two-way IR communicator
I’ve seen people make solar trackers with 4 LEDs, 2 for X & 2 for Y. Add something for shading. If pointed directly at the sun all LEDs will output the same, otherwise slew the panel away from the darker ones.
It was Wilf (Righter?) who designed the original as a two axis BEAM project.
Can’t find it, but from memory back in the BEAM days there was a design for a dragonfly with flapping wings powered solely by a string of green LEDs.
Also in BEAM world, green LEDs were popular as “eyes” for solar seeking photovores.
This isn’t really new, I remember many years ago using one of the glass houses diodes as a light sensor albeit in a manner no where near as ambitious as the writers of this article.
When I started doing electronics the number of times where instructions got the orientation of LEDs wrong in the illustrations was staggering and to this day I occupationally double check myself because I don’t trust my memory of where the cathode and anode are, even if it is seemingly simple.
Decades ago I bought an LED assortment blister pack at RadioShack.
A number of the LEDs had the cathode and anode swapped.
I remember coming across a schematic for firefly light. It used LED both as a light sensor to tell when it’s dark outside, and then as flasher. The light sensing quirk has been known for some years, perhaps a few decades?
The article says 2003 for the MERL paper. That’s two decades now. The Mims analog circuits are even older; the “innovation” in the MERL paper was using a /digital/ I/O.
There are stories of audio amps humming only when the cover is off, cuz…some transistors were encapsulated in not-fully-opaque resin and would pick up 120 Hz from the lighting!
Some of us had to scrape the black paint off an OC71 to make a phototransistor. Point contact Ge diodes were pretty good at converting light to electrons too
Haha. Yo must be around my same age. I do recall the Valvo black elongated germanium transistors and I recall they being sensitive to light. Lovely
(you)
Also use them reversed bussed as a voltage variable capacitor.
Biased
It’s always fun to see Bill (Crash)’s MERL paper come up, when it does. He did (and still does!) some really cool stuff. It’s also weird synchronicity for me just due to the timing of this HaD article; I think maybe a week or so ago I was telling somebody at work about this property of semiconductors junctions and shared the MERL paper with them.
“You Can Use LEDs As Sensors, Too”
Of course you can; same as you can use a phototransistor as an infrared emitter.
With enough voltage you can use pretty much any component as an infrared emitter, just not for very long….
I’ve hooked up IR leds to my oscilloscope to check remote control protocols, pulse widths etc. It’s a handy quick and dirty way. No need for a preamp either.
Nice!
I finally have something to do with my oscilloscope! Thank you 😊
Or if you want to go old school, incandescent bulbs can also be used as a light sensor.
I wonder if it will end up being worth anyone’s trouble to take advantage of this with micro-LED displays, given the relatively high resolution; or if that would be just loads of hassle to do basically the same thing as hiding a little cellphone camera module somewhere on the bezel and calling it good.
From 2009 … Single LED and one resistor connected to a microcontroller as a light sensor and emitter. https://forums.parallax.com/discussion/112786/led-as-light-emitter-and-light-detector
It was over a decade ago and I haven’t been able to find it after several attempts, including by clicking on the LED category-link, but there was an LED matrix or cube that could sense your finger being near different parts of it at different distances, and the software showed a cool 3d effect of it. I assumed it was perhaps a capacitive (or electrostatic? I can’t remember my other guess) effect, but BenHeck at a small conference told me it was just plain acting as a light sensor.
I’ve seen a LED matrix done by having a FET drive each LED and you leave the gate floating. That’s electrostatic though.
A microcontroller could use the LEDs as inputs, then toggle to output to drive them as needed. Rinse & repeat. This is an old idea, as the comment above says.
In 2000 my brother build an instrument for measuring something related to sky color. The device was from “Amateur scientist” article in Scientific American. It used a green LED with lens cut off to leave as little of plastic over the semiconductor as possible.
Germanium diodes sealed in glass are photosensitive. too. I saw so called “spirit radio” that used germanium diode in demodulator exposed to get extra noise into its demodulator for more spirituality. I also saw a photo of 2N3055 without its top cover, that emitted faint light when operating. All semiconductors in general are light-sensitive and also can emit light. However, there is a reason, why we optimized the semiconductor designs for specific tasks – those side effects in normal semiconductors are small and unpredictable. I like using PIN diodes as light sensors, and LEDs as light emitters…
That was my LED sun photometer project used by Shawn Carldon with my permission.
Thanks for stopping by!
I remember a project of a arduino birthday candle that turn off when blown, made just using an LED. Blowing on it makes it colder, and changes the resistance, which can be detected and used as a trigger
UV photodiodes and phototransistors are much more expensive than UV LEDs because of their far more specialized use. There is a very simple circuit that can be used in model rocketry as a rocket apogee (peak of flight) and, therefore, parachute deployment sensor that uses two UV LED’s, one pointed up and one pointed down attached to an op amp or comparator, to detect the very significant difference between UV emissions, even on a cloudy day, between the sky and the ground.
UV APOGEE DETECTOR v3 – 3.7V LiPo SUPPLY
http://www.blog.exrockets.com/blog/uv-apogee-detector-v3-3-7v-lipo-supply/
My favourite HaD project is using a LED as a sensor too.
https://hackaday.io/project/11796-avr-vs-pic-the-case-of-the-candle
LEDs are bad photodiodes, and, used improperly, photodiodes are bad LEDs. I’ve actually used LEDs as light sensors in some applications. They worked great because I needed a poor photodiode, normal ones would have been saturated by the light pulses I was measuring.
I found this at about 1980 and used it in some simple projects, where I needed spectral filtering.
When I got one of the first blue LEDs, (in Europe) I was disappointed to note how bad it was as a sensor.
I knew from the 80s that led can be used as light detector and you can build device for garden lights for example to turn off the lights after the sunrise.
But..
Could the leds from the tv used as sensors to detect motion or people in the room?
Like spy movies?
We know WiFi can be used by ai to determine number of people in a room and their positions.
So our tv sets can be used for the same effect
“Could”, but it would be so much easier and have better resolution just to plant a tiny camera somewhere.
PDF: nice spectrum charts
https://mdpi-res.com/d_attachment/sensors/sensors-20-05200/article_deploy/sensors-20-05200-v2.pdf
This reference is a real gem, and highly readable. Along with solid, understandable technical concepts, it is loaded with references. It should be read by (and required reading for) anyone who has an interest in this subject; It is as close to an ‘academic-paper-for-the layman’ as you’ll find.
Very refreshing.
Thank you, [Ray]. We all should now be on the ‘look-out’ for more comments from you.
There is an important point here. Your circuitry is vulnerable to ambient light.
I once was debugging a circuit and it failed everyday about 3pm. Turns out that is when the sun was in position to illuminate the circuit board with clear glass diodes and light-emiting diodes ( LED )
can a LED array of like 200 LEDs be used like a solar panel, rather then be tossed out after a service call ?
I had to write code to test solar cells for space craft. Turns out they act like LEDs too if you goof up. Oops!
I once bought a kickstarter alarm clock. Had a fancy SoC at its core, was going to entertain me by waking me with streamed music, weather, and news. And amazingly it had four colored LEDs across the top as dual purpose indicators AND inputs. Tap the red light, or wave your hand, or something.
Where do we use alarm clocks? By our beds, of course. When do we need them? When we’re sleeping. And how much ambient light do we like to have when we sleep? Not enough to activate a poor substitute for an actual pushbutton, that’s for sure!
It was a very interesting concept device, with the world’s poorest design choice for input. I never want to own another anything that’s abusing LEDs as light sensors.
Neat trick. I remember it from the Mims books and this project. Also, I worry that in a quest to reduce the BOM of a project by $0.38 we really end up causing tremendous headache for end users, for example, capacitive touch in almost everything. And now tremendously suboptimal light sensors? Can’t imagine us going back to IrDA, or something worse however. Might be great for exfiltration of sensitive data?
The fact that LEDs are sensitive photodiodes only in a narrow wavelength range can actually be exploited to measure femtosecond long optical pulses. Here is a good dissertation on the subject: https://www.qolah.org/thesis/thesis-syed.pdf
We had a work about led sensing with hand gesture recognition “LED Screen-Based Intelligent Hand Gesture Recognition System”.
Timing reverse bias discharge lets you use LEDs as light sensors on most microprocessors without any extra hardware:
https://thecavepearlproject.org/2021/05/10/timing-an-led-light-sensor-with-pin-change-interrupts/
We took this forward for to build a cheap Vegetation Index Sensor with two LEDs
https://thecavepearlproject.org/2019/08/30/creating-a-normalized-vegetation-index-sensor-with-two-leds/
And, like any diode, LEDs also work as temperature sensors with the same technique if you cover them completely. The technique is slow, but the whole system sleeps while waiting for the ICU to report the pin change. So its very low power method.