WeMos D1 with a relay?

I want to power a 12 V RGB LED strip (just the red and green LEDs) from a WeMos D1.
My plan was to use any of my relays I have laying around at home but it seems they are all 5 volt or more.

The D1 has a 5 volt pin, but is it safe to put that 5 volt to a digital input pin and have that act as ground?

What are my other options? 3 volt relays seems hard to find here.

Are you talking about the load or the control circuitry?

No. The i/o are only 3.3v tolerant.

Do you have any transistors?

You can easily drive a 5v or 12v relay from the GPIOs through any general purpose NPN transistor (BC546, 2N2222, etc…)

Note the diode to protect the transistor from inductive voltage spikes from the relay coil.

The resistor can be any value from 390 Ohms to about 1K.

The load is the LED strip I guess then, and that is 12 volt.

The relays I currently have are all 5 volt coils (both mechanical and Reed’s).

I don’t have one but I’m quite sure they are readily available here.

I found this in the store I’m about to place an order:


NPN Bipolar Transistors (PN2222) - 10 pack

Will any diod work?

1N4007 is a good choice.

I know I have some diods but not sure what types (and where they are).
But I found 1N4001 diods

Just a thought.
Wouldn’t it be possible to remove the relay and just use the transistor?
I would then have to use a NPN instead since LEDs have a common anode, and the grounding is what lights up the LEDs. But I assume I need to just “invert” the schematic?

The PN2222 transistor collector to emitter current is 600mA max. Most likely your LED strip will require many amps.

Which is another thing you should consider. The relay contact’s maximum carrying current and switching current.

Ok. Sorry about this.
But when I asked the question the LED strip was kind of irrelevant. But now that we (I) are talking about doing it without the relay the actual LEDs is important.

I’m using scrap LEDs from a roll of 5050 that I have laying around and I’m not going to use more than 9 LEDs, at most 12 LEDs.
Looking at specs it seems they use about 20 mAh per LED, so that means at most 240 mAh.

I created a ugly sketch in tinkercad to see if it works (a simplified version), and with a blink code the LED blinks.

Yes that is possible. But there’s an even better way.

If you use 5 Red LEDs (Vf=1.5 to 2V) in series and power it from 12V then you only have 20mA current.

So two strings of 5 series LEDs in parallel would only be 40mA.

I see your point!
That is a good suggestion and I would probably use it some other time.

But even though I’m only using red and green LEDs, that also gives me yellow (kind off).
And that is my plan, to be able to go from green -> yellow -> red with minimal wires and have it all in a tube.
(I know I can use neopixels but I don’t have any. And my plan is to use as much of the stuff I have laying around).

Do I need any diods in a setup like this to make it safe? Will the transistor need a heatsink?

No diodes required.

Just make sure you drive the transistor on hard so it saturates the C-E junction. That means using a lower value base resistor like the 390 Ohm end of the 390R to 1K range I said earlier.
The collector emitter saturation voltage is 1V max so 0.24W dissipation at 240mA. Should be fine for a TO-92 transistor case. No heatsink required.

1 Like