Welcome to NTP Discussions! #18
sstaub
announced in
Announcements
Replies: 3 comments
-
|
Hello |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
can you try this code: // example for Ethernetshield 2
#include "Ethernet.h"
#include "NTP.h"
uint8_t mac[] = {0x90, 0xA2, 0xDA, 0x10, 0x14, 0x48}; // MAC Adress of your device
IPAddress ip(10, 101, 1, 201); // IP address of your device
IPAddress dns(10, 101, 1, 100); // DNS address of your device
IPAddress gateway(10, 101, 1, 100); // Gateway address of your device
IPAddress subnet(255, 255, 0, 0); // Subnet mask of your device
EthernetUDP udp;
NTP ntp(udp);
void setup() {
Serial.begin(9600);
Ethernet.begin(mac, ip, dns, gateway, subnet);
ntp.ruleDST("CEST", Last, Sun, Mar, 2, 120); // last sunday in march 2:00, timetone +120min (+1 GMT + 1h summertime offset)
ntp.ruleSTD("CET", Last, Sun, Oct, 3, 60); // last sunday in october 3:00, timezone +60min (+1 GMT)
ntp.begin();
Serial.println("start NTP");
}
void loop() {
ntp.update();
Serial.println(ntp.formattedTime("%d. %B %Y")); // dd. Mmm yyyy
Serial.println(ntp.formattedTime("%A %T")); // Www hh:mm:ss
delay(1000);
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Many thank you for the answer I will try it. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
👋 Welcome!
We’re using Discussions as a place to connect with other members of our community. We hope that you:
build together 💪.
To get started, comment below with an introduction of yourself and tell us about what you do with this community.
Beta Was this translation helpful? Give feedback.
All reactions