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

Rtc Widget nu functioneaza

#1

Buna ziua! Stiu ca s-a mai discutat despre asta dar nu ii dau de cap. Am libraria time. h inclusa, rtc la fel, am adaugat widget-ul rtc. rtc. begin() este pus in Blynk. connected()… Dar nu vrea sa sincronizeze ceasul. Am mai facut un proiect care a mers perfect si chiar partile de program sunt luate din acela.Am asteptat si 5 minute sincronizarea dar ceasul este tot de la 0:0:0 si anul 1970. Acum nu vrea sa funcționeze. Ce problema poate fi?

0 Likes

#2

Where is your code? :thinking:

0 Likes

#3

This is my code.
I am using it with Adafruit_NeoMatrix.h to controll ws8212 leds , and I delete parts of this from the program.

#include "display.h"
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <TimeLib.h>
#include <WidgetRTC.h>

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

String inString = "";
int anim = 1; 
char auth[] = "sdfsdfsdfsdsfds";
char ssid[] = "tele2-6491";
char pass[] = "sdfsdfsdf";
char host[] = "blynk-cloud.com";
String message1;

#define PIN  D3 

void setup()
{  WiFi.begin(ssid, pass);
  Blynk.config(auth, host); 
   timer.setInterval(5000L, blynkCheck);
}

BLYNK_CONNECTED()
{
 terminal.println("BLYNK CONECTAT!");
 terminal.flush();
rtc.begin();
 }

void blynkCheck()
 {
  if (WiFi.status() == 3) {
  if (!Blynk.connected()) {
    for(x = matrix.width() + 1 ; x >= -110 ; x -- ){
      matrix.fillScreen(0);
      matrix.setTextColor(Red);
      matrix.setCursor(x, 3);
      matrix.print(F("WIFI OK Connecting"));
      matrix.show();   delay(scroll); } Blynk.connect();}}
  if (WiFi.status() == 1) {
    for(x = matrix.width() + 1 ; x >= -110 ; x -- ){
      matrix.fillScreen(0);
      matrix.setTextColor(Red);
      matrix.setCursor(x, 3);
      matrix.print(F("Offline"));
      matrix.show();   delay(scroll); }}}



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

#4

Might not matter, but put this in setup()

0 Likes

#5

Gunner, it was in setup() to… Same problem.
I thought that is to early in setup and I let Blynk to connect and after that to try to sincronize the time… But doesn’t want to function … I think I tried even the example RTC from the site and I have the same problem.

0 Likes

#6

How do you know it isn’t working? You don’t have any Serial.begin(); command to allow the Serial output and thus show the [5311] Time sync: OK as I just saw on my Serial Monitor… using your code (set for my network and minus the Neopixel stuff, and adding the Serial.begin() )

//#include "display.h"
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <TimeLib.h>
#include <WidgetRTC.h>

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

String inString = "";
int anim = 1;
char auth[] = "xxxxx";
char ssid[] = "xxxxx";
char pass[] = "xxxxx";
char server[] = "xxx.xxx.xxx.xxx";  // IP for your Local Server
int port = 8080;
String message1;

#define PIN  D3


void setup()
{
  Serial.begin(9600);
  WiFi.begin(ssid, pass);
  Blynk.config(auth, server, port);
  //timer.setInterval(5000L, blynkCheck);
}


BLYNK_CONNECTED()
{
  terminal.println("BLYNK CONECTAT!");
  terminal.flush();
  rtc.begin();
}


/*
void blynkCheck()
{
  if (WiFi.status() == 3) {
    if (!Blynk.connected()) {
      for (x = matrix.width() + 1 ; x >= -110 ; x -- ) {
        matrix.fillScreen(0);
        matrix.setTextColor(Red);
        matrix.setCursor(x, 3);
        matrix.print(F("WIFI OK Connecting"));
        matrix.show();   delay(scroll);
      } Blynk.connect();
    }
  }
  if (WiFi.status() == 1) {
    for (x = matrix.width() + 1 ; x >= -110 ; x -- ) {
      matrix.fillScreen(0);
      matrix.setTextColor(Red);
      matrix.setCursor(x, 3);
      matrix.print(F("Offline"));
      matrix.show();   delay(scroll);
    }
  }
}
*/


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

}

image

0 Likes

#7

Guess what ! I just powered the circuit with the same code as last night and is working ok now ! :roll_eyes:
The Serial.begin() was there but maby I delete it by mistake when I post it here. In serial monitor it was like this

[16918] Connecting to blynk-cloud.com:80
[17077] Ready (ping: 59ms).
0:0:17
0:0:19
0:0:21  

But "Time sync:OK " was not showing… 15 minutes ago I powered the circuit again and when I opened the serial monitor :

[16918] Connecting to blynk-cloud.com:80
[17077] Ready (ping: 59ms).
0:0:17
[18614] Time sync: OK
10:15:27
10:15:28
10:15:30
10:15:31
10:15:33
10:15:34

So Is working ok today. I know that I was doing it ok last night, because I copied the code from my first working project…

0 Likes