Need help with ESP32 with Blynk to drive 8 Channel LED control

Hi,

I am new to Blynk & ESP32 programming. I used google to complete a custom code to drive an aquarium light with 8 different led channel & PWM control. (For better understanding, I am adding the code after the post).

List of hardware used,

  1. 5V - 30A Power supply
  2. irfz44n N-Chn Mosfet (9 pcs)
  3. High Power 3W SMD LED (20 Royal Blue, 10 Blue, 5 Cyan, 2 green, 3 white, 5 UV, 3 Purple, 2 Red)
  4. 2 pcs 5V Cooling fan
  5. ESP32 Espressif board
  6. Logic level converter

What I did to complete the circuit.

  • For Royal Blue Channel:
  • ESP32 (GPIO 13) to Logiclevel converter to make the signal 3.3V to 5V.
  • Logic level converter to Mosfet Gate
  • Mosfet source to power supply Ground (-)
  • Mosfet drain to 20 pcs 3w LED in parallel.
  • Same goes to all other color of LED's

Note: I did not used any resistor or any other parts that are not mentioned in the post.

Problems:

  1. When i turn on a channel, the LED's are not in full brightness.
  2. Small LED flickering can be noticed in naked eye (8bit, 3000 HZ)
  3. The LED's turns off after few minutes when the load becomes high or when 2-3 channel of LED turned on at the same time.

Main Problem: LED's are not at the full brightness. How can I achieve full brightness of the LED's.

Your help will be highly appreciated.

 #define APP_DEBUG

    // Uncomment your board, or configure a custom board in Settings.h
    //#define USE_WROVER_BOARD
    //#define USE_TTGO_T7
    //#define USE_ESP32C3_DEV_MODULE
    //#define USE_ESP32S2_DEV_KIT

    #include "BlynkEdgent.h"

    int ledPin1 = 16; //White "RX2"
    int ledPin2 = 13; //Royal Blue "D13"
    int ledPin3 = 18; //Blue "D18"
    int ledPin4 = 19; //Purple D19
    int ledPin5 = 32; //UV "D32" 
    int ledPin6 = 21; //Cyan "D21"
    int ledPin7 = 22; //Green "D22"
    int ledPin8 = 23; //Red "D23"
    int ledPin9 = 26; //Master "D26"
    int ledPin10 = 25; //Fan "D25"

    int button_v9_value;
    int pinValue1; //White
    int pinValue2; //Royal Blue
    int pinValue3; //Blue
    int pinValue4; //Purple
    int pinValue5; //UV
    int pinValue6; //Cyan
    int pinValue7; //Green
    int pinValue8; //Red
    int pinValue9; //Master
    int pinValue10; //Fan

    const int chn1 = 0; //White
    const int chn2 = 1; //Royal Blue
    const int chn3 = 2; //Blue
    const int chn4 = 3; //Purple
    const int chn5 = 4; //UV
    const int chn6 = 5; //Cyan
    const int chn7 = 6; //Green
    const int chn8 = 7; //Red
    const int chn9 = 8; //Master
    const int chn10 = 9; //Fan
   
    const int frq = 3000;
    const int res = 8;


    BLYNK_CONNECTED()
    {
      Blynk.syncAll();
    }


    BLYNK_WRITE(V0)
    {
      pinValue1 = param.asInt(); // assigning incoming value from pin V1 to a variable
      if (button_v9_value == 1)
      {
      ledcWrite(chn1, pinValue1);
      Serial.print("V0 Slider value is: ");
      Serial.println(pinValue1);
      delay(30);
      }
    }

    BLYNK_WRITE(V1)
    {
      pinValue2 = param.asInt(); // assigning incoming value from pin V1 to a variable
      if (button_v9_value == 1)
      {
      ledcWrite(chn2, pinValue2);
      Serial.print("V1 Slider value is: ");
      Serial.println(pinValue2);
      delay(30);
      }
    }

    BLYNK_WRITE(V2)
    {
      pinValue3 = param.asInt(); // assigning incoming value from pin V1 to a variable
      if (button_v9_value == 1)
      {
      ledcWrite(chn3, pinValue3);
      Serial.print("V2 Slider value is: ");
      Serial.println(pinValue3);
      delay(30);
      }
    }

    BLYNK_WRITE(V3)
    {
      pinValue4 = param.asInt(); // assigning incoming value from pin V1 to a variable
      if (button_v9_value == 1)
      {
      ledcWrite(chn4, pinValue4);
      Serial.print("V3 Slider value is: ");
      Serial.println(pinValue4);
      delay(30);
      }
    }

    BLYNK_WRITE(V4)
    {
      pinValue5 = param.asInt(); // assigning incoming value from pin V1 to a variable
      if (button_v9_value == 1)
      {
      ledcWrite(chn5, pinValue5);
      Serial.print("V4 Slider value is: ");
      Serial.println(pinValue5);
      delay(30);
      }
    }

    BLYNK_WRITE(V5)
    {
      pinValue6 = param.asInt(); // assigning incoming value from pin V1 to a variable
      if (button_v9_value == 1)
      {
      ledcWrite(chn6, pinValue6);
      Serial.print("V5 Slider value is: ");
      Serial.println(pinValue6);
      delay(30);
      }
    }

    BLYNK_WRITE(V6)
    {
      pinValue7 = param.asInt(); // assigning incoming value from pin V1 to a variable
      if (button_v9_value == 1)
      {
      ledcWrite(chn7, pinValue7);
      Serial.print("V6 Slider value is: ");
      Serial.println(pinValue7);
      delay(30);
      }
    }

    BLYNK_WRITE(V7)
    {
      pinValue8 = param.asInt(); // assigning incoming value from pin V1 to a variable
      if (button_v9_value == 1)
      {
      ledcWrite(chn8, pinValue8);
      Serial.print("V7 Slider value is: ");
      Serial.println(pinValue8);
      delay(30);
      }
    }

    BLYNK_WRITE(V8)
    {
      pinValue9 = param.asInt(); // assigning incoming value from pin V1 to a variable
      if (button_v9_value == 1)
      {
      ledcWrite(chn9, pinValue9);
      Serial.print("V8 Slider value is: ");
      Serial.println(pinValue9);
      delay(30);
      }
    }

    BLYNK_WRITE(V10)
    {
      pinValue10 = param.asInt(); // assigning incoming value from pin V1 to a variable
      if (button_v9_value == 1)
      {
      ledcWrite(chn10, pinValue10);
      Serial.print("V10 Slider value is: ");
      Serial.println(pinValue10);
      delay(30);
      }
    }


    BLYNK_WRITE(V9)
    // This function is triggered when the widget attached to V9 changes in the app
    {
      button_v9_value = param.asInt(); // get the value of the button widget and store
      
      if(button_v9_value == 0)
        {
          ledcWrite(chn1,0);
          ledcWrite(chn2,0);
          ledcWrite(chn3,0);
          ledcWrite(chn4,0);
          ledcWrite(chn5,0);
          ledcWrite(chn6,0);
          ledcWrite(chn7,0);
          ledcWrite(chn8,0);
          ledcWrite(chn9,0);
          ledcWrite(chn10,0);
        }
      else
        {
          ledcWrite(chn1, pinValue1);
          ledcWrite(chn2, pinValue2);
          ledcWrite(chn3, pinValue3);
          ledcWrite(chn4, pinValue4);
          ledcWrite(chn5, pinValue5);
          ledcWrite(chn6, pinValue6);
          ledcWrite(chn7, pinValue7);
          ledcWrite(chn8, pinValue8);
          ledcWrite(chn9, pinValue9);
          ledcWrite(chn10, pinValue10);
        }
    }

    void setup()
    {
      ledcSetup(chn1,frq,res);
      ledcSetup(chn2,frq,res);
      ledcSetup(chn3,frq,res);
      ledcSetup(chn4,frq,res);
      ledcSetup(chn5,frq,res);
      ledcSetup(chn6,frq,res);
      ledcSetup(chn7,frq,res);
      ledcSetup(chn8,frq,res);
      ledcSetup(chn9,frq,res);
      ledcSetup(chn10,frq,res);
      
      ledcAttachPin(ledPin1,chn1);
      ledcAttachPin(ledPin2,chn2);
      ledcAttachPin(ledPin3,chn3);
      ledcAttachPin(ledPin4,chn4);
      ledcAttachPin(ledPin5,chn5);
      ledcAttachPin(ledPin6,chn6);
      ledcAttachPin(ledPin7,chn7);
      ledcAttachPin(ledPin8,chn8);
      ledcAttachPin(ledPin9,chn9);
      ledcAttachPin(ledPin10,chn10);
      
      Serial.begin(115200);
      delay(100);

      BlynkEdgent.begin();
    }

    void loop() {
      BlynkEdgent.run();
    }

These transistors are not suitable for this purpose even if driven with a 5 volt signal. It is better to use logic level transistors such as IRLZ44N.

IRLZ44N is not available in my city. Plus any logic level mosfet are not available at this moment. I managed to get my hand on logic level converter to get 5V signal insted of 3.3V from the ESP32.

1 Like
  1. You should be using switching constant current LED drivers instead of a mosfets.

  2. Power LEDs (that get hot) should never be used in parallel.

This board could drive three series strings of 6 LEDs (18 LEDs) on a 24volt supply.
There are much cheaper ebay clones based on the similar PT4115 chip.
This board I made some time ago, with the PT4115, can drive 16 strings of 3-7 LEDs (112 LEDs).
Leo..

2 Likes

Hi Wawa,

Thanks for your kind feedback. I know i need a constant led driver to run high power led. But in our country, it's not that much available.

Do you have any tutorial of the driver you made for 112 led's.

It's just used the default circuit on page 11 of the PT4115 datasheet,
with L 47uF and Rs value for ~660mA (about 2watt).
Up to six LEDs can be put in series if Vin is 24volt.
Five LEDs in series and an old 19volt laptop supply is another cheap way.
These boards could be a base for experimenting.
I have used a 16-channel PCA9685 to drive the DIM pin,
but for a few channels you could just use the Arduino PWM pins.
Leo..

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.