Due to high demand expect some shipping delays at this time, orders may not ship for 3-4 business days. On MLK Day no orders will be shipped.
0

Single NeoPixel should be near White but is very Yellow
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Single NeoPixel should be near White but is very Yellow

by swooby on Wed Dec 08, 2021 2:16 am

I am trying to figure out why the single neopixel on my Qt Py SAMD21 is very Yellow when I set it to any close or precisely equal red+green+blue value:
Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_NeoPixel.h>

#define PIN PIN_NEOPIXEL
#define NUMPIXELS 1

Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  Serial.println("setup()");
  Serial.begin(115200);
  pixels.begin();
}

void setPixelColor(int r, int g, int b) {
  log("setPixelColor(" + String(r) + ", " + String(g) + ", " + String(b) + ")");
  uint32_t c = pixels.Color(r, g, b);
  log("setPixelColor:   raw c=0x" + rgbString(c));
  //c = pixels.gamma32(pixels.ColorHSV(hue, sat, val));
  uint32_t c2 = pixels.gamma32(c);
  log("setPixelColor: gamma c2=" + String(c2) + " 0x" + rgbString(c2));
  pixels.setPixelColor(0, c);
  pixels.show(); 
}

void loop() {
  for(int i=0; i < 255; i++) {
    setPixelColor(i, i, i);
    delay(100);
  }
}


(I left out some of the supporting logging code)
Video of this running is at: https://youtu.be/zFjsR3X024o

I can get a pseudo-white value by setting the neopixel to values (r=5, g=5, b=25), or some similar ratios.

I do not expect the RGB to output a pure white, but I do expect it to output some white close to what is in the product/marketing photos for RGB non-W NeoPixels.

Is there a trick to getting a better white out of RGB non-W NeoPixels?

Thanks.

swooby
 
Posts: 67
Joined: Wed Jun 19, 2019 4:09 pm

Re: Single NeoPixel should be near White but is very Yellow

by blnkjns on Wed Dec 08, 2021 4:55 am

Seems defective. Usually at equal RGB values these LED's should appear cool/bluish, and you need to lower the blue and green to get a warmer white.

blnkjns
 
Posts: 696
Joined: Fri Oct 02, 2020 3:33 am

Re: Single NeoPixel should be near White but is very Yellow

by swooby on Wed Dec 08, 2021 11:59 am

blnkjns wrote:Seems defective. Usually at equal RGB values these LED's should appear cool/bluish, and you need to lower the blue and green to get a warmer white.


I have a 2nd Qt Py SAMD21 and even 2 Qt Py RP2040s that I will give a try...

swooby
 
Posts: 67
Joined: Wed Jun 19, 2019 4:09 pm

Re: Single NeoPixel should be near White but is very Yellow

by swooby on Wed Dec 08, 2021 3:29 pm

Interesting. The same board/neopixel works fine in CircuitPython.
https://youtu.be/yyeEaRYPPT4

Ardunio code:
Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_NeoPixel.h>

Adafruit_NeoPixel pixels(1, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800);

String toHexString(byte value) {
     char tmp[3];
     snprintf(tmp, sizeof(tmp), "%02X",  value);
     return String(tmp);
}

void setup() {
  Serial.begin(115200);
  pixels.begin();
}

void loop() {
  for(int i=0; i < 255; i++) {
    Serial.println("i=0x" + toHexString(i));
    pixels.fill(pixels.Color(i, i, i));
    pixels.show();
    delay(050);
  }
}


CircuitPython code:
Code: Select all | TOGGLE FULL SIZE
import time
import board
import neopixel

pixels = neopixel.NeoPixel(board.NEOPIXEL, 1)

while True:
    for i in range(255):
        print('i=0x%02x' % i)
        pixels.fill((i, i, i))
        time.sleep(0.050)


Why does the Arduino code look an unexpected very-Yellow when the effectively identical CircuitPython code on even the precise exact actual same device looks the expected near-White?
It also does not matter what USB-C port I connect to; the Arduino is always yellowish even when I plug it in to a port that the CircuitPython was just running as whiteish.

swooby
 
Posts: 67
Joined: Wed Jun 19, 2019 4:09 pm

Re: Single NeoPixel should be near White but is very Yellow

by adafruit_support_mike on Wed Dec 08, 2021 11:30 pm

You may be seeing an effect of under-voltage we call 'red-shift':

An LED's forward voltage is related to the color of the light it emits.. around 1.7V for reds, 2.2V for greens, and 3.0V for blues. If the supply voltage falls below its expected value, the blue LEDs will be the first to start getting dimmer than they should be. That tilts the whole color spectrum toward the red end.

adafruit_support_mike
 
Posts: 63921
Joined: Thu Feb 11, 2010 2:51 pm

Re: Single NeoPixel should be near White but is very Yellow

by swooby on Wed Dec 08, 2021 11:48 pm

adafruit_support_mike wrote:You may be seeing an effect of under-voltage we call 'red-shift':

An LED's forward voltage is related to the color of the light it emits.. around 1.7V for reds, 2.2V for greens, and 3.0V for blues. If the supply voltage falls below its expected value, the blue LEDs will be the first to start getting dimmer than they should be. That tilts the whole color spectrum toward the red end.


Thanks. But why does this appear to only happen in the Arduino code?
The exact same device on the exact same cable in the exact same port running CircuitPython shows a near white pixel.

swooby
 
Posts: 67
Joined: Wed Jun 19, 2019 4:09 pm

Re: Single NeoPixel should be near White but is very Yellow

by adafruit_support_mike on Fri Dec 10, 2021 4:50 pm

I’m not sure. Try measuring the votage at the closest point to the first misbehaving pixel and see if there’s any difference between the two cases.

If you’re using USB-C, there may be some difference in the way the devices negotiate power with the USB hub.

adafruit_support_mike
 
Posts: 63921
Joined: Thu Feb 11, 2010 2:51 pm

Re: Single NeoPixel should be near White but is very Yellow

by swooby on Fri Dec 10, 2021 8:07 pm

It's the exact same device, using the exact same single NeoPixel on the PCB, on the exact same USBC cable and port.
I'll try to get a voltmeter on there.
It repros on 4 out of 4 QT Py SAMD21 boards.
CircuitPython works fine: pixel is white when command to be white.
Exact same code logic in Arduino: pixel is yellow when commanded to be white.

swooby
 
Posts: 67
Joined: Wed Jun 19, 2019 4:09 pm

Re: Single NeoPixel should be near White but is very Yellow

by adafruit_support_mike on Fri Dec 10, 2021 8:22 pm

In situations like this you have to hold tight to the fact that hardware is deterministic: everything that happens has a cause, and anything that happens repeatably has a repeatable cause.

Our knowledge of hardware, OTOH, is heuristic: we work from principles we remember, and extrapolate from them. And we *really* like our heuristics, which creates problems when the hardware doesn't do what we expect. The laws of physics are immune to social engineering though, and don't care what we expect. Debugging is as much a process of changing our heuristics as of getting the hardware to work, and our minds don't like that.

That's why the best practices in debugging boil down to methodical testing of everything we think we know, in order to find the first place where the hardware does something we didn't expect. We have to stop believing anything that hasn't been confirmed instrumentally, and to be just a bit suspicious of everything we've only measured in one way.

adafruit_support_mike
 
Posts: 63921
Joined: Thu Feb 11, 2010 2:51 pm

Re: Single NeoPixel should be near White but is very Yellow

by swooby on Fri Dec 10, 2021 10:31 pm

adafruit_support_mike wrote:In situations like this...


Uh, sure...but literally the only difference between (16,16,16) being near-white or very-yellow is if CircuitPython or Arduino is used.
Same board.
Same cable.
Same port.
Same code (one CircuitPython, one Arduino C++).
https://youtu.be/FqrdBty0GVs

Same thing on 4 out of 4 QT Py SAMD21 boards.

Can Adafruit confirm with known good working QT Py SAMD21's in their test stock if the following Arduino code has the neopixel show near-White or very-Yellow?
Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_NeoPixel.h>

Adafruit_NeoPixel pixels(1, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800);

void setup() {
  pixels.begin();
  pixels.fill(pixels.Color(16, 16, 16));
  pixels.show();
}

void loop() {
  delay(100);
}


The following CircuitPython code works fine on literally the exact same hardware:
Code: Select all | TOGGLE FULL SIZE
import time
import board
import neopixel

pixels = neopixel.NeoPixel(board.NEOPIXEL, 1)
pixels.fill((16, 16, 16))

while True:
    time.sleep(0.100)


Same behavior on 4 out of 4 QT Py SAMD21s.

swooby
 
Posts: 67
Joined: Wed Jun 19, 2019 4:09 pm

Re: Single NeoPixel should be near White but is very Yellow

by swooby on Sat Dec 11, 2021 3:36 am

I'll see if I can get a probe down on one of these two pins and ground.
Screenshot 2021-12-10 233640.jpg
Screenshot 2021-12-10 233640.jpg (76.5 KiB) Viewed 225 times

QT Py SAMD21.png
QT Py SAMD21.png (632.01 KiB) Viewed 225 times

V is the neopixel power.
D is the neopixel data.
Which one are we interested in?
Are we interested in the voltage of the power, or the voltage of the data...the latter of which I would think I need an oscilloscope or logic analyzer, which I have neither of.

swooby
 
Posts: 67
Joined: Wed Jun 19, 2019 4:09 pm

Re: Single NeoPixel should be near White but is very Yellow

by westfw on Sun Dec 12, 2021 5:53 am

I think I can confirm that something weird is going on with the QT Py running Arduino, like one color will be "starved" depending on the other color values.
For example, the blue LED is visibly brighter when you use setcolor (1, 1, 2) than it is with (2, 2, 2) Likewise 9,9,10 vs 10,10,10.
Unfortunately, the only digital microscope I have is all automatic exposure, making this difficult to document.

neopixel_test.zip
test aduino sketch
(4.13 KiB) Not downloaded yet

westfw
 
Posts: 1814
Joined: Fri Apr 27, 2007 1:01 pm
Location: SF Bay area

Re: Single NeoPixel should be near White but is very Yellow

by westfw on Sun Dec 12, 2021 6:31 am

I fiddled more with the microscope.
Here's a pic with settings 9,9,10
9-9-10.jpg
9-9-10.jpg (210.72 KiB) Viewed 197 times


And here with 10,10,10
10-10-10.jpg
10-10-10.jpg (211.88 KiB) Viewed 197 times


(those should be nearly identical, right? But in the 10,10,10 case, the blue has gotten much dimmer compared to red and green.
Interestingly(?) with 0,0,10 the blue looks significantly brighter (but now the autoexposure is interfering with recording.))

westfw
 
Posts: 1814
Joined: Fri Apr 27, 2007 1:01 pm
Location: SF Bay area

Re: Single NeoPixel should be near White but is very Yellow

by swooby on Sun Dec 12, 2021 7:41 am

westfw wrote:I fiddled more with the microscope.
Here's a pic with settings 9,9,10
9-9-10.jpg


And here with 10,10,10
10-10-10.jpg


(those should be nearly identical, right? But in the 10,10,10 case, the blue has gotten much dimmer compared to red and green.
Interestingly(?) with 0,0,10 the blue looks significantly brighter (but now the autoexposure is interfering with recording.))


And this is using the Arduino code, but the same levels in CircuitPython work as expected with near equal light levels?

Excellent to hear someone else confirm the same thing.

It is just only little pixel and not very important in the grand scheme of things, but I am just trying to understand why it is behaving one way in Arduino and another in CircuitPython, and perhaps there is a small easy to fix bug in the Arduino neopixel driver code.

swooby
 
Posts: 67
Joined: Wed Jun 19, 2019 4:09 pm

Re: Single NeoPixel should be near White but is very Yellow

by adafruit_support_mike on Sun Dec 12, 2021 6:53 pm

You want the supply voltage to the pixel. The data voltage has no effect on color unless it's low enough to drop bits.

I'll check to see if there's some kind of gamma table in the CircuitPython NeoPixel code that would cause a color shift. I don't know of one, but haven't read all the code recently.

adafruit_support_mike
 
Posts: 63921
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.