BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Blynk with Arduino UNO + Etherner Shield reconnect every 5 Sec

I use Arduino UNO + Etherner Shield W5100 with this code.

#define BLYNK_PRINT Serial

#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include "DHT.h"
#include "ThingSpeak.h"

#define DHTPIN 6    
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

unsigned long myChannelNumber = xxxxxxxxxxx;
const char * myWriteAPIKey = "xxxxxxxxxxxxxxx";
char auth[] = "xxxxxxxxxxx";
BlynkTimer timer; // Announcing the timer

EthernetClient client;

void sensorToBlynk()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  Blynk.virtualWrite(V0, t);
  Blynk.virtualWrite(V1, h);


  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(t);
  Serial.print(" *C ");
  Serial.println();

}

void sensorToThingspeak()
{
   float h = dht.readHumidity();
   float t = dht.readTemperature();

   ThingSpeak.setField(1, t);
   ThingSpeak.setField(2, h);
 
    // write to the ThingSpeak channel
    int x = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
    if(x == 200){
      Serial.println("Channel update successful.");
    }
    else{
      Serial.println("Problem updating channel. HTTP error code " + String(x));
    }
}

void setup()
{
 
  Serial.begin(115200);
  dht.begin();
 
  Blynk.begin(auth, "xxxxxxxx.com", 8080);
  timer.setInterval(3000L, sensorToBlynk); //timer will run every sec
  timer.setInterval(600000L, sensorToThingspeak);
}

void loop()
{
  Blynk.run();
  timer.run();
}

It show output like this.

[538932] Connecting to xxxxxxxx.com:8080
[539091] Ready (ping: 2ms).
Humidity: 57.00 % Temperature: 26.10 *C
Humidity: 57.00 % Temperature: 26.10 *C
Humidity: 57.00 % Temperature: 26.10 *C
Humidity: 57.00 % Temperature: 26.10 *C
Humidity: 57.00 % Temperature: 26.10 *C
Humidity: 57.00 % Temperature: 26.10 *C
[557164] Connecting to xxxxxxxx.com:8080
Humidity: 57.00 % Temperature: 26.10 *C
Humidity: 57.00 % Temperature: 26.10 *C
[562165] Connecting to :8080
[562225] Ready (ping: 2ms).

It’s reconnect every 5 second ? How to fix it ?

You’re using a local server, but it appears to be located outside of your network. Can you explain more about this setup?

Pete.