neopixel ring 16 infrequent self-lighting only when wifi has been initialized once

rus_pa
Posts: 1
Joined: Tue Dec 10, 2019 3:11 pm

neopixel ring 16 infrequent self-lighting only when wifi has been initialized once

Postby rus_pa » Tue Dec 10, 2019 3:50 pm

Hello! This is my first post for my very first arduino-ish project ever, so please don't jump at my throat if I ignore basics of some kind, especially in electronic components and circuitry matters. I do code for living but, electronics... I'm almost a total beginner.

Let's jump to my issue, which hopefully might turn out to be not so difficult to fix: I used an Expressif ESP32-DevkitC to connect to some rest api, parse some json and when the value is X then I light a neopixel ring 16 (official), when set the code to use the leds alone, they work flawlessly, if I also turn on the wifi (wifi.begin(...)) the led still work good, but a few random leds (not always the same) also seem to randomly lit themselves, rarely, from time to time and without a real consistency. In other words, some random led flicker briefly always in different color on top of working correctly.

I've read that wifi on esp32 is bound to adc2 channel and you need to use adc1 pins if you plan to use wifi, but I've noticed no difference in using one pin instead of another, whether or not it was adc1 or 2, I just got the same results. I added the resitor to the data in and the capacitor between +5 and GND, same result.

I also have a collegue here pretty experienced in arduino projects and he's baffled as well about this issue, he never used an esp32 tho.

Another curious effect is that with neopixels if you dont specify any color and only write "strip.show()" all the led should go off: well if I actually don't lit ANY pixel (imagine the line rotateColor(50) commented out in the following code block) a few leds per turn lit themself on subtly (it takes an explicit strip.show() call in the main loop to wipe them off each time). A link with a video of the effect will be after the code block. Or it will just get me banned because of some rule, we'll discover that in a moment.

I post the code in the hope someone can help me spot my newbiness and suggest some fix:

Code: Select all

#include "WiFi.h"
#include <HTTPClient.h>
#include <Adafruit_NeoPixel.h>

const char* ssid = "XXX";
const char* password = "YYY";

#define LEDRING_PIN 32
Adafruit_NeoPixel strip = Adafruit_NeoPixel(16, LEDRING_PIN, NEO_GRB + NEO_KHZ800);

void setup() {

  Serial.begin(115200);
  delay(4000);

  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }
  Serial.println("Connected to the WiFi network!");

  strip.begin();
  strip.setBrightness(25);
  strip.show();
}

void loop() {
  rotateColor(50);
}

void rotateColor(uint8_t wait) {
  for(uint16_t i=0; i<16; i++) {
 
    uint16_t prev;
    
    if (i == 0) {
      prev = 15;
    } else {
      prev = i - 1;
    }
     strip.setPixelColor(i,  strip.Color(255, 0, 0));
    strip.setPixelColor(prev, 0);
    strip.show();
    delay(wait);
  }
 }

Effect if I replace rotateColor(xx) with strip.show(). If I leave the code as is in in the example the effect is the same but with rotating colors behaving correctly ontop of the glitch (harder to notice, yet present) https://www.youtube.com/watch?v=uuuJw1-Ot9A

Who is online

Users browsing this forum: No registered users and 95 guests