Disclaimer: this is my first PI project, and at the moment I have only a basic knowledge of circuitry, so please be gentle.

I'm looking to construct a device using a PI 3B+ that'll be housed outdoors in a sealed project box. As part of this, I'd like to have 6 weatherproof LEDs on the box to show status, and the only ones I can find are 12v 15mA. I know that this is too much for the GPIOs to handle directly, so I need another solution - preferably one that doesn't involve me having to provide a separate power supply.

At the moment I'm leaning towards a relay hat on the PI with a USB to 12v adapter providing the power to relay to the LEDs. Before I go out and buy the parts, am I working in the right direction, or is there a better way? Also, given that the LEDs are 15mA and the adapter output is 0.6A, do I need to put a resistor between the relay and each LED?

  • 1
    Seems like case of putting the cart before the horse
    – Milliways
    Oct 10, 2023 at 10:47
  • 1
    Is there a better way, YES! First it sounds like overkill with a Raspberry Pi. And there is for example "Blinkt!" 8 LEDs for a 1/3 of the price for a relay hat and no 12v is needed.
    – MatsK
    Oct 10, 2023 at 11:43
  • @Milliways - your comment could be described as many things. Constructive would not be one of them. Care to add anything useful?
    – Pete
    Oct 10, 2023 at 15:42
  • @MatsK - thanks - I'll look into that
    – Pete
    Oct 10, 2023 at 15:42
  • You are planning to use 1W of LEDS - a 6W LED bulb is enough to light up a room.
    – Milliways
    Oct 10, 2023 at 21:37

4 Answers 4


OK - several things to unpack here...

1. "6 weatherproof LEDs on the box to show status, and the only ones I can find are 12v 15mA"

12V LEDs do not exist. The items you've found are designed to work from a 12V supply, and so they have a resistor included in the package. If you keep looking, you may be able to find weatherproof LED packages that operate from 3.3V (GPIO voltage), or 5V - or simply weatherproof LEDs that have no voltage rating on them. If they have no voltage rating on them, this means you will need to add your own resistor.

2. "I'm leaning towards a relay hat on the PI with a USB to 12v adapter providing the power to relay to the LEDs."

That is a workable solution... but it probably fails your criteria for "[is there] a better way?", and "another solution - preferably one that doesn't involve me having to provide a separate power supply.".

Here's a simple schematic showing one way to connect a LED to your RPi:


simulate this circuit – Schematic created using CircuitLab

In this schematic, we use a 270 Ohm Resistor in series with an LED. LEDs are current-driven devices, meaning that the light intensity they output depends upon the current through the LED. About 10 mA is a reasonable figure for many smaller LEDs.

The 2N3904 transistor is an NPN transistor. Current is switched ON & OFF with base drive supplied by a GPIO pin, and current-limited by a 2.2 KOhm resistor.

I think I'll stop here because I don't know if this interests you. Feel free to ask questions in the comments (within reason), or you may post another, more detailed question if you like.


  1. The Light Emitting Diode
  2. Light-emitting diode physics
  3. Light-emitting diode
  • Now that's what I call an answer - informative and helpful. Thanks! I'll try what you suggested. The LEDs I found are described on amazon as 12v (see here: amzn.eu/d/8g0qPtZ) – does this mean I can forego the 270 ohm resistor?
    – Pete
    Oct 10, 2023 at 21:38
  • 1
    @Pete: If you use those LEDs, you can forego the 270 ohm resistor. However, you will need to power it from a 12 (-24)V source to get any light from it; i.e. those LEDs have resistors built into the assembly.
    – Seamus
    Oct 10, 2023 at 21:49
  • Thanks for the confirmation!
    – Pete
    Oct 11, 2023 at 10:40

I'd use normal LEDs by making holes just big enough in the box and sealing them with silicone after cleaning up any burrs from drilling. I have a number of outdoor projects with this arrangement and none have leaked.

  • A simple, yet effective solution. I may well go for this if the 12v LEDs become too much of a pain. Thanks!
    – Pete
    Oct 11, 2023 at 10:39

To drive 12V or other such devices from GPIO, maybe use the common ULN2003 chip, which does what R2 + Q1 in @Seamus answer does, but with 7 outputs in one chip, so all you need is the output resistor R1 (if not built into the LEDs) and something to power the LEDs (easier if they can run from the same 5V as the Pi, more difficult if they need 12V to produce enough light at desired viewing distance).

If you do end up needing a 12V supply, a switch mode converter between 12V and 5V would be easier than having an entirely separate supply. If the power source isn't inherently 12V, a boost converter strong enough to power the max number of LEDs used at the same time would be most efficient, as the majority of power will probably be consumed by the computer averaged over the system lifetime. One type of boost converter can be made with just a coil, a diode, a capacitor, the spare ULN2003 output and a PWM signal on the GPIO pin controlling that output.

Even if following the repeated advise to use ordinary LEDs (with an inherent drop of about 3V), it may be a good idea to make sure the outside connections are fairly waterproof, so 1+6 wires exiting the sealed box to drive 6 LEDs, and one ULN2003 channel unused.

  • Thanks - I'll take a look!
    – Pete
    Oct 11, 2023 at 10:43

There are always multiple ways to approach these problems. You can use a 12v supply and a 5v regulator to feed the pi. You can use 5V neopixels. You can use a waterproof panel mount for standard LEDs. Alternatively you can glue a transparent cover over standard LEDs; perspex, glass or polythene. I bought a pack of perspex offcuts. I use the opaque stuff for making cases with holes for LEDs and a transparent sheet on top.

Your Answer

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

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