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

Blynk server and EthernetServer server?

Hi friends. is it possible to using blynk server and EthernetServer server; in sketch ?
I write a sketch but compiling error. the error is: conflicting declaration ‘EthernetServer server’
any idea to fix ?

#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <Wire.h>
#include <DFRobot_SHT20.h>
#include <NewEEPROM.h>
#include <NetEEPROM.h>
#include <EthernetReset.h>

char auth[] = "5K4ffJVQB2DkhL8VWp3eawe4bRScy8Vr";
char server[] = "172.16.20.254";

#define W5100_CS 10
#define pirPin 2

EthernetReset reset(8080);
EthernetServer server(80);

BlynkTimer timer;

DFRobot_SHT20 sht20;

int x;
int alarm;
int slider;

BLYNK_WRITE(V7)
{
  alarm = param.asInt();
}

BLYNK_WRITE(V8)
{
  slider = param.asInt();
}

void setup()
{
  reset.begin();
  Blynk.begin(auth, server, 8080);
  sht20.initSHT20();
  pinMode(pirPin, INPUT);
  delay(100);
  sht20.checkSHT20();
  timer.setInterval(2000L, TH);
  timer.setInterval(2000L, te);
  timer.setInterval(30 * 1000, reconnectBlynk);
}

void TH()
{
  float humd = sht20.readHumidity();
  Blynk.virtualWrite(V1, humd);

  float temp = sht20.readTemperature();
  Blynk.virtualWrite(V2, temp);
}

void te()
{
  if (alarm == 1 && sht20.readTemperature() >= slider ) {
    Blynk.notify("room high temp");
  }
}

void reconnectBlynk() {
  if (!Blynk.connected()) {

    Serial.println("Lost connection");
    if (Blynk.connect()) {
      Serial.println("Reconnected");
    }
    else {
      Serial.println("Not reconnected");
    }
  }
}

void loop() {
  reset.check();
  timer.run();
  if (Blynk.connected()) {
    Blynk.run();
  }
}

thanks

Because you declare server twice.

Change your code to

...
char blynk_server[] = "172.16.20.254";
...
Blynk.begin(auth, blynk_server, 8080);

You also can change in EthernetReset.h from

#define ETHERNETRESET_DEBUG 0
#ifdef ETHERNETRESET_DEBUG > 0
	#define DBG(c) c
#else
	#define DBG(c)
#endif

to

#define ETHERNETRESET_DEBUG 0
#if(ETHERNETRESET_DEBUG > 0)
	#define DBG(c) c
#else
	#define DBG(c)
#endif

to avoid compiler complaint.

1 Like

thanks for reply.

this solution working like a charm :heart_eyes:

```
...
char blynk_server[] = "172.16.20.254";
...
Blynk.begin(auth, blynk_server, 8080);
```
1 Like