You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/hardware/05.pro-solutions/solutions-and-kits/edge-control/tutorials/user-manual/content.md
+34-3Lines changed: 34 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1063,7 +1063,38 @@ The built-in Real Time Clock of the Edge Control is ideal for timing irrigation
1063
1063
1064
1064
***To maintain the RTC on time the included CR2032 coin cell must be used.***
1065
1065
1066
-
`getRTDateTime(); // 2023-09-30 16:33:19 `
1067
-
`getRTCTime(); // 16:33:19`
1068
-
`getRTCDate(); // 2023-09-30`
1066
+
An example code to test the RTC functionality can be found on **File > Examples > Arduino_EdgeControl > Basic > RealTimeClock**
1067
+
1068
+
In the example code, there is a .h file called Helpers that includes very useful and easy-to-use functions for parsing the time on different formats.
1069
+
1070
+
Initially, you must set the current time as a reference for the RTC. This is made just once and can be done using the function setEpoch([Current Unix Time](https://www.unixtimestamp.com/)):
1071
+
1072
+
1073
+
```cpp
1074
+
RealTimeClock.setEpoch(Unix Time); // You can use the timestamp generated on https://www.unixtimestamp.com/. Be aware that the time found on the webpage is UTC.
1075
+
```
1076
+
1077
+
The `time(NULL)` function returns the Unix time (seconds since Jan 1st 1970), this is perfect for cloud and servers data logging.
1078
+
1079
+
```cpp
1080
+
getRTDateTime(); // 2023-09-30 16:33:19
1081
+
getRTCTime(); // 16:33:19
1082
+
getRTCDate(); // 2023-09-30
1083
+
```
1084
+
1085
+
Also, you can use these more specific functions to retrieve the time in a custom way:
1086
+
1087
+
```cpp
1088
+
RealTimeClock.getYears(); //return the current year
1089
+
RealTimeClock.getMonths(); //return the current month
1090
+
RealTimeClock.getDays(); //return the current day
1091
+
RealTimeClock.getHours(); //return the current hours
1092
+
RealTimeClock.getMinutes(); //return the current minutes
1093
+
RealTimeClock.getSeconds(); //return the current seconds
1094
+
```
1095
+
1096
+
To test the example code, press the Edge Control Enclosure Kit button to set the time once with the code build date. (The button should be pressed while the code is being upload or while a hard reset).
1097
+
1098
+

0 commit comments