Comments (5)
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.
from esp8266-react.
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.
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.
Won't do - sntp support now implemented
from esp8266-react.
Related Issues (20)
- Error npm start or build Error: ...API schema. - options.allowedHosts[0] should be a non-empty string. HOT 3
- Support to show user defined build version infomation in the about screen x.x.x. Also nice to expose an api that can return this infomation. This can be handy if you want to mass update devices that meet a version criteria.
- Help me understand why "We want the device to come up in opmode=0 (WIFI_OFF)" (WiFiSettingsService.cpp)
- ESP32 light sleep mode and WiFi on/off
- websocket (WS_EVT_DATA) event from client does not update state on esp8266 only HOT 1
- Add netBIOS name
- On Mobile after clicking on menu item it does not close drawer HOT 7
- Firebase Integration HOT 1
- [Question] Add a websocket based STOMP implementation
- How to use MQTT function
- How to buy a coffee? HOT 2
- Retain flag on MQTT topic & Last will & Testament message HOT 1
- Possibility to use a JsonArray instead of JsonObject in read/update method
- Using PreactJS instead of ReactJS to reduce bundle size HOT 8
- Merging 2 websockets into a single one
- esp32 bootloop with platform=espressif32 HOT 5
- Manual Set Time not accounting for DST Properly (Fix attached) HOT 1
- web interface
- Slider Issue
- Working Platformio packages versions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp8266-react.