Anyone got the Adafruit NeoPixel ring working? [SOLVED]

Referring to this product:

The closest I’ve been able to get is this code (which actually crashes my Photon)…

/*
 * This is a minimal example, see extra-examples.cpp for a version
 * with more explantory documentation, example routines, how to 
 * hook up your pixels and all of the pixel types that are supported.
 *
 */

#include "application.h"
#include "neopixel/neopixel.h"

SYSTEM_MODE(AUTOMATIC);

// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN D6
#define PIXEL_COUNT 24
#define PIXEL_TYPE WS2812

Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);

void setup() 
{
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}
void loop() 
{
  rainbow(20);
}

void rainbow(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256; j++) {
    for(i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel((i+j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  if(WheelPos < 85) {
   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } else if(WheelPos < 170) {
   WheelPos -= 85;
   return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else {
   WheelPos -= 170;
   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
}

i have 3 photons - each with a 16 Neopixel Ring (not the kit you’re using) and the code you use for controlling the pixels should work.

Are you using the latest Neopixel library?

#include "application.h"

and

SYSTEM_MODE(AUTOMATIC);

do not seem necessary to me - although i can’t imagine any negative sideeffect.

Do the Pixels light up at all? What is the Photons Status LED Doing before and when “crashing”?

Looking into the neopixel library, I can see the following in neopixel.cpp:

  switch(type) {
    case TM1803: // TM1803 = 24us reset pulse
      wait_time = 24L;
      break;
    case TM1829: // TM1829 = 500us reset pulse
      wait_time = 500L;
      break;
    case WS2812B: // WS2812 & WS2812B = 50us reset pulse
    case WS2812B2:
    case WS2811: // WS2811 = 50us reset pulse
    default:     // default = 50us reset pulse
      wait_time = 50L;
      break;
  }

As you can see, the switch case is for the types of neopixel LEDS. You defined PIXEL_TYPE WS2812 in your code, a type that does not exist in the library. Googling around I found out that one of the differences between WS2812 and the WS2812B is timing, the WS2812B uses slightly different timing. Also, the WS2812 has 6 pins where the WS2812B has 4 pins. Looking at the product pictures at adafruit, it looks like you got WS2812B leds on the board, not WS2812 as adafruit says.

So change PIXEL_TYPE WS2812 to PIXEL_TYPE WS2812B and you should be fine! :smile:

Edit: I now see the comment at case WS2812B: // WS2812 & WS2812B = 50us reset pulse so it doesn’t even matter if you have WS2812 or WS2812B :slight_smile:

Using the NEOPIXEL 0.0.7 public library.

I’ve removed those 2 lines with the same effect:

Code flashes successfully, Photon connects to the cloud then immediately start breathing magenta (blue+red), followed by blinking magenta.

Problem persists.

hmm, interesting. Does the photon still crash?

  1. Code flashes successfully
  2. Photon connects to wifi then cloud
  3. Photon breathes magenta (red+blue) a few times
  4. Photon blinks magenta forever

Have to ‘fix’ it with:

particle flash --usb tinker

How long did you wait at step #4? Reading this topic makes me think its busy flashing new firmware which could take up to 10 minutes.

Does “NEOPIXEL 0.0.7 public library” equal to:

Github ported Neopixel lib

or the lib in WEB-IDE? (https://build.particle.io/libs/55bfa963caf78dbf5e00072a/tab/neopixel.h)

The 55bfa963caf78dbf5e00072a lib in the web ide.

I’ve left it for at least 20 minutes now and it’s still magenta.

Did you try a factory reset? If not, do that and then flash code again (with ~10 minute wait if it still flashes magenta)

Edit: very bad mistake of me here, don’t do a factory reset if you experience the problem in this topic. See this pinned topic

SOLVED!

According to the docs, factory reset is not available for the Photon. So I tried the following…

  1. Entered DFU mode
  2. particle flash --usb tinker
  3. Flashed a very simple “blink led” script via the web ide

At this point it started blinking magenta for 5 mins, then I got a few flashes of white, etc and then back to blinking magenta for 3 minutes. After that, everything seems fine with the simple script running successfully.

Next, I flashed the original NeoPixel code mentioned above and it works!

My guess is that somehow the neopixel script was interfering with the firmware update process?

1 Like

@bufferout, your initial behaviour sounds pretty much like a system FW update that was interrupted and now might not get out of it anymore.

There were some threads about that issue, maybe you can find it before me, otherwise I’ll come back to post some links.


OK, just seen your success-post :+1:
Can I mark this as solved then?

Happy to hear it is solved, I was confused with the core haha.

Well, I guess so since flashing a simple project worked.
Perhaps some of your not necessary declarations as #include "application.h" may have caused some trouble. Something else could be the usage of an external library which could have interrupted the FW update. Anyhow, yayy!

Thanks for your help btw- was driving me crazy.

From my noob perspective it feels like the firmware update process is flawed if user code can dramatically interfere with it.

1 Like

Yes, solved thank you: to be clear the issue wasn’t so much the neopixel code as a broken firmware update.

1 Like

I think it’s not user code that interfered here but user patience and user hardware access to the reset button and the power supply :wink:

1 Like