RTC and irrigation controller blynk 2.0

Hello, I am new to the forum.

I want to develop an irrigation controller with the new version 2.0 of blynk.

For the irrigation controller I need to obtain the day of the week and the current time from the server and compare it with the data entered in the input time. But I have some doubts about how to do it with version 2.0 that I cannot solve with the documentation.

I have read in the forum that the rtc widget functions are still available (weekday(), hour(), …)



Is it necessary to include the following line?

WidgetRTC rtc;

When I do I get a compilation error.

error: 'WidgetRTC' does not name a type

And is it necessary to include the following line?

#include <WidgetRTC.h>

fatal error: TimeLib.h: No such file or directory

I don’t know if I’m in the right line of work.

Thank you!!


If you want to use the Time library then you have to install it via the Arduino IDE.


Thank you for answering so quickly!!!

In the forum they say that the rtc widget is still available. It includes functions that allow you to work with dates and times in a much more friendly way. But I can’t get it to work.

Working with the time in unix format seems a bit complicated to me.

It’s not, and it’d not needed anyway. You get the current server time in the way described in the link I provided.

That’s where the Time library makes like easier.


Thank you!!!

Now I understand everything much better.

I was analyzing the code of the WidgetRTC library and I took some things.

An approach could be this:

// Fill-in information from your Blynk Template here
#define BLYNK_TEMPLATE_ID "**"
#define BLYNK_DEVICE_NAME "**"

#define BLYNK_FIRMWARE_VERSION        "0.1.0"

#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG

#define APP_DEBUG

// Uncomment your board, or configure a custom board in Settings.h
//#define USE_WEMOS_D1_MINI

#include "BlynkEdgent.h"
#include <TimeLib.h>

// Variables
int start_time;       // Hora de inicio programada (en segundos)
int active_duration;  // Duración de la activación (en segundos)
int weekdays[8];      // Días de la semana programada (Array de 8: el 0 no se usa)

// Objeto Timer
BlynkTimer timer;

  Blynk.sendInternal("rtc", "sync"); // Solicita la hora local para el dispositivo

 * Realiza comprobaciones cada 60s
void checkTime() {
  Blynk.sendInternal("rtc", "sync"); // Actualiza la hora con el servidor

 * Obtiene los datos del time input y los almacena en variables
void setTime(BlynkParam param) {

  TimeInputParam t(param);

  if (t.hasStartTime()) {
    Serial.println(String("Hora de inicio: ") +
                   t.getStartHour() + ":" +
                   t.getStartMinute() + ":" +

  if (t.hasStopTime()) {
    Serial.println(String("Hora de finalización: ") +
                   t.getStopHour() + ":" +
                   t.getStopMinute() + ":" +

  // Recorre todos los días de la semana (1 Lunes, 2 Martes, 3 Miércoles, etc.)
  for (int i = 1; i <= 7; i++) {
    if (t.isWeekdaySelected(i)) {
      Serial.println(String("Day ") + i + " is selected");

// Time input 1 (V2)

void setup() {

  timer.setInterval(10000L, checkTime);

void loop() {

// Comprueba el valor de InternalPinRTC cuando se sincroniza con Blynk
  const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013
  unsigned long blynkTime = param.asLong();

  // Compruebe que el número entero sea una hora válida (mayor que el 1 de enero de 2013)
  if (blynkTime >= DEFAULT_TIME) {

    // Sincronizar el reloj de la biblioteca TimeLib con el valor recibido de Blynk

    Serial.println(String("Hora actual: ") + hour() + ":" + minute() + ":" + second());
    Serial.println(String("Día de la semana: ") + weekday());