[SOLVED] Blynk response very slow when I send command, but receive quicly

Hi Blynk,

I have a problem with my project.

When I push button I have a delay(30s-60s), but if I receive a signal from the arduino module very quickly.

The ping is 35ms.

Last week everything works fine, but from 2 days I have a big delay.

Please find below my sketch.

#define BLYNK_PRINT Serial // Enables Serial Monitor
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h> // This part is for Ethernet stuff
#include <OneWire.h>

// OneWire DS18S20, DS18B20, DS1822 Temperature Example
// http://www.pjrc.com/teensy/td_libs_OneWire.html
// The DallasTemperature library can do all this work for you!
// http://milesburton.com/Dallas_Temperature_Control_Library

OneWire  ds(7);  // on pin 7 (a 4.7K resistor is necessary) make sure you change this from the original pin 10 to an unused pin.
int adr;
float s1;
float s2;
float s3;
//float s4;
//float s5;
//float s6;
//float s7;

//char auth[] = "3485ef82b0634333baab62d231fb7702"; // Put your Auth Token here. (see Step 3 above)
char auth[] = "af2fb508623146c5a1df8e961b76d38b";

//int RELAY1 = D8;
//int RELAY2 = D9;

void setup()
  Serial.begin(9600); // See the connection status in Serial Monitor
  Blynk.begin(auth);  // Here your Arduino connects to the Blynk Cloud.
  // definesc pinii pentru controlul releelor
//primul set de pini ptr placa A de relee   
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(22, OUTPUT);
// al doilea set de pini ptr placa B de relee
  pinMode(23, OUTPUT);
  pinMode(24, OUTPUT);
  pinMode(25, OUTPUT);
  pinMode(26, OUTPUT);
  pinMode(27, OUTPUT);
  pinMode(28, OUTPUT);
  pinMode(29, OUTPUT);
  pinMode(30, OUTPUT);
  // initializez releele pe ON de pe placa A

// initializez primii 6 pini de pe placa B pe ON
 // initializez pinii 27 - 30 pe OFF    
// initializez LED-ul martor al motorului exhaust pe OFF pe virtual V1

void loop()
  Blynk.run(); // All the Blynk Magic happens here...

  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
    byte i;
  byte present = 0;
  byte type_s;
  byte data[12];
  byte addr[8];
  float celsius, fahrenheit;
  if ( !ds.search(addr)) {
    Serial.println("Nu mai sunt senzori.");
//  Serial.print("ROM =");
  for( i = 0; i < 8; i++) {           //we need to drop 8 bytes of data
  adr = (addr[7]);

  if (OneWire::crc8(addr, 7) != addr[7]) {
      Serial.println("CRC is not valid!");
  ds.write(0x44, 1);        // start conversion, with parasite power on at the end
  delay(1000);     // maybe 750ms is enough, maybe not
  // we might do a ds.depower() here, but the reset will take care of it.
  present = ds.reset();
  ds.write(0xBE);         // Read Scratchpad

  for ( i = 0; i < 9; i++) {           // we need 9 bytes to drop off
    data[i] = ds.read();

  // Convert the data to actual temperature
  // because the result is a 16 bit signed integer, it should
  // be stored to an "int16_t" type, which is always 16 bits
  // even when compiled on a 32 bit processor.
  int16_t raw = (data[1] << 8) | data[0];
  if (type_s) {
    raw = raw << 3; // 9 bit resolution default
    if (data[7] == 0x10) {
      // "count remain" gives full 12 bit resolution
      raw = (raw & 0xFFF0) + 12 - data[6];
  } else {
    byte cfg = (data[4] & 0x60);
    // at lower res, the low bits are undefined, so let's zero them
    if (cfg == 0x00) raw = raw & ~7;  // 9 bit resolution, 93.75 ms
    else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
    else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
    //// default is 12 bit resolution, 750 ms conversion time
  celsius = (float)raw / 16.0;
  fahrenheit = celsius * 1.8 + 32.0;
  if(adr == 173)  {         //replace ??? with value of sensor number 1    
    s1 = celsius;           //change celsius to fahrenheit if you prefer output in Fahrenheit

  if(adr == 129)  {         //replace ??? with value of sensor number 2
    s2 = celsius;           //change celsius to fahrenheit if you prefer output in Fahrenheit

  if(adr == 51)  {         //replace ??? with value of sensor number 3
    s3 = celsius;           //change celsius to fahrenheit if you prefer output in Fahrenheit
Serial.print(" Sensor 1 = ");
Serial.print(" Sensor 2 = ");
Serial.print(" Sensor 3 = ");//adauga sau sterge in functie de cat este nevoie
//Serial.print(" Releul 1 = ");

  Blynk.virtualWrite(V5, s1);
  Blynk.virtualWrite(V6, s2);
  Blynk.virtualWrite(V7, s3);//adauga sau sterge in functie de cat este nevoie

 //de aici ma joc cu temperaturile
  if (s1 > 30) {
    Blynk.virtualWrite(V1, 255);

    Blynk.virtualWrite(V1, 0);

Remove all delay()'s and replace with BlynkTimers would be the first thing I’d try.
The loop() should be at most 2 lines.


All other functions should be contained and run behind timers.

You can help with this example?

It is my first project and i want a good example for the future projects.


BlynkTimer Mytimer; // Sets up a timer object named Mytimer (could be any name)

Mytimer.setInterval(1000L, MyFunction);  // Goes in Setup() and will call the void MyFunction() every 1000 milis (one second - adjust to your needs).  Blynk Timer allows up to 16 of these same object named timers pointing to differing functions

void MyFunction() 
// Mytimer runs stuff here every 1000 millis (one second)

void loop()
Mytimer.run();  // Goes in the void loop() so the BlynkTimer library can run.

Thank you,

I’ll try tomorrow and I’ll tell you.


I made the changes as you suggested.

Everything is ok now.

I have one more question?

If I have a push button in the application, and press this button for 2 seconds, the relay attached to the arduino board, connects 3-4 seconds or just 1 second.

Do you know why this is happening?