Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ezTime for ESP32 Wired Ethernet on Olimex ESP32-POE-ISO Working #167

Open
jaseiffert opened this issue Apr 19, 2023 · 0 comments
Open

ezTime for ESP32 Wired Ethernet on Olimex ESP32-POE-ISO Working #167

jaseiffert opened this issue Apr 19, 2023 · 0 comments

Comments

@jaseiffert
Copy link

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.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant