RTC widget reset to UNIX start time

Hello Blynkers,

Im trying to get the RTC widget working, but everytime i reset my ESP the RTC widget resets the time to 00:00.

this is the function i call every 10 seconds:

void getTime() {
  Serial.println("timeIn");
  int Vhour = hour();
  int Vminute = minute();

  char Vtime[10];
  
  sprintf(Vtime, "%02d:%02d", Vhour, Vminute);
  Serial.println(Vtime);
  
//  BLYNK_LOG("%02d:%02d", hour(), minute());
}

I want to print the incoming time with Serial.println so my arduino can handle it without the blynk log codes.

I updated the blynk lib to 0.3.5 -beta.

i connected the RTC widget to V1:
BLYNK_ATTACH_WIDGET(rtc, V1);

But i cannot link the in app RTC widget to anything, there is only a delete option.

Any good solutions? :slight_smile:
Many thanks!

Bas Peter

With the details you have provided we don’t know if you have all the code for the RTC widget i.e. do you have rtc.begin() in setup()?

I don’t understand “But i cannot link the in app RTC widget to anything, there is only a delete option” as prior to this you say you connected it to V1. Please explain further including details of Smartphone OS (Android or the other one).

For 0.3.4 (not 0.3.5 beta) on Android the RTC has pin assignment available.

Maybe you have everything set up ok because we have noticed that RTC is now very unreliable. Less than 50% of our requests for time are ignored, similar with sync feature. Don’t know if it is an app change, server location change or library change.

Thanks for the reply!
this is my code :slight_smile:

#include <Time.h>
#include <TimeLib.h>
#include <SimpleTimer.h>

#include <stdio.h> // for function sprintf

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <WidgetRTC.h>

char auth[] = "xxxxxxxxxxxxx";

WidgetRTC rtc;
WidgetTerminal terminal(V0);
SimpleTimer timer;

BLYNK_ATTACH_WIDGET(rtc, V1);

void getTime() {
  Serial.println("timeIn");
  int Vhour = hour();
  int Vminute = minute();

  char Vtime[10];
  
  sprintf(Vtime, "%02d:%02d", Vhour, Vminute);
  Serial.println(Vtime);
  
//  BLYNK_LOG("%02d:%02d", hour(), minute());
}

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, "xxxxxx", "xxxxxxxxxx");

  while (Blynk.connect() == false) {
    // Wait until connected
  }

  rtc.begin();
  timer.setInterval(10000L, getTime);

  // This will print Blynk Software version to the Terminal Widget when
  // your hardware gets connected to Blynk Server
  terminal.println(F("Blynk v" BLYNK_VERSION ": Device started"));
  terminal.println("-------------");
  terminal.flush();
}

BLYNK_WRITE(V0)
{
  terminal.print("echo: ");
  terminal.write(param.getBuffer(), param.getLength());
  terminal.println("");
  Serial.println(param.asStr());
  terminal.flush();
}

BLYNK_WRITE(V2)
{
  int R = param[0].asInt() >> 3;
  int G = param[1].asInt() >> 2;
  int B = param[2].asInt() >> 3;

  Serial.println("colorRGB");

  long RGB = (R << 11) | (G << 5) | B;
  Serial.println(RGB);
}


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

The sketch is uploaded to an ESP8266-12, using an iPhone 6 ios 9.3

when i try to connect the RTC widget on my iPhone to any pin (like i would do with for example a button) there is no option for this. The RTC example states:

19  * App project setup: 
20  *   RTC widget on V5 

So i assumed you had to connect the widget in the app to a virtual pin.

I hope this is all the information you need!

Thanks

@BasPeter You do connect to a pin. @Dmitriy looks like RTC is broken on iOs and working poorly on Android.

@BasPeter @Costas yes. missing pin selection for RTC is iOS bug.

Could you please describe your case in separate topic?