diff --git a/content/arduino-cloud/01.getting-started/02.technical-reference/iot-cloud-tech-ref.md b/content/arduino-cloud/01.getting-started/02.technical-reference/iot-cloud-tech-ref.md index c760af3b53..40f4de9fa9 100644 --- a/content/arduino-cloud/01.getting-started/02.technical-reference/iot-cloud-tech-ref.md +++ b/content/arduino-cloud/01.getting-started/02.technical-reference/iot-cloud-tech-ref.md @@ -131,6 +131,19 @@ This feature allows Arduino devices to communicate with each other by sharing va Using this feature you can link variables of the same data type between **two or more cloud-enabled devices**, and Arduino IoT Cloud will automatically ensure any change to their value is propagated among all linked boards. For example, one button could set three smart bulbs to the same color by just setting a variable on one device and reading it on the others. Or you could turn on a heater when temperature sensors in your room or outside in your weather station drop below a certain level. +### Local Time + +To retrieve local time, use the `ArduinoCloud.getLocalTime()` method in your sketch. The value returned represents the current local time expressed as a Unix timestamp (i.e. seconds from the epoch), and it automatically takes your time zone settings and DST (Daylight Saving Time) into account. Time zone can be set in the Thing configuration page within the Arduino IoT Cloud platform. + +The returned timestamp can be displayed in a dashboard using a `CloudTime` variable and the [Time Picker widget](/arduino-cloud/getting-started/technical-reference#time-picker), or can be parsed with a third-party library such as [Time](https://www.arduino.cc/reference/en/libraries/time/) in case you want to show it on a display. + +```arduino +myTimeVariable = ArduinoCloud.getLocalTime() +``` + +***Note that when using a board equipped with a hardware Real-Time Clock (RTC) the [Arduino_IoTCloud](https://github.com/arduino-libraries/ArduinoIoTCloud) library will use it automatically, thus communicating with the RTC from within your sketch or other libraries is not recommended. You can use the `getLocalTime()` and `getInternalTime()` methods provided by Arduino_IoTCloud instead. +*** + ## Things In order to use your devices in IoT Cloud, you need to associate a Thing to each of them. A Thing is an abstract concept which holds the configuration of the variables and other settings, as well as the history of the data collected for the variables. @@ -153,7 +166,7 @@ The steps below can be used as guidance when **setting up a Thing**: ## Variables -***Visit the main article on [Cloud Variables](arduino-cloud/getting-started/cloud-variables) for a more detailed coverage.*** +***Visit the main article on [Cloud Variables](/arduino-cloud/getting-started/cloud-variables) for a more detailed coverage.*** A thing can have one or more variables. A variable can be used for multiple purposes: diff --git a/content/arduino-cloud/01.getting-started/06.dashboard-widgets/assets/time-picker.png b/content/arduino-cloud/01.getting-started/06.dashboard-widgets/assets/time-picker.png new file mode 100644 index 0000000000..74d379bc94 Binary files /dev/null and b/content/arduino-cloud/01.getting-started/06.dashboard-widgets/assets/time-picker.png differ diff --git a/content/arduino-cloud/01.getting-started/06.dashboard-widgets/dashboard-widgets.md b/content/arduino-cloud/01.getting-started/06.dashboard-widgets/dashboard-widgets.md index 196a1d09e8..d99be1644d 100644 --- a/content/arduino-cloud/01.getting-started/06.dashboard-widgets/dashboard-widgets.md +++ b/content/arduino-cloud/01.getting-started/06.dashboard-widgets/dashboard-widgets.md @@ -126,6 +126,22 @@ else if(stepperVariable == 11){ Serial.println(stepperVariable); ``` +### Time Picker + +![Time Picker Widget](assets/time-picker.png) + +The time picker widget is used to represent and set a time and/or a date. + +Can be linked with a **CloudTime** variable. + +An example of how it is used in a sketch: + +``` +CloudTimeVariable = ArduinoCloud.getLocalTime(); +``` + +In this example, the variable named `CloudTimeVariable` is populated with `ArduinoCloud.getLocalTime()` which returns the Unix time stamp (in seconds) of the local time zone. + ### Messenger ![Messenger Widget](assets/widget-messenger.png)