I set up an ESPHome / HA integration to control lighting on a project I made. Full setup & code at end of the post. Initially, it worked great. Recently, I found that even when set at 100% brightness in HA, the LEDs seemed much more dim. I broke out the multimeter and found that at 100%, only a bit over 3V was being delivered to each strand of LEDs instead of the full 12V.
I thought it may be due to the IRF520 MOSFet I was using, so swapped it out with an RFP30N06LE 30A 60V N-Channel but got the same results. I’m almost certain the issue has to be software as I have the same hardware config + code (except using 12V LED strip instead of sets) for another project and it works great. BTW - I’ve obviously restarted the Wemos + have updated the firmware to the latest.
Is it possible to put a scope on the LEDs to see if the dimness/voltage is due to PWM, or something else like a DC-current problem?
A voltmeter will tend to read the average of a PWM signal, so you can’t really tell by just voltage.
You might also not need those resistors, as this is not like a conventional transistor. The logic level from the ESP is all it should need at the gate. Having a 1K pull-down on there may be overcoming the logic signal from the ESP, preventing the gate from fully opening.
Sorry, but what do you mean about a scope on the LEDs? Perhaps I can try a different power source as well. Doubt its due to resistors since had same results with an IRF520 + have same setup on that other project without issue.
I was referring to an oscilloscope, which would reveal if the dimness is due to the ESP time-slicing the on-time signal, or not. That’s something an ordinary voltmeter can’t reveal.
But an easy way to rule that out would be to temporarily unhook from the ESP’s GPIO pin and pull that gate resistor to +V (or to gnd, depending on the polarity of the MOSFET. one will turn it on, the other off). The LEDs should come on to full-brightness.
Also, you might consider inserting a gate driver on the ESP-to-gate line. At high PWM rates, the inherent capacitance in the gate (even a logic-level one) can look like almost a dead-short to the ESP, drawing currents from the ESP that might be over-stressing that GPIO line and causing it to misbehave.
Thinking further at this, and thinking about the gate capacitance, those resistors become my “Suspect #1” as they will slow down the rise/fall time at the gate. That is, the gate acts like a capacitor, and a capacitor’s charge/discharge time is slowed down by resistance. That may be enough to keep the light from being on as long as the PWM is asking it to. Try just wiring the gate direct to D7, with no inline or pulldown resistor.
OK, so below are the tests I conducted and their results…
Bypassed the resistor between gate & GPIO: When turned up to 100%, it was still dim - no difference at all in brightness level
Connected Gate to V+: I tried both 5V & 12V +, but both yielded the same result of the brightness level still being dim
Changed power supply: Swapped the power supply with one from another project which produces a few more (4.35) amps even though shouldn’t be needed - no change
This causes your MOSFET to be driven at a guaranteed 100% duty cycle. If the LEDs are still dim then there are only a few causes:
your MOSFET has a high Rds ON value.
your cabling to the LEDs has a high resistance…
Speaking of resistance, where are the current limiting resistors for your LEDs?
None are shown in your circuit above.
You have 8 groups of 4 series LEDs in parallel. If one of those groups has a lower on voltage than the rest it will prevent the other groups from lighting fully. Each group should have a low value series resistor to prevent this.
I don’t have any resistors. Each LED is 3V and voltage is 12V which is why I have them in groups of 4. I guess its possible that a lower voltage LED got mixed in. Will check and see.
Each LED is nominally 3V. Not exactly 3V. And they as they are diodes they are very non linear around the turn on voltage, small differences in voltage have big effects in luminosity.
Not only that but their voltage changes with temperature. As they heat up the voltage lowers, allowing more current, which heats more which allows more current… etc until smoke comes out.
Understood, but I still measured 3V being sent to each group of 4 when at 100% though. Here’s a link to the exact LEDs for reference. I’ll guess I’ll test with individual groups of 4 to see what happens unless someone has another suggestion.
I disassembled and tested each strand of 4. One of them (last one I checked of course) wasn’t nearly as bright as the rest. Everything was soldered well and obviously current could pass through. Did notice that they occasionally blinked on/of so going to assume its a bad LED somewhere. Replaced entire strand and all back to normal.
You were right - it happened again. What do you mean by “per-string current limiting”, exactly? I’ve got 12V going to x4 3V LEDs so didn’t think I’d need resistors. Would adding a 10ohm resistor to each string be enough? Please explain.
Read the articles (plus others) and tried to do my homework, but can’t figure out what to use. Below are 3 schematics I drew up really quick. The one on the left is how it’s currently wired. The middle one is with resistors introduced, and the right one with a current mirror (I think). It’s my understanding that the middle one would work, but that the left one would be the ideal solution. If so and given that the power source is 12V 4.58A DC and LEDs are 3V 20ma, what resistors / transistors should I use?