     unsigned long lowWord = word(packetBuffer[42], packetBuffer[43]);
     unsigned long secsSince1900 = highWord << 16 | lowWord;
 
-    const unsigned long seventyYears = 2208988800UL;
-    unsigned long epoch = secsSince1900 - seventyYears;
+    unsigned long epoch = secsSince1900 - 2208988800UL;
     setTime(epoch);
 }
 

unsigned long time_now;

// LED pins
const int redLed = 3;
const int greenLed = 5;
const int yellowLed = 6;
const int routerPin = 8;
const int resetRouterTime = 30 * 1000; // wait 30 seconds

// SD card
const int chipSelect = 4;
File logfile;

void setup() {

  String fv = WiFi.firmwareVersion();

  // attempt to connect to Wifi network:
  while (WiFi.begin(ssid, pass) != WL_CONNECTED) delay(1000);
  Udp.begin(2390);

  sendNTPpacket(timeServer); // send an NTP packet to a time server
  delay(500);
