Posts: 1
Joined: Sat May 18, 2013 11:19 pm

Trigger action from external LED?

Sat May 18, 2013 11:25 pm

I have a water tank that has a simple monitor that activates an alarm sound and lights a red LED when the tank is full. I would like to use a Raspberry Pi to enhance this monitor to send an e-mail when it activates. Can I simply connect the LED output from the current monitor to one of the GPIO connections and watch for a voltage or do I need to put some circuits between. From what I have read the LED voltage should be low enough but I'm confused if I need to do any kind of analog to digital conversion.

Thank You

User avatar
Forum Moderator
Forum Moderator
Posts: 12041
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Trigger action from external LED?

Sun May 19, 2013 1:13 am

Yes and no!
Yes, in principle the voltage falling over a LED is in the range that you could safely input into a GPIO and it would probably register as a logical "high".
but no, its not a simple matter of connecting the GND of the PI to the cathode of the LED, and the GPIO to the anode of the LED, not unless you know its not a problem to connect the GND of the PI to the cathode of the LED!

You see, you don't know what voltage there may be between the anode of the LED, and the GND of the PI! In fact you seem to know nothing about the circuit you are trying to interface to, which can be dangerous, if not for you for the electronics!

The PI isn't normally connected to anything electrically directly, unless you connect it to a TV, through the HDMI ports (or the composite port), then the GND of the PI is connected to earth through the TV (if the TV is grounded that is, otherwise there might be even potentially high voltages on the PI, not generally dangerously though for a human, but potentially for electronics)
bottom line is that unless you know enough about electronics to know exactly what you are doing, you are taking a risk doing what you suggest! You need some kind of electrical isolation between the two systems to make its safe.

What I would do is to use an "opto-isolator", which is in fact also a LED on the "transmit side", and a photo-transistor as receiver. The phototransistor can act as a switch, pulling a GPIO pin with a pull-up to 3V3 low. The LED of the phototransistor you cannot simply wire in parallel to the original LED normally if both LED's have different forward voltages chances are that one would draw 95% of the current, and the other only 5%, so for both LED's there must be a series resistor. You can wire one end of the LED's together but the other end to wire together must be the resistor.

Another solution would be to use a single phototransistor, and let that "watch" the water tanks LED. The phototransistor can then be safely connected to the GPIO.

Its not impossible to do what you originally said, but you must think about the implications.

User avatar
Posts: 945
Joined: Mon Oct 17, 2011 11:18 pm
Location: The Mountains
Contact: Website

Re: Trigger action from external LED?

Sun May 19, 2013 1:54 am

I'd definitely go with an opto-isolator. You can read more about them at Wikipedia: http://en.wikipedia.org/wiki/Opto-isolator.

Opto-isolators generally use infra-red LEDs so the voltage drop is less than a visible LED. That means that if you put it in parallel with the visible LED most of the current will go through the opto-isolator -- you'll still see a faint glow from the visible LED.

Return to “General discussion”