Download esp32/level1/RTC_module_basic/src/main_esp.cpp from eunzee/PCEval: direct link, hf CLI and curl.
- Browser
- Download file 926 Bytes
-
https://huggingface.co/datasets/eunzee/PCEval/resolve/main/esp32/level1/RTC_module_basic/src/main_esp.cpp
- Command line
-
hf download hf://datasets/eunzee/PCEval/esp32/level1/RTC_module_basic/src/main_esp.cpp
-
curl -L -o main_esp.cpp https://huggingface.co/datasets/eunzee/PCEval/resolve/main/esp32/level1/RTC_module_basic/src/main_esp.cpp
926 Bytes
| /** | |
| Get the current time using an RTC sensor | |
| 10 APR 2025 by Blind Author | |
| */ | |
| RTC_DS1307 rtc; | |
| char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; | |
| void setup () { | |
| Serial.begin(115200); | |
| if (!rtc.begin()) { | |
| Serial.println("Couldn't find RTC"); | |
| Serial.flush(); | |
| abort(); | |
| } | |
| DateTime now = rtc.now(); | |
| Serial.print("Current time: "); | |
| Serial.print(now.year(), DEC); | |
| Serial.print('/'); | |
| Serial.print(now.month(), DEC); | |
| Serial.print('/'); | |
| Serial.print(now.day(), DEC); | |
| Serial.print(" ("); | |
| Serial.print(daysOfTheWeek[now.dayOfTheWeek()]); | |
| Serial.print(") "); | |
| Serial.print(now.hour(), DEC); | |
| Serial.print(':'); | |
| Serial.print(now.minute(), DEC); | |
| Serial.print(':'); | |
| Serial.print(now.second(), DEC); | |
| Serial.println(); | |
| } | |
| void loop () { | |
| } | |