30 lines
709 B
Plaintext
30 lines
709 B
Plaintext
#include <ESPMegaPRO.h>
|
|
#include <ETH.h>
|
|
|
|
uint8_t utc_offset = 7;
|
|
|
|
IPAddress IP(192, 168, 0, 241);
|
|
IPAddress SUBNET(255, 255, 255, 0);
|
|
IPAddress GATEWAY(192, 168, 0, 1);
|
|
IPAddress DNS(10, 192, 1, 1);
|
|
|
|
void setup()
|
|
{
|
|
ESPMega_begin();
|
|
Serial.begin(115200);
|
|
ETH.begin();
|
|
ETH.config(IP, GATEWAY, SUBNET, DNS, DNS);
|
|
delay(5000);
|
|
char ntp[19];
|
|
DNS.toString().toCharArray(ntp, 19);
|
|
ESPMega_configNTP(utc_offset * 3600, 0, ntp);
|
|
ESPMega_updateTimeFromNTP();
|
|
//ESPMega_setTime(0,10,52,9,11,2008);
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
rtctime_t time = ESPMega_getTime();
|
|
Serial.printf("RTC: %02d:%02d:%02d %02d/%02d/%04d\n", time.hours, time.minutes, time.seconds, time.day, time.month, time.year);
|
|
delay(1000);
|
|
} |