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

ESP8266 ArduinoOTA and widgetRTC compile error

Hi friends. I have a problem with compiling my sketch. the problem is when I add widgetRTC to my sketch the arduino IDE showing error. how can I fix this problem

here my sketch:

//Master Controller for Bosch and Siemens
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <WidgetRTC.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>

char auth[] = "QRZQrO4sxt7cIbIGR-_GVgbRY-wOoUjb";
char ssid[] = "MikroTik Tesla";
char pass[] = "12345678";
char server[] = "10.5.51.5";
char hostOTA[] = "Master";

char currentTime[9];
char startTime[9];
char stopTime[9];
int SThour;
int STmin;
int STsec;
int SPhour;
int SPmin;
int SPsec;

int tempmicakhar;
int hummicakhar;
int premicakhar;
int pirmicakhar;

const int Relay = 14;

WidgetBridge bridge1(V100);
WidgetBridge bridge2(V101);

BlynkTimer timer;

WidgetRTC rtc;

void setup()
{
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass, server, 8080);
  ArduinoOTA.setHostname(hostOTA);
  ArduinoOTA.begin();
  rtc.begin();
  pinMode(Relay, OUTPUT);
  setSyncInterval(360);
  timer.setInterval(30000L, TimeCheck);  // Update Time Check every 30 seconds
}

BLYNK_CONNECTED()
{
  bridge2.setAuthToken("TWyLDt5xgR57gTPCQB0vt7yZjNnke9Tl");
}

BLYNK_CONNECTED() {
  Blynk.syncVirtual(V98);
  TimeCheck();
}

BLYNK_WRITE(V98) {
  TimeInputParam t(param);
  SThour = t.getStartHour();
  STmin = t.getStartMinute();
  STsec = t.getStartSecond();
  SPhour = t.getStopHour();
  SPmin = t.getStopMinute();
  SPsec = t.getStopSecond();
}

BLYNK_WRITE(V99)
{
  int pinValue = param.asInt();
  if (pinValue == 1)
  {
    digitalWrite(Relay, HIGH);
    bridge2.virtualWrite(V0, 1);
  }
  else if (pinValue == 0)
  {
    digitalWrite(Relay, LOW);
    bridge2.virtualWrite(V0, 0);
  }
}

BLYNK_WRITE(V1)
{
  tempmicakhar = param.asInt();
}

BLYNK_WRITE(V2)
{
  hummicakhar = param.asInt();
}

BLYNK_WRITE(V3)
{
  premicakhar = param.asInt();
}

BLYNK_WRITE(V4)
{
  pirmicakhar = param.asInt();
}

void TimeCheck() {  // call with timer every 30 seconds or so
  // Get RTC time
  sprintf(currentTime, "%02d:%02d:%02d", hour(), minute(), second());
  Serial.print("Current Time: ");
  Serial.println(currentTime);

  // Get Time Input Widget time
  sprintf(startTime, "%02d:%02d:%02d", SThour, STmin, STsec);
  Serial.print("Start Time: ");
  Serial.println(startTime);

  sprintf(startTime, "%02d:%02d:%02d", SPhour, SPmin, SPsec);
  Serial.print("Stop Time: ");
  Serial.println(startTime);

  if (hour() == SThour) {
    if (minute() == STmin) {
      Serial.println("Doing something now");
      digitalWrite(Relay, HIGH); // Turn ON built-in LED
    } else if (minute() < STmin) {
      Serial.println("Will do something");
    } else if (minute() > STmin) {
      Serial.println("Did something");
    } else {
      Serial.println("Clueless");
    }
  }

  if (hour() == SPhour) {
    if (minute() == SPmin) {
      Serial.println("Stopping something now");
      digitalWrite(Relay, LOW); // Turn OFF built-in LED
    } else if (minute() < SPmin) {
      Serial.println("Will stop something");
    } else if (minute() > SPmin) {
      Serial.println("Stopped something");
    } else {
      Serial.println("Clueless");
    }
  }
  Serial.println("----------");
}

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

and the error:

Multiple libraries were found for "ArduinoOTA.h"
 Used: C:\Users\STRIX\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\ArduinoOTA
 Not used: C:\Users\STRIX\Documents\Arduino\libraries\ArduinoOTA
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

thanks.

Your code compiles fine for me (well, it does once I fixed the fact that you have two BLYNK_CONNECTED() callbacks, so I moved your Bridge2 command into the other one and deleted the first).

I’m using ESP Core 2.6.3 whereas you are using 2.5.2 and as the OTA functionality is part of the ESP Core I guess that’s your problem.

Pete.

2 Likes

thanks @PeteKnight the problem solved by removing the extera BLYNK_CONNECTED() :rose: