Managing Daylight Saving Time with ArduinoCloud (IoT)

Hello everyone, I am currently developing an IoT application with an MKR WiFi 1010 board, in which I want to manage certain tasks based on the local time. When establishing the connection to "Arduino IoT Cloud," the board's RTC is updated with the local time retrieved from the network. However, this time corresponds to UTC and not UTC+1 (French local time in winter). Could you enlighten me on how to automatically update my RTC with the correct time (summer or winter)? Either by correcting it directly at the connection or afterwards. The functions for connecting to Arduino Cloud are as follows:
C++
ArduinoCloud.begin(ArduinoIoTPreferredConnection); // Connect to Arduino IoT Cloud
setDebugMessageLevel(4); // by default the value is 2
ArduinoCloud.printDebugInfo();
C++
ArduinoCloud.begin(ArduinoIoTPreferredConnection); // Connect to Arduino IoT Cloud
setDebugMessageLevel(4); // by default the value is 2
ArduinoCloud.printDebugInfo();
The corresponding traces obtained on the serial link are: Arduino IoT Cloud - configuration info Device ID: (MASKED) MQTT Broker: mqtts-sa.iot.arduino.cc:8883 WiFi.status(): 3 Current WiFi Firmware: 1.5.0 Connected to "SSID" (MASKED) TimeServiceClass::sync Drift: -7 RTC value: 1699189163 Connected to Arduino IoT Cloud Thing ID: (MASKED) TimeServiceClass::setTimeZoneData offset: 3600 dst_until 1711846800
1 Reply
Saßì
Saßì12mo ago
It seems like you're facing an issue with time synchronization on your MKR WiFi 1010 board when connecting to Arduino IoT Cloud. To adjust the RTC to your local time, you can follow these steps: After connecting to Arduino IoT Cloud, retrieve the current UTC time. Determine your local time zone offset, considering daylight saving time (DST) changes if applicable. Apply the offset to the UTC time and set your RTC with the adjusted local time. Adjust the 'localTimeZoneOffset' variable according to your local time zone. Additionally, you may need to consider DST changes based on your specific location and the time of the year.
Want results from more Discord servers?
Add your server