r/WLED • u/saratoga3 • Feb 15 '25
Wiring up ESP32 grounds correctly
I've seen a lot of questions lately where people wire up the grounds on an ESP32 to the power supply then the strip to the power supply and get a glitching mess. I suggest people not do this, but was curious how much it really mattered. I set everything up on the floor and tested it out here with an ESP32, a 50 ohm resistor (as recommended by the WLED project), a 1 m long data wires and the two grounds joined at a lab power supply (top left). No level shifter was used and the strip is a 12v WS2811. The results were not pretty:

This seems like it should work since the ground and data are connected to the strip with short wires. However, these are RF signals, so they don't move through the wires like low frequency signals do. At the same time, we have no level shifter, so our signal starts out weak, so the strip is very sensitive. Here is a diagram showing what is happening:

When the RF signal is injected into the data line (red), the electric (green) field pulls a matching negative current through the ground wire (blue). However, since the grounds are tried together at the power supply and not the strip, the electric field must cover a large distance and is much weaker, resulting in a high impedance, high noise pick up, and data corruption. In the scope trace we see this as lots of ringing and voltages that spike very high and then negative. Since this wire is just 1 m long, a big enough resistor (and/or level shifter) could probably still fix this bad wiring, but that will quickly fail if the wires get longer or the gap gets larger as you will need a resistor that is too large to drive the load.
Rearranging the wiring is a better solution:

Bringing the wires together and combining grounds at the LEDs (instead of the power supply) completely fixes the glitching. Here I twisted them to keep the close, but tape, twist ties or just using two wire speaker cable would do the same thing. So long as the ground and data wires are physically as close as possible, the ESP32 will be able to drive the pair.
Also, just for fun, here is a 3.3V output of a GLEDOPTO (bypassing level shifter) into a 15m spool of 2 wire speaker cable:

15 times longer than the glitching data cable above and it works perfectly, no level shifter required. I use this for most of my projects and it works great.
Hope this helps.
3
u/AboKhozayem Feb 16 '25
Thanks for the post. Unfortunately, English is not my first language. Could you please consider adding a graph for the connections?
2
u/ree_dox Feb 15 '25
Good point and demonstration! I guess I have just become so accustomed to running Cat5 for everything that its sort of hard to remember it's possible to run the wires as a giant loop.
I typically run 4 strands + the shield as ground, 3 strands for power and 1 strand for data. With 5V data and a resistor, 40, 50 or 60 feet runs don't seem to be a problem.
The 'loop' could also be an issue if grounds or power are run in a big circle, so it is best to keep those in a 'star' formation too - so you literally avoid any ground loop or power loop issues.
7
u/Tehmoep Feb 15 '25
Dude, this post is a gem. I literally spend days trying to understand this problem in the beginning, when I had no fng clue about electronics and couldn't figure out why some projects would be super touchy stressballs, while others were just stable af. The answers on the Internet to this question, which is very common, are either the generic one liners about adding a cap and a resistor or complete books with 500+ pages about signal filtering in circuit design for masters in electrical engineering. This nails it, kudos sir!
6
u/SirGreybush Feb 15 '25
Awesome. We need this in the wiki.
1
u/mlop098 Feb 17 '25
This seems like exactly the problem I had with my setup! I don’t fully understand — if I just had a single strip then I should run the ground between the controller and the strip with the data line to the strip, where I connect it with the power supply ground?
How can I implement this when I have multiple (my setup has 5) strips? Currently I run power to a wago splitter, then to each strip, around 1-2m power line per strip. Data is run from the controller to each strip, same length. I currently connect the ground at the controller, but have a lot of noise issues. Would I need to run a second ground line from the controller to the terminals of each strip with the data line to reduce noise?
1
u/LordBalance Mar 15 '25
You don't see this issue in ws2185 since backup is connected to the ground.
1
u/SameTemperature Mar 15 '25
So basically all the deal was the ground joined at supply and not at leds ? I don’t have this issue but wanted to understand the case so maybe help more people . I naturally kept the grounds separated , like power ground to power supply and data ground together with the data , that seemed logical to me, not criticizing others just curious .
1
u/Significant_Algae988 Mar 28 '25
For me it helped to wrap the data cable several times around a ferrite core.
1
u/AjeebLad Jul 06 '25
Hello, I am having similar glitching issues with my WLED installation. It works perfectly fine when powered directly via USB but as soon as external 5V power is supplied it starts glitching.
To understand this correctly, do I have to make the 5V external power and GND from the adapter to LED strip and then the same for the Arduino board? Basically, Arduino board connects to LED strip with Data, GND and VIN and then external 5V Power supply is connected to LED strip directly at 5V and GND?
Thank you.
3
u/tablatronix Feb 15 '25
Yeah grounds should always run along data, everything else in an antenna, also consider using shielded runs for longer runs
1
u/EquivalentRope6414 Feb 19 '25
This explained a lot to me thank you for this! Funny enough like the user above I’d been using cat5 too just bc that was the wire I had laying around my house and I was like eh this works. Question for you though when you’re doing this setup do connect any diodes ect to protect a short circuit going back to the chip ?