Long Delay for Actions

Hi,
So I have just started using Blynk and Wanted to test my ESP32 WROOM Dev Board.
I connected an LED and created a Push Button for it.

The weird thing is, it shows me that the device is connected, but it instantly disconnects again.
But I can still turn the LED On and Off, but with a 9 second delay.

I also run my local Server on a Raspberry Pi.

I thought it is a high ping, but the ping from the Board to the Server is 10ms and the Ping from the App to the Board is 100ms. Still high but its not 9 seconds.


#include <Arduino.h>

int A1A = 22;
int A1B = 23;
int B1A = 2;
int B1B = 4;
#define BLYNK_PRINT Serial


#define BLYNK_PRINT Serial


#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

char auth[] = "----";

char ssid[] = "FRITZ!Box Fon WLAN 7390";
char pass[] = "----";


const char* WIFI_SSID = "FRITZ!Box Fon WLAN 7390";
const char* WIFI_PWD = "----";


int pin = 13;

void setup() {
  //WiFi.begin(WIFI_SSID, WIFI_PWD);
  pinMode(A1A, OUTPUT);
  pinMode(A1B, OUTPUT);
  pinMode(B1A, OUTPUT);
  pinMode(B1B, OUTPUT);
  pinMode(pin, OUTPUT);
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass, IPAddress(192,168,178,53), 8080);


}

void loop() {
  Blynk.run();
  digitalWrite(A1A,255);
  digitalWrite(A1B, LOW);
  delay(5000);
  digitalWrite(A1A, LOW);
  digitalWrite(A1B, 255);
  delay(5000);
}

Get rid of the delays in void loop and see what happens then.

And also look into BlynkTimer.

2 Likes

Just so that you fully understand what’s happening here…
The void loop should run hundreds if not thousands of times per second. Your two 5 second delays mean that the loop can only run once every 10 seconds at best.
As Blynk isn’t getting its regular dose of processor time, because it’s only having Blynk.run execute once every 10 seconds, the server is probably disconnecting the device (your serial output will confirm this). It’s then it’s having to re-connect and that’s when it’s executing the LED change of state.

Pete.

Wow lol,
I somehow totally forgot the other code xD

I promise I’m not bad at code xD I have just totally overseen it xD

Okay it can be maked as solved now

Thanks for you answer

2 Likes