0

I'm going crazy, there is clearly something I'm missing here. I have a NodeMCU V3.0 and a 5V LED strip WS2812B with 10 diodes. I tested this first with a 5V 0.3A power supply, only powering 3 diodes, this worked fine.

Than I changed the power supply to a 5V 2A (Measured to 5.2V) and now the colours are way off, they even change everytime its updating, even though nothing is changed. I put my voltmeter across "D3" and "GND" and suddently the LEDs were perfect and stable.

If I remove it again, the LEDs change to random colours again, I tried pulling "D3" to ground with a 10 kOhm resistor, but this doesn't change anything.

What is going on here, why isn't it working, and why does it work with the voltmeter?

WS2812B

Code:

#include <ESP8266WiFi.h>
#include <FastLED.h>

#define LED_PIN     3
#define NUM_LEDS    10

CRGB leds[NUM_LEDS];
int R = 255;
int G = 90;
int B = 10;

//Set up MQTT and WiFi clients
WiFiClient client;

void setup()
{
  FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
  Serial.begin(9600);

  //Connect to WiFi
  Serial.print("\n\nConnecting Wifi... ");
  WiFi.begin(WIFI_SSID, WIFI_PASS);
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
  }
  Serial.println("OK!");
  pinMode(D4, OUTPUT);
  digitalWrite(D4, HIGH);
}

void loop()
{
    leds[0] = CRGB(255, 0, 0);
    leds[1] = CRGB(0, 255, 0);
    leds[2] = CRGB(0, 0, 255);
    FastLED.show();
    delay(5000);
}
4
  • Have you tried another pin?
    – Matej
    Mar 13, 2019 at 10:45
  • Remove the resistor. There is also way way to use one WS2812 as a booster for the rest of the WS2812, check out elec-tron.org/wp-content/uploads/2015/10/ws2812bconverter.jpg
    – MatsK
    Mar 13, 2019 at 16:26
  • if the resistor in your DMM (likely 10m) pulls down the signal and makes it work, it stands to reason that you can simply add your own pull-down resistor to make it work the same.
    – dandavis
    Mar 13, 2019 at 17:50
  • That was my first thought as well, but adding a 10k OHM to pull down the data pin (same spot I measured) did nothing, so I’m still puzzled why measuring didn’t anything
    – Yoshidk
    Mar 15, 2019 at 8:12

1 Answer 1

2

WS2812B LEDs are 5V devices. The NodeMCU is 3V. Your first 5V supply will probably have been somewhat under 5V once the NodeMCU had taken a big chunk of the current (see Voltage Droop). This would mean that the Logic High Threshold would be within the bounds of the 3.3V output by the NodeMCU.

However, with your new high powered power supply that voltage droop will be less prevalent (added to the fact that it's measuring 5.2V), and so the logic high threshold will be higher. At, or very close to, the 3.3V that is output by the NodeMCU. That makes it rather unstable at communicating, since the logic HIGH may not always be above that required HIGH threshold.

Adding your voltmeter obviously changes that logic signal so that it stabilizes above the required threshold (the volt meter input has capacitance. That will help hold the line higher for longer).

To drive 5V devices from a 3.3V MCU you really need to add a logic level shifter, or ensure that the power supply isn't too high.

The WS2812B has a logic HIGH of 0.7 × Vdd. At 5V that's (0.7*5=) 3.5V. That's close, but not quite there. Your original power supply was probably putting out more like 4.75V under load. That would be 3.325V for a logic high - just about manageable by a NodeMCU.

However at 5.2V the logic HIGH will be 3.675V, which is way above the 3.3V that the NodeMCU outputs.

So you either need to:

  • Add a 3.3V to 5V logic level shifter, or
  • Reduce your LED power input voltage to below 4.75V.

The latter can be done by adding a single series diode with a suitable current handling capacity to the VDD connection. That will (depending on the diode) drop around 0.7V taking you to about 4.5V (the actual drop usually depends on the current to a certain extent). The WS2812B will happily run from 3.5V to 5.3V.

5
  • I think I understand, thank you This diode, could it be like this: 1N4001 ? And will it create a loss of power?
    – Yoshidk
    Mar 13, 2019 at 11:11
  • I'd probably go for a 1N5402. The 1N4001 is only 1A rated. The 1N5402 is 3A rated. Yes, it will lose some power. But losing some power is what you want - you have too much at the moment ;)
    – Majenko
    Mar 13, 2019 at 11:14
  • @Yoshidk I think you can lower the voltage for the first chip only. Its output will be up to its power supply voltage
    – KIIV
    Mar 13, 2019 at 22:05
  • @Yoshidk Or, maybe adding diode between power ground and NodeMCU ground could provide the same service without cutting the LED strip.
    – KIIV
    Mar 13, 2019 at 22:13
  • I added a diode in series to lower the voltage to 4.6V, and now everything works, thank you
    – Yoshidk
    Mar 15, 2019 at 8:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.