Why do I get kicked from Blynk server?

Hi guys,
Have problems to progam a sketch, where a led fade automatically up and down, but where I can adjust the time with a slider, in which it does it. Below my sketch and the error I get in Serial Monitor, when I change timer interval. I don´t know why, but when I try to adjust the “speed” appear the error and I get kicked from Blynk server? It´s possible that it interrelate with the power supply (read something on web) but it would be strange, because until now I never had any problems with the power supply from my PC

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
BlynkTimer timerSzene;
WidgetLED ledV101 (V101);
char auth[] = "3cfd6fa8eada49b08478d9b9062ba312";
char ssid[] = "Fritzbox3272";
char pass[] = "67033709486218110510";

int timerID_Szene = 0;
int LedPinD1 = D1;
int Control_Szene = 0;
int varButtonV2 = 0;          
int OutputValue_Szene = 0;
int SzeneSteps = 5;
void loop()
{
  Blynk.run();
  timerSzene.run();
}

void setup() {
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  pinMode (LedPinD1, OUTPUT);
  timerID_Szene = timerSzene.setInterval(1000L, Func_Mode_Szene);             
}
BLYNK_WRITE(V26)
{
  Control_Szene = param.asInt();                                                         
  if (varButtonV2 == 1) {
    timerSzene.deleteTimer(timerID_Szene);
    timerID_Szene = timerSzene.setInterval(1L / Control_Szene, Func_Mode_Szene);
  }
}
BLYNK_WRITE(V2)
{
  int ButtonV2 = param.asInt();
  if (ButtonV2 == 1) {
    timerSzene.enable(timerID_Szene);
  }
  if (ButtonV2 == 0) {
    timerSzene.disable(timerID_Szene);
  }
}


void Func_Mode_Szene() {
  ledV101.setValue(OutputValue_Szene);
  analogWrite(LedPinD1, OutputValue_Szene);
  if (varButtonV2 == 1) {
    static int SzeneValue = 0;
    SzeneValue = SzeneValue + SzeneSteps;
    if (SzeneValue > 255 || SzeneValue < 0) {
      SzeneSteps = -SzeneSteps;
    } else {
      OutputValue_Szene = SzeneValue;
    }
    Serial.print("SzeneValue = ");
    Serial.println(SzeneValue);
  }
}
[11326] Connecting to blynk-cloud.com:80
[11468] Ready (ping: 73ms).
SzeneValue = 5
SzeneValue = 10
SzeneValue = 15

Exception (0):
epc1=0x4000e25d epc2=0x00000000 epc3=0x4020db34 excvaddr=0x00000000 depc=0x00000000

ctx: cont 
sp: 3fff0410 end: 3fff0620 offset: 01a0

>>>stack>>>
3fff05b0:  00000000 3ffef2b8 3ffef294 40204509  
3fff05c0:  00004ad2 00000000 00004ad2 00000000  
3fff05d0:  00000001 00000002 3ffef538 3ffef5f8  
3fff05e0:  000018b4 00000000 3ffef294 3ffef5f8  
3fff05f0:  3fffdad0 00000000 3ffef5f0 40203369  
3fff0600:  3fffdad0 00000000 3ffef5f0 40204d58  
3fff0610:  feefeffe feefeffe 3ffef600 40100710  
<<<stack<<<
⸮!⸮⸮?)

Not sure your intent here, but dividing 1ms with whatever value you are getting from your widget is probably ending up with some very small numbers and strange calculations… this is probably your ESP crashing due to bad math, not a Blynk Server issue.

1 Like
Exception (0): ...

indicates “IllegalInstructionCause”. Possibly division by zero in this case.
“1L / Control_Szene” will most likely also not result to a Long but a Float value and the timer expects Long.

In addition to all above (true): BlynkTimer has a resolution of 1ms (as it is millis() based) so you are trying to split the atom here - possible, but not with tools provided :smile:

1 Like

Okay… I understand. I made it so (short calls of the loop), because want to get a "lowing fade up and down). Wan’t avoid to see the single steps :smile:
Thank you… and I wondered why it works, when slider was at 1 and by 2, I got kicked :see_no_evil::see_no_evil:

Ups, there someone have overlooked the part of the resolution in timer-description​:see_no_evil::see_no_evil:
Now it’s clear why it didn’t work
Thanks :ok_hand:

1 Like