Hi everyone,
how can I trigger time synchronization in Arduino programming on the XIAO MG24?
I can't find any support for this in the Silicon Labs Matter stack.
As far as I know, directly accessing the data via UDP doesn't work either.
Thanks in advance for your help!
Best regards,
Hannes
Hi there,
SO . the Suggested Workaround: is Hub-to-Device Push
Until a high-level “MatterTime” library is released for Arduino, the most reliable “low-code” way to sync time is to:
- Create a Matter Attribute (like a string or integer) in your code.
- Use an automation on your Smart Home Hub (Home Assistant, Alexa, etc.) to “write” the current Unix timestamp to that attribute once a day or upon connection.
- On the XIAO MG24, use the
on_changecallback to update your local clock when that attribute is updated.
`C++// Example: Conceptual attribute update
void onTimeAttributeChange(int32_t newTimestamp) {
// Sync your internal RTC here
Serial.print("Time Synced: ");
Serial.println(newTimestamp);
}`
Are you looking for a way to get absolute UTC time for data logging, or just trying to sync multiple XIAO MG24 boards to each other?
How to use the Update for UTC Time
If you update your XIAO MG24 board package to 4.0.0, the “best practice” for UTC is now:
- Trust the Hub: The device will now more reliably receive a
SetUTCTimecommand during commissioning and reconnection. - Access the RTC: Use the updated
sl_sleeptimerlibrary (part of the new Gecko SDK integration) to read the time that Matter has synced to the hardware.
Code Snippet for v4.0.0+:
#include "sl_sleeptimer.h"
void printCurrentUTC() {
sl_sleeptimer_date_t date;
// v4.0.0 uses the updated Sleeptimer API
sl_sleeptimer_get_datetime(&date);
Serial.printf("Current UTC: %04d-%02d-%02d %02d:%02d:%02d\n",
date.year, date.month, date.day,
date.hour, date.min, date.sec);
}
Note: If your device reboots and loses time, it is likely because it hasn’t received a new sync command from the Matter controller. In Matter 1.4, you can now trigger a “Check-In” protocol to ask the hub for updates more aggressively.
Have you already updated your Board Manager to version 4.0.0, or are you still on the older 2.x/3.x branch?
HTH
GL
PJ ![]()
Arduino MG24 Matter stack lacks exposed time synchronization APIs. Matter time is controlled by the ecosystem controller, not devices. Arduino layer doesn’t expose Time Sync cluster or callbacks.
Standard UDP/NTP fails due to Thread networking limitations. Direct OpenThread UDP requires lower-level SDK access. Best workaround: use external device to provide time. Full solution requires Silicon Labs Matter SDK, not Arduino.
Hello,
Thanks for the quick replies!
I already suspected it wouldn’t work that way.
@PJ_Glasso: Thanks, but this approach doesn’t work either.
The background is that I’m using it to control a Waveshare ePaper display that shows the time, date, day of the week, and indoor and outdoor temperatures.
The goal is to use as little energy as possible so that this device can operate autonomously with a LiPo battery and a small solar cell.
That’s why I chose this chip and transmission technology.
I’m now going to try splitting the timestamp in the HA into 4 bytes and transmitting the bytes via a Matter RGB lamp, then reassembling them there.
Thanks again for your help!
Best regards,
Hannes
I’d suggest using Simplicity Studio for this development.
Start with a simple light switch to confirm current consumption is what is expected. Alternatively a Multi Sensor example with Long Idle Time might be useful.
Then add the time sync cluster to Endpoint 0 and and finally the display support (there are third party drivers for the display).
Thanks for your quick reply!
I’ll try a different approach and use a different chip that uses a different stack…
Regards,
Hannes