Skip to content

Commit 2a69cce

Browse files
committed
User Manual writing commit 15
1 parent a204411 commit 2a69cce

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed
186 KB
Loading

content/hardware/05.pro-solutions/solutions-and-kits/edge-control/tutorials/user-manual/content.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,38 @@ The built-in Real Time Clock of the Edge Control is ideal for timing irrigation
10631063

10641064
***To maintain the RTC on time the included CR2032 coin cell must be used.***
10651065

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+
![RealTimeClock example output](assets/rtc-output.png)
1099+
10691100
## Communication

0 commit comments

Comments
 (0)