Hacker News new | past | comments | ask | show | jobs | submit login
How to use LEDs to detect light (makezine.com)
153 points by chrisbennet on Aug 29, 2018 | hide | past | favorite | 65 comments



I designed motion detectors for a couple years and once spent a few weeks researching the use of LEDs as light detectors. What I found was the wavelength each LED could detect and the sensitivity was inconsistent from LED-to-LED and inconsistent across LED batches. We were producing 50k-1M units per year so those findings made using the LED as a sensor a deal breaker and we eventually just added a $0.12 photo-sensor to the boards to detect light.

All of that said, I designed a few demos (using the LED on the motion detector as a light sensor) that were pretty cool:

- I connected the amplified LED input on a motion detector to the microcontroller and sampled the LED in between PWM cycles (we PWMed the LED to save power). Even when the LED was on you could shine a flashlight at the motion detector light-pipe and trigger events or a test mode.

- On a motion detector that had a bi-color LED (red/green) in the same SMT package I connected the amplified LED input from one LED to the microcontroller and pulsed the other LED at a non-visible rate. If you placed your finger on the light pipe it would reflect the light from the pulsing LED to the other LED and you could detect when someone touched the light-pipe.

- A motion detector that could receive serial data over the LED to configure parameters.


wow that's neat! sampling between PWM cycles is a cool idea.

I'd guess the issue is that the required parameters are not well controlled in the fabrication of most LEDs. Possibly LEDs not used as indicators, with a tighter wavelength output... most likely this would remove any cost advantage however.

Fascinating stuff!


Ya, they're not designed as detectors so there's no control over the parameters that determine how good they are as detectors. Interestingly, one of the reasons I was looking at light sensors was because our pyroelectric sensors were erratically sensitive to incandescent light. We wanted a reliable way to detect bright light and mitigate the effects in software and were hoping to use an existing component on the board as a sensor (our products were extremely cost sensitive due to the volume, so adding a $0.12 sensor was actually a huge deal).


While this effect is observable in most LEDs (subject to variability), there are photodiodes specifically designed with much more consistent light sensitivity: http://www.ttelectronics.com/sites/default/files/download-fi...


How expensive were LEDs in comparison? Could you have added e.g 6 of them to the board as sensors?


LEDs were pennies but the biggest problem was some LEDs were super sensitive and some had no reaction at all -- so even with a bunch of LEDs you might just get all non-responsive sensors. Ultimately we wanted to detect the brightness of light reliably and a photo-sensor was reliable.


Fascinating! What do you mean by light pipe in the second point? As in touching the LED package itself or a fiber optic strand?


Here's a photo of a motion detector with a lens and a light pipe above it: https://d1unzhqf5a606m.cloudfront.net/images/product/honeywe...

It could detect a finger touching the surface of the light pipe.


The “light pipe” is a fat fiber optic channel. Light comes in the end, gets reflected by internal sides and curves, makes its way out the other end and to a detector on the circuit board. The way the end surface interacts with light allows the detection of things touching the surface of the pipe.


On the microbit [1] we run the display's LEDs in reverse to turn most of the display into a light sensor [2]. It can then be used in code [3].

[1] https://microbit.org

[2] https://lancaster-university.github.io/microbit-docs/extras/...

[3] https://makecode.microbit.org/_Lgy9F04ar9Tm


The author of this article is Forest Mims.

Forest Mims wrote RadioShack's Getting Started in Electronics[0] as well as a number of "mini notebooks"[1]. He is an amazing writer and has a real knack for explaining things in "layman's" terms.

[0]: https://www.radioshack.com/products/getting-started-in-elect...

[1]: http://www.forrestmims.com/engineers_mini_notebook.html


He also wrote the manual for the MITS Altair 8800, the microcomputer Bill Gates and Paul Allen developed BASIC for.


I instantly recognised the hand drawn LED in the article as something from my childhood.


There are a couple of really cool things you can do with LEDs as detectors. One is as a wireless link, modulate a red laser pen pointer by putting a microphone in the battery supply line and then point it at an LED that is reverse biased on a transistor that is halfway between the on and off state. Most cheap LED pointer internal power supplies have no filtering for "high frequency" (greater than about 100hz) noise on the supply line which comes out as a change in brightness in the pen pointer which the LED can pick up and drive a transistor amplifier.

The other is a simple "firefly" program where the LED is connected to the ADC input of a microprocessor, and when it detects LED light it turns around and flashes the LED some random time in the future. If you have a bunch of these you can bounce a light around for quite a while.

Chris Kuethe did a great example of this but I cannot seem to find his code anywhere.



I made a "laser aux cable" a few years back. I used a laser pointer (an actual laser one too, I think) and I can't remember exactly what I used as the receiver, I think I may have used an LDR with a transistor, I don't think I would've had any photodiodes floating around.

Interesting to see it can be done with an LED as the receiver.


Yeah! I made something similar when I was a kid. Audio transmission via laser pointer using an inline microphone to modulate supply voltage, then an opamp on a photodiode to receive. Quality was horrible, but hey, it was pretty cool!


Fasten your seatbelts:

Using LEDs as SPADs (Single-Photon Avalanche Photodiodes)

http://nebula.wsimg.com/0b846f1e91ab9c7442a61c8c35680a51?Acc...

Not sure if that link is shareable, otherwise it's the May 2013 issue "What's a SPAD?" at http://www.teachspin.com/services.html


Very cool. I always enjoy George's posts on sci.electronics.design, and now I'm going to have to spend some time I don't actually have at the workbench, trying that.


Old diodes were painted black for that reason. If you scraped off the paint you had a pretty good photodetector. Old transistors ditto (OC71 for instance), the housings were made of glass so already transparent.

The Germanium ones were more susceptible to this than the Silicon ones.


I remember old books with circuit 'recipies' where you had to sand off the top of a metal casing transistor to turn it into a detector.


This is neat; I just recently came across a project using an LED as a candle you could blow out - using just an LED and microcontroller (no other sensors). The resistance (hence voltage) change due to the change in heat can be measured by an ADC.

So, what other hidden talents do LEDs have?


Covered here [1] I think? (disclaimer, I write for HaD)

https://hackaday.com/2018/08/21/an-led-you-can-blow-out-with...


I started reading it, and I thought "this style seems very familiar". When I got to the first schematic, it clicked and I checked the header for the author's name; sure enough, Forrest Mims!


You can use this to make a cheap "toilet-paper-ometer" by sending a 1KHz square wave to one LED and using a second LED's "detector" output narrowband filtered for 1KHz. The 1KHz signale makes the "meter" insensitive to ambient light, and the device is easily calibrated by measuring "detector" amplitude with different layers and curve fitting the amplitude vs. sheet count. Nice science fair project for a Raspberry Pi.


How do you implement the 1kHz filter? A 1kHz square wave is easily generated in software but surely you have to implement the filter using an op-amp and some passives?


Given it's a raspberry pi, you could easily implement the 1 kHz bandpass filter in software, by sampling at a higher frequency and then implementing a discrete-time filter. Just about any microcontroller with an ADC could do that, actually (edit: actually, the raspberry pi doesn't have an ADC - I guess the author is doing that with a discrete ADC?).


The problem is that most micro-controller ADCs use sample and hold with a capacitor so they require some time to stabilise. From the source code of other projects this seems to be on the order of 1 to 5ms which effectively turns it into a low pass filter.


Is it possible to do this across an entire monitor ? Could the NSA (or anyone else) be filming us through our screens ?

"We see all through the black mirror"


I tried this on an oled display (by removing the controller and accessing row and column lines directly).

Light certainly had some effect, but I didn't get to be able to have the display show something and act as a sensor at the same time (possibly because the capacitance of the row and column lines is too high)


What specific display did you try this with? Maybe µLED displays will eventually be sensitive enough for use as 3d webcams or pupil tracking for AR/VR.

Capacitive touch screens in lenses can also track pupils using the shape of the eye.


I would love to learn more about using capacitive touch screen to track pupils. Is there a specific article or smth you can recommend?


Each pixel receives light from each point in the room, so almost all of them have the same value.

You need a pinhole to block vast majority of that light, so that each pixel on screen receives light from a different point on the other side of the pinhole.


Your OLED display doesn't have a lens though, so you would only see light differences


The keyhole of the door could serve as a pinhole.


Maybe, but why do that when you can compromise webcams and display cables?


display cables can be shielded, webcams can be covered over removed or banned from office use...the whole tempest hacking thing was intended to be applied noninvasively from a suspicious icecream truck parked outside for the last 3 days...


...if you work it for a while, you can image things in a radar like fashion. there was even a device that could be purchased that was a working television/camera, now obsolete...what you are suggesting requires physical compromise beforehand...


This seems like it ought to be much bigger than it is. Two-way single-cable fiber-optics, with cheaper components than photoresistors? What's the catch?


LEDs usually are not very good photodiodes. You optimize them differently for each usage. In abstract theory the perfect photodiode and the perfect LED would be the same but in reality there are more tradeoffs and you end up with different devices.


Detectors for fiber optic data transmission need a very fast response time. For gigabit data, you need sub-nanosecond response. LEDs are much slower. They're also less sensitive, which means you need a higher-power transmitting LED to get the same range.


What drives the response time, internal capacitance or something?


Yes, capacitance of the junction.


That's a rather vague statement, it is the textbook answer directed at the users of discretes: given a fixed discrete photodiode part and a fixed load resistor one can change the capacitance by reverse biasing and thus improve the bandwidth of the resultant RC filter.

But this is not a full truth from the perspective of the photodiode designer: he can trivially increase or decrease the capacitance by designing a photodiode with a larger or smaller area. Suppose ratio of the incoming light power over photodiode area is unaffected by doubling the original photodiode area. If he doubles the area and hence capacitance, then he also doubles the injected photocurrent! Hence he can halve the load resistor, hence the bandwidth is unaffected by doubliing capacitance!

Consider the source illumination, what is the smallest area you can concentrate the light in? If it is smaller than your photodiode's active area, it pays off to select a smaller photodiode since the unused area is contributing dead weight capacitance. But if decreasing the area does not increase the optical power / photodiode area ratio, you need better optics or illumination.

EDIT: fixed poorly phrased sentence


pretty sure the expense in BiDi transceivers (which aren’t that expensive) comes from the WDM coupler, not the receiving element.


I think the point is that with a LED to LED system you would not need any sort of optical multiplexing.


i felt like returning to half-duplex communications was enough of a non-starter to discount it as a possible suggestion.


There’s a limit to how many pulses you can have per second. They stack more waves to get more capacity.


Ciao, I have played with this characteristic of LEDs since young, those are some of the results:

- This is a reflectometer: https://github.com/gioblu/PJON/tree/master/devices/sensors/L...

- This is a bidirectional wireless data-link: https://github.com/gioblu/PJON/tree/master/src/strategies/An...


My favourite application of this idea is concealing a tamper protection switch in a debug LED.


I used this phenomenon to build a laser tachometer a while back. https://www.youtube.com/watch?v=RfitqGLPCUY


You can communicate using bidirectional LEDs: http://www.merl.com/publications/TR2003-35


This is actually how modern Optical Mark Readers ("Scantron") works. The older models from the 1960s used electrical current passed through the paper somehow.


Scantron readers use LED's as light sensors? I assumed they used regular photo sensors.

The older form readers used metal brushes that detected the conductivity of the graphite in pencil lead.


It's possible that the "newest" ones use photo sensors as they now also double as standard desktop scanners, but I'm not sure they would be marketed as OMR. I suspect Scantron and Pearson NCS won't be around much longer as standard scanners are much cheaper, can accomplish the same goals (minus printing results on the form, without a special attachment on expensive scanners), and embedded processing continues to grow.


I've used LEDs as light detectors in a pinch when I wanted to measure the rotational speed of something and didn't have any other sensors handy. Neat trick.


I haven't personally used this feature of PJON, but they have an apparent way of communicating bidirectionally with a single LED on each side. The one wire software bit bang method worked for me though.

https://www.pjon.org/AnalogSampling.php


The Optical Communications hobbyists have been using this idea since LEDs first arrived nearly 50 years ago.

It sure makes things easier to use the same optical system (lens, etc) for TX and RX.

The only problem is that LEDs make a fairly poor Optical sensor.


I first heard about this in the 1970's. I tried to build a two-way communicator on this principle in high school, but never got the circuit to work.


Are there any other accidentally light sensitive devices?


Chips can be, if their case isn't opaque enough. Famous example would be the "camera shy" Raspberry Pi 2, which crashed when exposed to strong light like a camera flash: https://www.raspberrypi.org/blog/xenon-death-flash-a-free-ph...

Other semi-conductors can be too, e.g. classical diodes in glas casing.


Thanks.

I grabbed a multimeter and checked the first part I could find. 1mV DC covered, 10mV DC uncovered (it's a bleak cloudy day). Magnifying glass reveals it's a 6v2 zener :)


i distinctly recall articles much like this one about decapping dram parts in ceramic packages and focussing an images onto them with a lens. once you mapped the address lines to the physical structure, and tuned the aperture and ambient light levels of the chip you could get out a one bit image.


Content? Nah that's overrated let's cover it up with a gigantic sticky header and footer


TL;DR: LEDs make pretty decent photodiodes. But you should read it. ;)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: