Hello folks, I’m struggling with controlling my 5m strip of 300 WS2812B LEDs. I’m using a NodeMCU Arduino Nano clone that’s built around an ESP8266 WiFi module.
One issue is that the logic levels seem to be reversed. I need to use CRGB::White to turn off the strip. This works without any problems. However, when I try outputting the complement of other colors, the results are inconsistent. Sometimes the 30 LEDs all show the same color, and other times they show repeating patterns. This suggests to me that there may be a timing issue that’s causing commands to be incorrectly split between LEDs.
A potential source of problems is my logic level shifter. My microcontroller outputs 3.3V logic, so to switch that to 5V logic, I used a P2N2222A that was lying around my office. It seems to be working as intended, but I don’t totally trust it. (I have a proper converter being shipped from China, but it won’t arrive for a few weeks.)
I have included all of my current code in a Gist below, as well as a Fritzing image of my circuit. The pictures of my LED strip show “Orange” (repeating pattern of 5 LEDs) and “Green” (all the same, but not green).
Your level shifter is likely the source of your problems - many shifters are too slow for the ws2812 timing accuracy (using white to register as all black is a big sign that something is wrong there). You can remove it for the time being until you get the proper shifter - you’ll just need to make sure that your power source into the leds is putting out less than 5.1 or 5.2 volts.
Okay, thanks Marc and Daniel! I’ll hook it up to an adjustable power supply at my office to drop the supply voltage for now.
I looked at the transistor datasheet, but I wasn’t sure how to judge its suitability. I got another transistor in an electronics kit, so I might try that one too. Is there a guideline for the response time required to switch fast enough?
I’m hoping the generic level shifter I ordered is sufficient, but I’ll probably end up buying some of the ones that Marc suggested.
Two issues.
The 2N2222 NPN transistor by itself will act as an inverter in the tradition usage. Or in another configuration it could act as a “make shift” level shifter but would possibly be too slow and outside proper voltage level specs. You’d need an NPN driving a second NPN or PNP to act as a proper buffer/level shifter.
Secondly, your wiring is too thin for the potential current draw, plus it goes through the breadboard. Both of those will cause a big voltage drop as you illuminate any significant number of LEDs.
I tried using an adjustable power supply, but that didn’t work. I found a USB B cable and tried out the Arduino Uno that was in my electronics kit and that worked!
I guess that until my 74HCT245s arrive, I’ll have the Uno control the LED strip, and use the NodeMCU microcontroller as the master of the system - handling button inputs and WiFi requests and relaying them on to its slave.
I’ve been meaning to try out my nRF24L01 2.4GHz transceiver modules, so this seems like a good excuse! Once I have some 74HCT245s, I’ll use them with my Arduino Nano clones.
Commander @Kean_Maizels , the male-male wires that came with my kit are really high-gauge - they feel pretty flimsy. What gauge wire would you recommend I buy?
My 5V 10A power supply came with a barrel-to-screw plug adapter. I originally used some very thick many-stranded wires to connect that directly to the male JST connector that came with my LED strip.
Once my capacitors arrived, I connected the many-stranded wires to the right side of the breadboard, and used the other pair of wires that were included with the LED strip to connect to the left side of the breadboard. There was a female JST connector at the other end of the LED strip, so I plugged that into the breadboard via the flimsy male-male wires so that both ends were powered/grounded (those are the most prominently displayed connections in my photos, although they were really more of an afterthought).
How would you recommend transitioning from the barrel-to-screw adapter to the LED strip (while keeping the capacitors involved somehow)?
-------
I’m eventually planning on having two ~1.7m strips along the sides of my bed and another two ~1m strips elsewhere, so wiring everything may get tangly. If I put the 3rd and 4th strips on top of my wardrobes on the opposite side of the room, I had considered using lithium battery packs to power them, but I’ll have to run some numbers and figure out whether that’s viable.
What do you mean “really high-gauge”? Don’t believe the specifications from the “manufacturer”. Stiffer wire can actually just be thicker or lower quality PVC insulation. The amount of copper in those breadboard wires is generally just enough for typical digital circuits, not powering long LED strips.
The gauge of wire needed is a factor of current draw, wire length (both supply and return paths), and maximum acceptable voltage drop. I might use 20AWG or 18AWG depending on cable lengths and current draws. And even heaver stuff with bus bars when dealing with very large LED installs and 100’s of amps.
Those type of breadboard wires are typically 24AWG or 26AWG. Lets be generous and say 24AWG at 84mOhm/m. So at 10cm (x2) that is only 17mOhm round trip. At 3A, that would drop 50mV - no problem. But if you had a total of 2m of cable from PSU to LEDs (4m round trip) you would drop 1V at 3A. That’s enough to cause problems, even before you account for additional voltage drop along the length of the strip itself.
But note that if you put more than 3A through a 24AWG wire it will probably get hot enough to melt the insulation. Just try shorting the 10A PSU with your thin wires!
The actual crappy connections in the breadboard will add significantly higher resistance than short wires, just to compound the issue.