commands:reference:irtcunixtime
IrtcUnixTime()
명령어
| 명령어 | 인수 | 반환값 | 동작 |
|---|---|---|---|
IrtcUnixTime(unixTime) | uint32_t& unixTime | bool | 현재 시간을 Unix 시간으로 반환합니다. |
예제
void setup() { Serial.begin(115200); if (!IrtcBegin()) return; // DS3231 RTC 연결을 확인하고 사용을 시작합니다. bool valid = false; if (IrtcTimeValid(valid) && !valid) { // RTC 시간이 신뢰 가능한 상태인지 확인합니다. IrtcSet(2026, 9, 7, 9, 0, 0); // RTC의 날짜와 시간을 설정합니다. IrtcClearOscillatorStopFlag(); // 발진 정지 상태 표시를 초기화합니다. } } void loop() { IrtcDateTime now; uint32_t unixTime = 0; float rtcTemperature = 0.0F; if (IrtcRead(now) && IrtcUnixTime(unixTime) && IrtcGetTemperature(rtcTemperature)) { // RTC 내부 온도를 반환합니다. / 현재 시간을 Unix 시간으로 반환합니다. / RTC의 날짜와 시간을 읽습니다. Serial.print(unixTime); Serial.print(','); Serial.println(rtcTemperature, 2); } delay(1000); }
주의사항
각 장치는 해당 Begin 명령어를 먼저 실행하십시오. I²C 주소와 핀 공유 여부를 확인하고, bool 반환값이 false이면 배선과 전원을 점검하십시오.
같은 카테고리의 내장 명령어
commands/reference/irtcunixtime.txt · 마지막으로 수정됨: 저자 127.0.0.1
