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,
- 5V - 30A Power supply
- irfz44n N-Chn Mosfet (9 pcs)
- High Power 3W SMD LED (20 Royal Blue, 10 Blue, 5 Cyan, 2 green, 3 white, 5 UV, 3 Purple, 2 Red)
- 2 pcs 5V Cooling fan
- ESP32 Espressif board
- 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:
- When i turn on a channel, the LED’s are not in full brightness.
- Small LED flickering can be noticed in naked eye (8bit, 3000 HZ)
- 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.
** For blynk datastream I used 0-160. As 160 provides me with 3.6V measured with multi tester. After getting dimmed LED, I changed the maximum to 255. Still same result.**
Your help will be highly appriciated.
#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();
}