Its a lot of code so I've pasted what I believe to be the relevant bits here. The sketch has been working fine but this morning I discovered it has not changed from BST to GMT (yes I'm in the UK)
as it should have done. Grateful for any suggestions.
#include "time.h"
...
// *** for ntp ***
const char* ntpServer = "pool.ntp.org";
const long gmtOffset_sec = 0;
const int daylightOffset_sec = 3600;
struct tm timeinfo;
...
initWiFi();
delay(200);
...
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer); // Init and get the time
delay(100); //allow to get NTP time
while (!getLocalTime(&timeinfo)) {
delay(100);
}
Thanks to both of you. I've implemented those changes;
const char* ntpServer = "uk.pool.ntp.org";
..
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer); // Init and get the time
setenv("TZ","GMTGMT-1,M3.4.0/01,M10.4.0/02",1); //added V2.19 as staying on BST
My bad forgot to say I'm running the code on an ESP32. Anyway @6v6gt thanks:
no different. and
invalid conversion from 'const char*' to 'long int' [-fpermissive]
I've tried the rui santos example and it shows the same issue. Presumably because without the setenv it does not know when to change between BST &GMT
As this code is for a data logger to track the output from my solar panels, I'm thinking it might make sense just to record time as GMT all year round. They dont produce much power between midnight & 1am anyway
But - of course - I'd still like to know why its not working as is.