DziveQ
December 9, 2020, 8:39pm
1
Hi. I’m using Blynk 2-3 months, and I always have problem with it. Every each time I use the blynk app, and i do something, the app says “Your led_strip went offline” (I’ve the notify when hardware goes offline thing on). I’m using ZERGBA, and if i just change the color, the blynk disconnect. I can see that esp are doing something, and changing the color of the led strip, but not whole, sometimes 200, sometimes 250 leds. This is very very enoying and i want to fix it.
If you need more details, just let me know. thanks in advance.
#include <Adafruit_NeoPixel.h>
#include <SPI.h>
#include <BlynkSimpleEsp8266.h>
#include <ESP8266WiFi.h>
#define PIN D7
#define PIN2 D6
#define NUMPIXELS 276
#define NUMPIXELS2 275
#define BLYNK_PRINT Serial
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pixels2 = Adafruit_NeoPixel(NUMPIXELS2, PIN2, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(9600);
Blynk.begin("Token", "SSID", "Passwrd");
pixels.begin();
pixels2.begin();
WiFi.setSleepMode(WIFI_NONE_SLEEP);
pinMode(D5, OUTPUT);
}
BLYNK_WRITE(V1) {
rainbow(10);
}
BLYNK_WRITE(V2) {
int R = param[0].asInt();
int G = param[1].asInt();
int B = param[2].asInt();
Serial.println(R);
Serial.println(G);
Serial.println(B);
for(int i=0;i<NUMPIXELS;i++){
pixels.setPixelColor(i, pixels.Color(R,G,B));
pixels.show();
}
}
BLYNK_WRITE(V3) {
int brightness = param[0].asInt();
Serial.println(brightness);
for(int i=0;i<NUMPIXELS;i++){
pixels.setBrightness(brightness);
pixels.show();
}
}
BLYNK_WRITE(V4) {
int R2 = param[0].asInt();
int G2 = param[1].asInt();
int B2 = param[2].asInt();
Serial.println(R2);
Serial.println(G2);
Serial.println(B2);
for(int i=0;i<NUMPIXELS;i++){
pixels2.setPixelColor(i, pixels2.Color(R2,G2,B2));
pixels2.show();
}
}
BLYNK_WRITE(V5) {
int brightness2 = param[0].asInt();
Serial.println(brightness2);
for(int i=0;i<NUMPIXELS;i++){
pixels2.setBrightness(brightness2);
pixels2.show();
}
}
void rainbow(int wait) {
for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) {
for(int i=0; i<pixels.numPixels(); i++) {
int pixelHue = firstPixelHue + (i * 65536L / pixels.numPixels());
pixels.setPixelColor(i, pixels.gamma32(pixels.ColorHSV(pixelHue)));
}
pixels.show();
delay(wait);
}
}
void loop() {
Blynk.run();
}
I think your for
loops are raking too long to execute, and this is causing your disconnections, because the Blynk.run()
command in your void loop isn’t getting processed while these loops are being executed.
I’d recommend adding Blynk.run();
commands within your for
loops to solve this.
Pete.
DziveQ
December 9, 2020, 10:43pm
3
PeteKnight:
Blynk.run();
Ok, so I added Blynk.run(); to both for, and it work better, but not perfectly. It is still disconnecting sometimes but less then before.
DziveQ
December 10, 2020, 2:53pm
5
Sure
#include <Adafruit_NeoPixel.h>
#include <SPI.h>
#include <BlynkSimpleEsp8266.h>
#include <ESP8266WiFi.h>
#define PIN D7
#define PIN2 D6
#define NUMPIXELS 276
#define NUMPIXELS2 275
#define BLYNK_PRINT Serial
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pixels2 = Adafruit_NeoPixel(NUMPIXELS2, PIN2, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(9600);
Blynk.begin("xxx", "x", "xxx");
pixels.begin();
pixels2.begin();
WiFi.setSleepMode(WIFI_NONE_SLEEP);
pinMode(D5, OUTPUT);
}
BLYNK_WRITE(V1) {
rainbow(10);
}
BLYNK_WRITE(V2) {
int R = param[0].asInt();
int G = param[1].asInt();
int B = param[2].asInt();
Serial.println(R);
Serial.println(G);
Serial.println(B);
for(int i=0;i<NUMPIXELS;i++){
pixels.setPixelColor(i, pixels.Color(R,G,B));
pixels.show();
}
}
BLYNK_WRITE(V3) {
int brightness = param[0].asInt();
Serial.println(brightness);
for(int i=0;i<NUMPIXELS;i++){
pixels.setBrightness(brightness);
pixels.show();
Blynk.run();
}
}
BLYNK_WRITE(V4) {
int R2 = param[0].asInt();
int G2 = param[1].asInt();
int B2 = param[2].asInt();
Serial.println(R2);
Serial.println(G2);
Serial.println(B2);
for(int i=0;i<NUMPIXELS;i++){
pixels2.setPixelColor(i, pixels2.Color(R2,G2,B2));
pixels2.show();
Blynk.run();
}
}
BLYNK_WRITE(V5) {
int brightness2 = param[0].asInt();
Serial.println(brightness2);
for(int i=0;i<NUMPIXELS;i++){
pixels2.setBrightness(brightness2);
pixels2.show();
}
}
void rainbow(int wait) {
for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) {
for(int i=0; i<pixels.numPixels(); i++) {
int pixelHue = firstPixelHue + (i * 65536L / pixels.numPixels());
pixels.setPixelColor(i, pixels.gamma32(pixels.ColorHSV(pixelHue)));
}
pixels.show();
delay(wait);
}
}
void loop() {
Blynk.run();
}
So is it your V1 button that’s causing the problem, or all of them?
Pete.
Change your serial monitor baud rate to 74880 and see what your serial monitor shows when the device goes offline.
I’m thinking that maybe your device is restarting when it goes offline, and if it is then I’d like to see what the crash dump days.
Pete.