Icetrey74
Posts: 6
Joined: Mon Aug 01, 2016 1:57 pm

Monitor led flash via GPIO possible?

Fri Feb 21, 2020 4:09 pm

I am pretty green, so please be patient with me and let me know if this is the correct place for this question.

I am wanting to tap into an LED on a machine and monitor its status via GPIO. Depending on the flash pattern, a different status is determined and reported to a simple web page. If no LED, the machine is off/inactive; solid ON means normal operation; flashing denotes an error.

I have found tutorials about making an LED react to, but not about determining a state based on reading the input voltage from LED to the pi.

Any recommendations about wiring the LED to the GPIO and/or how to read the state is most welcome.

User avatar
Burngate
Posts: 6290
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Monitor led flash via GPIO possible?

Fri Feb 21, 2020 7:27 pm

I wouldn't recommend connecting directly to a LED - you don't know what voltages are around it.

Instead, you could try an optoisolator, or put a light detector in front of the LED.
In either case you can then treat it as a simple switch.

Icetrey74
Posts: 6
Joined: Mon Aug 01, 2016 1:57 pm

Re: Monitor led flash via GPIO possible?

Mon Feb 24, 2020 1:29 pm

Burngate wrote:
Fri Feb 21, 2020 7:27 pm
I wouldn't recommend connecting directly to a LED - you don't know what voltages are around it.

Instead, you could try an optoisolator, or put a light detector in front of the LED.
In either case you can then treat it as a simple switch.
I will see if the light detector route is feasible and give that a try. Thank you so much!

Icetrey74
Posts: 6
Joined: Mon Aug 01, 2016 1:57 pm

Re: Monitor led flash via GPIO possible?

Wed Feb 26, 2020 1:32 pm

Burngate wrote:
Fri Feb 21, 2020 7:27 pm
I wouldn't recommend connecting directly to a LED - you don't know what voltages are around it.

Instead, you could try an optoisolator, or put a light detector in front of the LED.
In either case you can then treat it as a simple switch.
Apologies for the delayed response, but work had to take precedence.

I've had a chance to examine the wiring I want to tap into for monitoring purposes and have discovered a couple of things that will change my approach. It is not an LED I'm attempting to monitor, but this incandescent beacon:

https://www.radwell.com/en-US/Buy/ALLEN ... 5T-G24DN5/

How might this change my approach?

User avatar
Burngate
Posts: 6290
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Monitor led flash via GPIO possible?

Wed Feb 26, 2020 6:46 pm

I'd go the photodetector route - Pimoroni sell one for £1.50, Spakfun $1.50.
Google "photoresistor raspberry pi" or similar.
Icetrey74 wrote:
Wed Feb 26, 2020 1:32 pm
Apologies for the delayed response, but work had to take precedence.
Work always gets in the way until you retire. Then housework does that

Icetrey74
Posts: 6
Joined: Mon Aug 01, 2016 1:57 pm

Re: Monitor led flash via GPIO possible?

Wed Feb 26, 2020 8:33 pm

Burngate wrote:
Wed Feb 26, 2020 6:46 pm
I'd go the photodetector route - Pimoroni sell one for £1.50, Spakfun $1.50.
Google "photoresistor raspberry pi" or similar.
Icetrey74 wrote:
Wed Feb 26, 2020 1:32 pm
Apologies for the delayed response, but work had to take precedence.
Work always gets in the way until you retire. Then housework does that

As luck would have it, I have a photoresistor that came in a kit I purchased from Amazon. I assume I would need to shield the resistor from ambient light from the room - it's a very bright production environment, but I can't blackout the beacon. Or can I adjust the sensitivity of the photoresistor?

User avatar
Burngate
Posts: 6290
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Monitor led flash via GPIO possible?

Thu Feb 27, 2020 10:31 am

You may have to experiment a bit.

I'm going to assume you're going to connect the photoresistor between Gnd and a GPIO, with a pull-up resistor from the GPIO to 3v3 (that way, you can run a long pair of wires from the Pi to the photoresistor glued to the beacon, with the pull-up close to the Pi)

Since light reduces the resistance of the photoresistor, the value of the pull-up resistor will determine how much light is required to pull the GPIO low enough to register.

Of course, where on the beacon you glue the photoresistor will determine how much ambient light it sees. You may even be able to place it inside the beacon - more light from it, less from outside.

My daughter accuses me of verbal diarrhoea. Sucking eggs is another of my specialities. Sorry about that.

Return to “Interfacing (DSI, CSI, I2C, etc.)”