You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I modified the Preprocessor code to add the libraries it needed for Wired Ethernet.
This is for the ETH.h in the arduino-esp32 core.
First of all let me just say I know enough to be dangerous. I'm past beginner just a little with C++ coding with the Arduino Libraries.
I only modified the ezTime.h and ezTime.cpp and those are the only files in the attached zip file.
You can compare these to the original ones and see what I changed. If you are using VS Code and PlatformIO you can just replace the files in the libdeps folder for ezTime if installed or load it and then make the changes.
If you have your code setup like this example, ETH_LAN8720 from arduino-esp32 Ethernet examples then all you need to do is add
#include <ezTime.h>
#define NTP_POLLING 3600 // NTP polling interval in seconds (3600 = 1 hour)
// For ezTime before setup()
Timezone myTZ; // or your way of doing this.
In the Event for ARDUINO_EVENT_ETH_GOT_IP
I put this at the end of what was already there.
// Wait for ezTime to get its time synchronized
Serial.println("Waiting for time sync...");
//setDebug(INFO);
if(!waitForSync(30)){
Serial.println("Time out getting time from NTP Server.");
}
// Provide official timezone names
// https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
myTZ.setLocation(("America/Chicago"));
Serial.print(F("Date Time: "));
Serial.println(myTZ.dateTime());
// Set NTP polling interval to 6 hours.
setInterval(NTP_POLLING);
This is what my serial output looks like though I took a few things out that were not needed.
I modified the Preprocessor code to add the libraries it needed for Wired Ethernet.
This is for the ETH.h in the arduino-esp32 core.
First of all let me just say I know enough to be dangerous. I'm past beginner just a little with C++ coding with the Arduino Libraries.
I only modified the ezTime.h and ezTime.cpp and those are the only files in the attached zip file.
You can compare these to the original ones and see what I changed. If you are using VS Code and PlatformIO you can just replace the files in the libdeps folder for ezTime if installed or load it and then make the changes.
If you have your code setup like this example, ETH_LAN8720 from arduino-esp32 Ethernet examples then all you need to do is add
#include <ezTime.h>
#define NTP_POLLING 3600 // NTP polling interval in seconds (3600 = 1 hour)
// For ezTime before setup()
Timezone myTZ; // or your way of doing this.
In the Event for ARDUINO_EVENT_ETH_GOT_IP
I put this at the end of what was already there.
This is what my serial output looks like though I took a few things out that were not needed.
Ethernet MAC: FF:FF:EE:EE:DD:DD
IPv4: 192.168.15.103
Gateway: 192.168.15.1
DNS: 192.168.15.1
, FULL_DUPLEX, 100Mbps
Waiting for time sync...
IPv4: 192.168.15.103
Temp *F = 81.81 Hum. % = 34.84
Date Time: Wednesday, 19-Apr-2023 13:32:46 CDT
Temp *F = 81.84 Hum. % = 35.45
I can't provide support for this so use at your own risk.
Thanks,
Jeffery
ezTime.zip
The text was updated successfully, but these errors were encountered: