1
\$\begingroup\$

What I have is I think a standard problem in home electronics but I can't wrap my head around it. I'd like to control an IKEA light chain from an ESP32 board. The chain is basically a set of LED diodes connected parallelly. The power cannot be sourced from the pin itself because it exceeds board limitation of 40mA draw (the lights consume 0.72W which is ~144mA at 5V). I want to shift somewhat linearly 0-3.3V from the pin to 0-5V to the lights to turn them on/off and dim.

At first I tried tried using a BC337 NPN transistor but I'm only getting 2.6V max.

schematic

simulate this circuit – Schematic created using CircuitLab

I've also tried using an L293DNE motor driver but the max voltage drops to 2.7V under load.

schematic

simulate this circuit

  1. What are some other ways to do it? I've read somewhere that a MOSFET transistor might work.

  2. How can I find a proper transistor and calculate the emitted voltage based on values from its specification.

  3. Is there a standard name for what I'm trying to achieve? I'm basically looking for keywords here so I can find relevant information.

\$\endgroup\$
9
  • \$\begingroup\$ Well, an emitter-follower is not the way to go. Even if all the rest is right. (Which it probably isn't.) Can you provide a link to the specifications for the LED string? \$\endgroup\$
    – jonk
    Commented Dec 6, 2021 at 4:12
  • \$\begingroup\$ They don't provide anything. There's only a sticker that says 5V DC, 24 x 0.03W. They are powered via USB connector but just connected straight to VCC/GND pins. \$\endgroup\$
    – mariusz
    Commented Dec 6, 2021 at 4:26
  • 1
    \$\begingroup\$ So it is regulated down to 3.3 V on the board, regardless. The I/O pins can only drive out 3.3 V, I take it. Try grounding the emitter of the NPN. Expect to use 1/20th of the 144 mA, or about 7.2 mA for the I/O pin, which from your wiring appears to be well within its capability. The resistor value should be about (3.3-0.9)/8mA or about a 270 Ohm resistor from the I/O pin to the NPN base pin. Attach the IKEA load between 5 V and the collector. See if that works. \$\endgroup\$
    – jonk
    Commented Dec 6, 2021 at 4:48
  • 2
    \$\begingroup\$ just swap the BJT and the LEDs in your first diagram. \$\endgroup\$
    – dandavis
    Commented Dec 6, 2021 at 5:04
  • 1
    \$\begingroup\$ if you used an nchannel fet it would work even better, i use the irlz44n a lot for 3.3v switching of large loads. \$\endgroup\$
    – dandavis
    Commented Dec 6, 2021 at 6:23

2 Answers 2

3
\$\begingroup\$

enter image description here

This means that with a 5 volt drive level on GPI)18 the max voltage on the emitter is about 4.3 volts.

I want to shift somewhat linearly 0-3.3V from the pin to 0-5V to the lights

Of course, if your supply voltage is 3.3 volts then, the maximum voltage you'll get on the emitter is 2.6 volts.

You should try using an op-amp and BJT circuit to adjust the current through the LED: -

enter image description here

Image from here. The LED would connect between the supply and the drain of the MOSFET above. There's also this version that uses a MOSFET: -

enter image description here

Image from here.

You should also be aware that most LEDs will fail if given too much voltage and that controlling the LED current is a more reliable method.

\$\endgroup\$
1
\$\begingroup\$
  1. Use PWM.
  2. Connect the transistor in a common emitter configuration, with emitter connected to ground, base connected via a 4k7 resistor to GPIO, and collector collected to the cathode (-) of the LED light.

PWM is inherently linear no matter what the peak voltage is. Here you’re using a 3.3V PWM signal to control a switch that toggles a 5V load. 100% PWM will be equivalent to full brightness, 50% will be approximately half brightness, etc.

This will work as long as the LED light doesn’t include some fancy active drive circuitry, like a boost power converter. If it only included an active current source then the chances are it will work fine with PWM, perhaps only in a limited frequency range. You’ll have to experiment. Start with 1kHz PWM and go up if it misbehaves.

\$\endgroup\$

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.