Dimming on and off 2x5m led strip with arduino

Hello everyone,

I use in my office a 10m long led strip, powered from a 100w source, it is controlled using an arduino, just on and off an relay, worked perfectly in the last 3 years.

Now i want to improve my system, and also add another 10m led strip (2x5m - 5630 led) in the yard, but with 2 modifications:

  1. I want to use a few 433Mhz PIR sensors (no problem so far)
  2. I want to dim from 0% to 100% in about 2 - 3 seconds when turning ON, and when turning them OFF, to dim from 100% to 0%

I just ordered an PWM 8amp led dimmer to see how it works/if it works BUT I DONT NEED A KNOB! I want my arduino to controll ot. Do you guys know if I can replace the potentiometer in that dimmer with a digital pot, controlled from arduino ?
Or is there another way?

I was thinking it is easier to get a ready made dimmer and hack it, than trying to make one myself.

Thank you in advance, for any advices amd tips!

Do you guys know if I can replace the potentiometer in that dimmer with a digital pot, controlled from arduino ?

You can’t.

Or is there another way?

Yes.
Use a FET to switch the strip on, and feed the FET with a PWM signal from the analogWrite call. The value used will set the brightness.

This link is for a RGB strip, but just use one FET to control your white strip.

Is just that simple? Only an MOSFET (and probably an aluminum radiator) and a resistor ? Just 2 components to dim the 10 meters led strips ? If this is it, today I'll purchase locally that IRLB8721 MOSFET and play with them in the weekend :smiley:

Thank you.

Just 2 components to dim the 10 meters led strips

Yes.

But, while that FET is good with a 5V signal, it will run a lot cooler if you could boost the signal up to 10 or 12V with an other transistor before the gate. Look at the data sheet of the Ron resistance, and se the diddrence in dissipation between the two voltages. Or you could use a better FET.

You don't say much about your led strip(s). Most single colour strips are 12V, and most are either 30 or 60 leds per metre. The leds are either wired in groups of 3 in series, or sometimes (especially white leds) individually. Typically each led, or group of leds, draws around 20mA to 30mA.

Your strip could be drawing as much as 10 * 60 * 30mA = 18A
or as little as 10 * (30 / 3) * 20mA = 2A

So a very wide range. Whether you would need one or two MOSFETs, and whether you would need extra heatsinks for them, depends on that total current requirement.

Also your power supply. Is it AC or DC? 12V or 24V? You said 100W. At 12V DC, that's 8.3A. So to know if the psu will run both strips, you need to know that strip current.

Can I suggest you measure the current and voltage of your strip, when lit?

Thank you for your replys Mike, Paul.

Mike, unfortunately I couldn't find that MOSFET locally and I purchased a different one to try out RFP50N06. I want to use an ESP8266, so this one is 3.3v, from the ones I could find locally I looked for the Gate voltage treshold, this one is min 2v , max 4v .. I though it should be ok.
I didn't about the other way you say, to use another on the gate , to boost the voltage.

Paul, the led strip is this one with the wattmeter on the AC - DC source , I get 70w when powering both led strips (2x5m). The AC - DC power source is max 100w @ 12v

On my first try it seems easy, there only one problem, the full brightness is wery low, when I use the MOSFET. If I connect the led strip directly on the PC PSU (12v) I get the real brightness (please check the end of the video)

I used an 180 Ohm resistor on the gate, is this the cause ?

As you see in the video I'm using an Wemos D1, so it's 3.3v on the PWM pin, not 5v like on a standard Arduino.

The sample code I used for the test is this :

#include <SoftwareSerial.h>

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

const char* ssid = "office";
const char* password = "0987654321";

#define REDPIN 4

 
#define FADESPEED 15     // make this higher to slow down


void setup() {

  Serial.begin(115200);
  Serial.println("Powering up LED Strip Dimming module");

  
  pinMode(REDPIN, OUTPUT);


  Serial.printf("Connecting to %s ", ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println(" connected");
  Serial.println(WiFi.localIP());
}



void loop() {
  int r, g, b;

 Serial.println("Fade from 0 to 255");
  // dim from off to on
  for (r = 0; r < 256; r++) { 
    analogWrite(REDPIN, r);
    delay(FADESPEED);
  } 

Serial.println("Wait at full brightnes");
delay(1000);
  
  Serial.println("Fade from 255 to 0"); 
  // dim from on to off
  for (r = 255; r > -1; r--) { 
    analogWrite(REDPIN, r);
    delay(FADESPEED);
  } 


Serial.println("Wait  1 sec with leds turned OFF");
delay(1000);

}

this one is min 2v , max 4v .. I though it should be ok.

Err no.

You can’t use the RFP50N06 because this takes at least 10V to turn it on. Using it like you are it will get very hot and as you have found will be not very bright.

You need a transistor to boost the output voltage.

See this:- PWM voltage boost for mosfet - Electrical Engineering Stack Exchange

As you see in the video I'm using an Wemos D1,

We love it when a poster withholds vital information, so much more interesting that giving us the relevant facts in the first post.

Yeah, get a better MOSFET and you're fine :smiley:

And if you want to make the programming side of things easy, have a look at FadeLed. Easy fading up and down the brightness and the use of a gamma table (because our eyes don't see light linear).

Grumpy_Mike:
Err no.

Please can you tell me what should I look for in the datasheet? I attached a screenshot with the specs of that MOSFET, and a few explanations, in the feature, when looking for MOSFETs I should check the GATE CHARGE value, to be compatible with 3.3v of an Wemos ?

Grumpy_Mike:
You can’t use the RFP50N06 because this takes at least 10V to turn it on. Using it like you are it will get very hot and as you have found will be not very bright.

You need a transistor to boost the output voltage.

See this:- PWM voltage boost for mosfet - Electrical Engineering Stack Exchange
We love it when a poster withholds vital information, so much more interesting that giving us the relevant facts in the first post.

Adding an transistor is not complicated also, if I will use an transistor on the gate of my MOSFET (RFP50N06), will it be ok ? Or it will still run hot ? If it will work ok with a transistor and my led strips , can you recommand what transistor I should buy, considering I will use an ESP8266 to control it - 3.3v.

As you seen in my video, the light intensity was not too bright, but also the mosfet was cold, not even warm at that brightness level, I run it for about 5 minutes.

@septillion What is a better mosfet, some names/codes will be helpfull. The one in the adafruit (IRLB8721) is ok ? If that will be ok I will order a few of ebay, as locally I can't find them.

In this video you can see how I can turn on / off my office leds, I want to soft-start and soft-stop from now on (and ofcorse, automatically start and stop using PIR modules) After todays test I'm confident it's not that complicated to dim them, I just need to find the right components.

Thank you !!

Please can you tell me what should I look for in the datasheet?

Look at the Ron value in the data sheet, it will have a test condition showing the gate voltage you need to use to acheave that value. That is what you want to be 3V3.

will it be ok ? Or it will still run hot

How hot it runs depends on the current your strip draws.

Gotcha!

On esp8266, analogWrite() goes up to 1023 by default. So 255 is only 25% of max brightness.

You should either change your code to fade up to 1023, or put

analogWriteRange(255);

in setup().

Either way, you may then find that your MOSFET gets hot.

Ohh .. tonight when I'll get home I will definitely try that! It will be so great if it will work.

But can you tell me if the MOSFET in the adafruit article is much better than mine? IRLB8721 will it run cooler ? Should I buy a different one ? Any recommendation about what mosfet should I buy is welcome.

Thank you.

Update. I did the test 1023, I was extremely curious and I delayed going to a job today, 20 minutes later it's not an issue :D.

but even with the range increased to 1023 it still doesn't light upo the led strip enough, to mee it seems nothing changed. So I will either need to bost with an transistor (what transistor ?) or to get a different mosfet.

thank you

Not "better", just more appropriate for your circuit.

The heat a MOSFET generates depends on its resistance. Lower resistance, less heat, less wasted energy, more led brightness, longer life. To get to the lowest resistance a MOSFET is capable of, you need to get it fully switched on. It starts to switch on at the "Gate Threshold Voltage". You want to go above that, ideally by at least 1 or 1.5V. So driving it with a 3.3V digital output, you want that gate threshold voltage to be 1.8 to 2.3V or ideally even less. Your RFP50N06 probably has a gate threshold of 3V, so 3.3V is only just enough to switch it on.

I have some stp16nf06l and clones of them. They have a gate threshold voltage between 1 and 2.5V, which is fine for 5V Arduinos, but on the limit for 3.3V Arduinos. I have never had a problem with heat, but none of my projects have needed to switch more than about 4 or 5A.

If you want to get a transistor to help your MOSFET switch fully on, any common npn will do, for example bc337.

Another problem that may be contributing to your dim LEDs is using a breadboard. They are not meant to deal with the levels of current you are using. Their spring contacts and internal strips could be adding significant resistance, and also heating up. What I might do is build myself a small module out of stripboard. Solder the MOSFET and screw terminals X 4 (12V in, 12V out, GND, switched-GND) to that and a pair of hook-up wires or PCB pins (GND, MOSFET Gate) back to the breadboard. That way, the high currents don't go through the breadboard. On the parts of the stripboard tracks that carry the high currents, put a good thick layer of solder, enough to cover any holes.

You may also want to make a 12V wire or pin from the mosfet module back to the breadboard, so you can later build a voltage regulator circuit to run the Wemos, and/or for your npn transistor circuit. This will not carry much current, so you can prototype that on breadboard no problem. 12V is ok on breadboard, but currents over 1A are not.

Thank you for giving me the exact names of components, tomorrow I will try to find them locally.

About the breadboard, it's only used as I do my tests, sincerely I didn't expected to be so simple to dim my leds. This means I can remove the relay module and just use a simple 2 (resistor and MOSFET) or 3 (resistor, transistor, MOSFET) components on a PCB ?

Yes, although I would double on the resistors and add a pull down/up resistor to the gate/base to be sure the leds stay off while the uC is off.

PaulRB:
...
If you want to get a transistor to help your MOSFET switch fully on, any common npn will do, for example bc337.
....

Paul, I tried now with BC337-40 but it's not lighting up at all, I also received the IRLB8721 mosfet and it acts the same as the other one I used, it dims the strip but it's not fully lights it up.

Now I don't know why the circuit is not working at all when the transistor is connected like you see in the attached photos.
If I connect the resistor to the large MOSFET base, it dims the led, but if I connect it like you see bellow, it doesn't light up at all. Is the BC337-40 only working with 5v and not 3.3v ?

Thank you for any more advices!

Another resistor was needed on the MOSFET GATE, as it shows in the schematic, but I still think the power is not 100% even with this 10k resistor. I will make some tests again, and also connect the strip directly to the source, to see again the full power. Anyway, now it lights up more than it was before, without that transistor

UPDATE. It's not 100% but it's quite close, maybe it's at 90%. Tomorrow I will check the code on the arduino . The mosfet and transistor are cold, not even warm :smiley: