You Can Use LEDs As Sensors, Too [Hackaday]

View Article on Hackaday

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.

Forrest Mims liked to use op-amps to boost the output from LEDs used as sensors. Credit:Forrest Mims via Make article

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.

Two tristate pins let you use an LED for emitting light and sensing it. Credit: MERL research paper

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.

Researchers were able to communicate between microcontrollers over a distance of a few centimeters using nothing but regular LEDs. Data rates reached 250 bits/sec. Credit: MERL, research paper

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.

Some researchers believe PerLEDs could enable the creation of touchscreen displays that don’t need additional sensor elements beyond the LEDs themselves. Credit: Bao, et al, research paper

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.

 



Leave a Reply