GithubHelp home page GithubHelp logo

Comments (5)

beta-tank avatar beta-tank commented on August 22, 2024

Hi, thanks for your project. I am new here and I’d like to know about the benefits of using the NTPClient library.
I use the default implementation from sntp.h and there are no problems.
Initialization can be done like this:

 configTime(7 * 3600, 0, "time.google.com");

or you can manually call all init functions:

sntp_stop();
sntp_setserver(0, "time.google.com");
sntp_set_timezone(7);
sntp_init();

Then you should wait for the time initialization to happen. I make it in the setup function in a synchronous way (because my functionality needs the actual time), but it can be made in the loop in an async way with a callback.
Here is my implementation, fairly straightforward:

time_t getTime(){
  #ifdef ESP8266
    return sntp_get_current_timestamp();
  #endif
  #ifdef ESP32
    time_t now = 0;
    return time(&now);
  #endif
}
int last = 0;
  while(getTime() < 1500000000){
    if((millis () - last) > 1000){
        last = millis ();
        Serial.println(getTime());
        Serial.println("Waiting for sntp.");
    }
    yield();
  }

from esp8266-react.

rjwats avatar rjwats commented on August 22, 2024

from esp8266-react.

beta-tank avatar beta-tank commented on August 22, 2024

Thanks for the explanation. I'll try to use NTPClient library in my project to simplify the migration to your react framework.

from esp8266-react.

proddy avatar proddy commented on August 22, 2024

SNTP is now native in the ESP8266 and ESP32 arduino core. See #47 (comment). After the PR has been merged you can close this

from esp8266-react.

rjwats avatar rjwats commented on August 22, 2024

Won't do - sntp support now implemented

from esp8266-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.