Hi All...
I'm trying to sync the RTC module (adafruit ds3231) with an arduinoMKR1010WiFi...
all is good except that I get the time of Two hours ago!
the only workarround I've found is to set the time mannualy adding two hours to the current time but I would like to know if it could be donne
I assume the RTClib looks at the web editor's current time, so this could be a reason for this span or maybe a local time seasonal difference, I think it should be adjusted to the local time of the browser....?
any clues or ideas?
how can I add Two hours to the web editor's time ?
Many thanks in advance for any help
Ale.
here is the code I use to setup the time to the sketch's compilation time,
got from RTClib example
// Date and time functions using a DS3231 RTC connected via I2C and Wire lib
#include "RTClib.h"
RTC_DS3231 rtc;
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
void setup () {
Serial.begin(57600);
#ifndef ESP8266
while (!Serial); // wait for serial port to connect. Needed for native USB
#endif
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
Serial.flush();
while (1) delay(10);
}
if (rtc.lostPower()) {
Serial.println("RTC lost power, let's set the time!");
// When time needs to be set on a new device, or after a power loss, the
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); **//compile time setup**
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2022, 9, 19, 10, 23, 0)); **//manual time setup**
}
// When time needs to be re-set on a previously configured device, the
// following line sets the RTC to the date & time this sketch was compiled
// rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); **//compile time setup**
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
rtc.adjust(DateTime(2022, 9, 21, 10, 17, 0)); **//manual time setup**
}
NO, it shows the time two hours in the past.
is the timezone of the compiler "web-editor side" ,as I thought, but shouldn't it look at the browsers time?
how should I make it adjust to the correct timezone time ?
Thanks in advance
Ale
two hours from GMT - it looks suspiciously similar to the timezone of the Italy where arduino headquarters are situated
Perhaps it is default setting somewhere in the web-editor
many thanks for your answer... and
yes it's my first suspect, as per my original post:
but how should I make the compiler take the compute-rside "local time"
I've llooked a way to add two hours to (F(_ TIME _)) but i think it whould be better to have a non hardcoded TIME but a "look for real data" sentence.
Thanks again
@gfvalvo
thats a good workarround.... i think I can use the Arduino IDE to setup the time to the RTCmodule and then the web editor for my application.
Good idea!
and additionaly I'll look at my arduino maker Account to see if the timezone is configurable
Many thanks
As far I know the timezone of France is GMT+2
So if you got from the code a time that two hours in the past (as you said in post #4) from your local time - it's means that the code outputs exact GMT time.
This is pretty reasonable for a network system that knows nothing about what zone its clients are in
It seems that the your web-editor doesn't have timezone settings correctly installed.
just It's easier when programing from differents places ( home, office, etc) and up to date online libraries, but I dont know if they're good reasons anyway
@b707
browser parameters are ok
and there is no option in the web editor, or at least I can't find it..
I'll continue looking to see if I can find anything