Controlling LED Light Intensity with ESP32

Might be normal. Take your multimeter and measure the converter output voltage 40% and 100%. Is it 4V and 10V? Probably not. You can compare that to voltage of the “manual” dimming, what voltage levels you read when it turns off?

Also, while common Gnd works here, ideally you take benefit of optoisolator and have local gnd between Esp and converter.

You can also try adjusting the frequency and setting gamma correction to 0

output:
  - platform: ledc
    pin: GPIO18
    id: gpio_18
    frequency: 1220Hz

# Example usage in a light
light:
  - platform: monochromatic
    output: gpio_18
    name: "Lumii Black LED"
    gamma_correct: 0
1 Like

I’ve done what you recommended, thanks. I connected the ESP and Converter so, that they have local ground now.

I also did some measurements with the manual dimm controller. Here are my results:

OFF: 0V
25%: 2.66V
50%: 5.21V
75%: 7.31V
100%: 10.14V

From the 12V+ I get 12.03V, which is expected I think.

@Mikefila: I’ve implemented your recommendation as well and added frequency and gamma_correct. I’ve played around with it a little and found out, when I put the gamma_correct to “0.5”, I can go down to 1% and the light doesn’t turn off.

I’ll go on Vacation in a few days, so I can’t make anymore tests in the next month. But as soon as I’m back, I’ll test the initial setup with the buck converter. My goal is to not have an additional power supply to power the ESP. But if this doesn’t work out, I’ll have to power it with an additional power supply then.

So far I want to thank everyone in this thread :heart:. I’ve learned a lot on this little journey and I’m glad that we have this helpful community. My next project will be speed controlling a PWM Inline Duct Fan with ESP hehe.

So those are spot on. I meant to compare it to converter voltage output with same dimming levels.

Hi everyone, I’m back and I’ve had some success.

I’ve set up my original plan with the buck converter, and it works! I’ve also changed the gamma correct in the ESP32 config to “0.6”. The output voltages of the PWM converter now are:

OFF or 0%: 0.59 V
1%: 0.87 V
25%: 4.51 V
50%: 6.68 V
75%: 8.38 V
100%: 9.88 V

I can still go down to 1% and the light doesn’t turn off. So, everything is working now as planned, without an extra power supply for the ESP32. The next step is to make a nice enclosure with a 3D printer because I can’t fit all the components in the old case anymore :sweat_smile:

My final scheme is also attached:

Thanks again for everyone supporting me on this journey!

2 Likes

You can add zero_means_zero: true under the output section to bring the output to 0V.

Thanks for the tip. I’ve tested it but it doesn’t do anything. The output of the PWM converter stays at 0.59V at 0%. Also measured the PWM input, I’ve got 0 V at 0%, with and without the ZMZ-Parameter.

Can this be dangerous if the PWM conv. constantly outputs 0.59V at 0% or could it be normal? Just curious.

btw this is the PWM converter I’m using:

Did you measure that with output wire disconnected?

No everything is connected like on the last scheme I’ve uploaded.

My measurements were:

VOUT/GND on…
0%: 0.59V
1%: 0.87V

PWM/GND on…
0%: 0V
1%: 0.22V

You could measure if there is any current draw through the LED lights.

Alright I did some more research and tests. The 0.59V stays, no matter what I do. I figured out that the LED Driver has a threshold around 0.8-0.9V. Everything below is considered “off”. I also calibrated the PWM to Voltage converter with the potentiometer on the PCB to exact 5V with 50% PWM signal.

However, I must use the gamma_correct parameter in order to go down to 1% without the light turning off.

The 0.59V on VOUT can be caused by several reasons, but it’s harmless.

Possible reasons are:

  • Op-Amp Offset Voltage
  • Residual Charge or Leakage Currents
  • No Pull-Down Resistor on VOUT
  • LED Driver Interaction
  • Nonlinear Circuit Design
  • Internal Calibration or Design Limitations

I also found in the docs of the PWM to Voltage converter that it has an allowable error of 5%, which could be these 0.59V.

So far I think I’ll draw the line here, since these 0.59V aren’t causing any unintended behavior on the light.

I need a beer now, cheers :fist:t2:

1 Like