I have a PCB that controls some doors and gates at a facility. I need to determine the status of said doors/gates. There are no I/O ports at the PCB to read from, and soldering some probes to it is not an option. But there are SMD LEDs on the board for each door status. I had an idea that I could attach some photo sensitive elements on the LEDs to determine the current state with light.

What elements should I use to easily read the data with a simple I/O microcontroller? Light resistors? Maybe there is something already in the market for exactly this kind of application? There are multiple locations I would need to install this and I'm looking for a simple "plug and play" solution if that is even possible.

  • 1
    \$\begingroup\$ 1) Burglar alarms often use a magnet and magnetic switch to detect if a door is opened, and there are many people familiar with their installation. Would that be an option for you? 2) Otherwise, does it matter if the LED is no longer visible? Are the LEDs inside a case or visible from the outside? \$\endgroup\$ Aug 19, 2020 at 11:29
  • \$\begingroup\$ I'm unsure what "plug and play" means in this context. My experience of P and P is that it's never as simple as it's made out to be and needs a fair amount of faff. \$\endgroup\$
    – Andy aka
    Aug 19, 2020 at 11:46
  • \$\begingroup\$ Is there room for an IP camera? \$\endgroup\$
    – Transistor
    Aug 19, 2020 at 11:57
  • \$\begingroup\$ Magnetic switches are not an option. These doors, gates and barriers are not in one location. It would take a lot of wiring etc. LED are not visible as they are in closed locker and it is not necessary for them to be visible. IP camera would be overkill as I need to install this at multiple locations and some of them would be connected with a poor tower network. Problem with a regular photoresistor would be the installation on the LED, maybe I could use some transparent/opaque adhesive, but would need to isolate from the neighbouring LED not to bleed light across them. \$\endgroup\$ Aug 19, 2020 at 12:10
  • \$\begingroup\$ Based on you lack of experience debugging basic circuits, you will not be able to accomplish this unless you choose a low impedance buffered sensor with UTP or STP cable. You really need to learn about low impedance signal integrity and optic daylight filter blocking to do what you want. Photo resistors are lame hobbyist sensors and better to use a 5mm buffered optical sensor with narrow beamwidth and heatshrink block all light except the <1 deg aimed at the LED to prevent false switching. These are also hard to find as Panasonic stopped making them. But there may be others . 5V RCfilter cap \$\endgroup\$ Aug 19, 2020 at 12:13

1 Answer 1


One or more option exists to achieve your requirements, lets divide your project into 2 segmentations

Segment 1 "Choosing the suitable sensor for your circuit"

LDR (Light dependant resistor) as its name implies, this type of resistors are similar to regular resistors but resistance change is dependent on the amount of light it’s exposed to (high light intensity -> low resistance -> high output voltage) and vice versa. So by applying a 5v supply to one end of the LDR you can get an output voltage dependant of that amount of light at the other end of the LDR as shown on this circuitry " figure 1"


The most confusing part of this circuit is that LDRs output voltages are analog means you have to either connect them to analog pins of your micro-controller which are few compared to digital ones, or you will have to add some circuitry to convert those analog voltages into 5v digital voltages adequate to your micro-controller. to do that you will have to first test how much voltages are at the output of the LDR pin when the SMD LED is turned OFF and after exposing it to your SMD LEDs. you will be lucky if you can have a value higher than or equal to 2v when the SMD is ON as some micro-controllers such as the AT-Mega32 accepts high digital input values between 1.8v to 5.5v. otherwise you are going to determine the ON and OFF voltages of the LDR output and add this circuit "figure 2"


Where IC1 is a 5v comparator op amp, Vref is a voltage between the ON and OFF voltages of the LDR so that when SMD LED in ON, LDR output voltage is higher than Vref and comparator output is high (5v) to the microcontroller pin. And when SMD LED is OFF LDR output voltage is less than Vref and comparator output is low (0v).

Photodiode Photodiodes are another type of light sensor. But instead of using the change in resistance like LDR, it’s more complex to light, easily changing light into a flow of electric currents. To convert that current into voltage, a simple circuit with an operational amplifier allows you to get an output voltage proportional to current generated by the photodiode as shown in "figure 3"


The value of R can be calculated from this equation Vo = I * R , where Vo is the output voltage to the micro-controller pin (5v in our case) and I is the amount of current produced when the photodiode is exposed to SMD LED ON. R can also be determined by a try and error algorithm. assume it 50K Ohms and measure the output voltage then increase or decrease it according to requirements.

Segment 2 (Attaching your diagnostic PCB to the SMD LED PCB)

You can measure the exact board dimensions then measure the location of each SMD LED on that board reference to board dimension , then placing whichever sensor you have chosen into the same exact location of each SMD LED on the board and finally take in consideration that you are going to flip that new PCB to be placed over the existing one. Then using some kind of a 3d printed tubing around each LED and Sensor in order to eliminate the interference between lights from different SMD LEDs will be adequate.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.