1
\$\begingroup\$

There are a lot of questions on here and elsewhere about this.

The consensus seems to be to use a transistor to switch a power supply — implying that I have a 12v supply available.

Only 5V is available, either coming out of the GPIO pins or directly from the power supply (USB battery in this case).

This is a single LED: seems like it should be possible to directly wire it to the GPIO pins with a component in the middle that raises voltage. (GPIO pins can "safely" provide 16 mA)

It appears that I need a stepup/boost converter, but nobody seems to be discussing that. Am I thinking about this correctly?

\$\endgroup\$
  • \$\begingroup\$ What kind of 12v led? Datasheet or product page? How much current is needed? \$\endgroup\$ – Passerby Jun 26 '15 at 13:00
  • 1
    \$\begingroup\$ Several boost converter chips are available. A 5V - 12V converter could be designed. The GPIO pins aren't suitable, you need to use the 5V supply. \$\endgroup\$ – Leon Heller Jun 26 '15 at 13:00
  • \$\begingroup\$ A "12v LED" is something of an oxymoron - it has to be an LED with current limiting resistor or regulator built in. Can you simply find a 5V variant? \$\endgroup\$ – Nick Johnson Jun 26 '15 at 13:16
  • \$\begingroup\$ @NickJohnson You're probably right, but the LED is part of a bigger device and I can't rip the LED out. \$\endgroup\$ – David Chouinard Jun 26 '15 at 15:38
  • \$\begingroup\$ @Passerby No information on the LED, other than it "runs at 12VDC" (sparkfun.com/products/9181) \$\endgroup\$ – David Chouinard Jun 26 '15 at 15:42
3
\$\begingroup\$

In general, you need a boost converter on the 5V supply input, to 12V. You can typically see 85% efficiency. You still want to use the transistor on the RPI output, since it is 3.3v and low current.

Any typical step up or boost converter will work, considering you keep in mind the minimum regulating load.

Alternatively you can find a boost converter with a 3.3v enable pin, and control it directly from the rpi.

Edit The button that OP linked to can be disassembled by design, to replace parts. An easier solution is to replace the led resistor with one suitable for 5V operation. I'd still advise a transistor setup. If you feel lucky punk, well do you?, then a resistor suitable for a red led at 3.3V 16 mA or less would work directly, with minimal brightness change, but a ten cent transistor to protect the RPI pin is recommended.

\$\endgroup\$
  • \$\begingroup\$ Just stumbled upon this thread as I am doing the same thing with an Arduino. I am fairly new to the whole electronics scene (coming from a software engineering background) but keen to learn. Based on the specs above, would a 120 ohm resistor do the trick (assuming a 5V source, 3.3V forward voltage, 16mA forward current)? Could you also elaborate on the transistor that you recommended to include - why it's a good idea to include the transistor, and what transistor to use? Thanks in advance! \$\endgroup\$ – Skoota Dec 10 '16 at 10:06
2
\$\begingroup\$

If you have a 12 volt LED and only a 5 volt supply you need a boost regulator and a means of activating the LED from a gpio pin. So, look for a suitable boost converter (TI or LT) and then choose a BJT that can be activated by a gpio pin via a resistor. Emitter connects to 0 volts and collector to the LED cathode. Anode to 12 volts and MAKE SURE that the LED will work without a current limiting resistor.

\$\endgroup\$
1
\$\begingroup\$

Although the Pi can supply 16mA (ish - drive strength is a poorly controlled parameter) at 5V, energy is conserved. Since Power P = I*V, where I is current and V is voltage, stepping up the voltage means the current supplied to the LED will be lower than the current from the GPIO - even with 100% converter efficiency, you'll get 4.4mA max from a 3.3v GPIO. When we also take into account that

  • The converter efficiency will be much less than 100%, especially with such a large step from 3.3V to 12V
  • 16mA is the current with the GPIO shorted - at this point, the output voltage is actually zero, not 3.3V. Any significant current draw will cause some amount of voltage drop

We can see that driving a high power LED from a Pi's GPIO is essentially not a good idea.

BUT there is a better way!

Example circuit for driving high voltage device with Raspberry Pi

A DC-DC boost converter (search ebay) can provide 12V from a 5V supply with a reasonable efficiency (typically ~85%). A dedicated 12V supply is better.

The current through the LED is switched on and off by a transistor - a MOSFET is ideal because no current flows into its gate while it is on.

The MOSFET suggested in the diagram will happily pass an amp or two with a 3.3V gate voltage from the GPIO pin, making the LEDs much brighter and avoiding any damage to the Pi.

This type of transistor circuit (just the lower part) is very useful for driving higher voltage loads from a low voltage microcontroller or processor.

\$\endgroup\$
  • \$\begingroup\$ Thanks! This idea was quite clear to me, but thanks for providing part numbers. \$\endgroup\$ – David Chouinard Jun 27 '15 at 0:38
  • \$\begingroup\$ Also, somehow I thought the Raspberry Pi's GPIO pins outputted 5v, not 3.3v. Thanks for correcting that. \$\endgroup\$ – David Chouinard Jun 27 '15 at 0:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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