User Tools

Site Tools


en-us_commands:reference:irtcset

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en-us_commands:reference:irtcset [2026/09/07 21:52] – 만듦 - 바깥 편집 127.0.0.1en-us_commands:reference:irtcset [2026/09/08 00:53] (current) – 바깥 편집 127.0.0.1
Line 19: Line 19:
 void setup() { void setup() {
   Serial.begin(115200);   Serial.begin(115200);
 +  if (!IrtcBegin()) return;  // Check the DS3231 RTC connection and begin operation.
  
-  if (!IrtcBegin()) { +  bool valid = false; 
-    Serial.println(F("DS3231 connection failed")); +  if (IrtcTimeValid(valid&& !valid) {  // Check whether the RTC time is reliable. 
-    return;+    IrtcSet(2026, 9, 7, 9, 0, 0);  // Set the RTC date and time. 
 +    IrtcClearOscillatorStopFlag() // Clear the oscillator-stop flag.
   }   }
- 
-  // Run once initially, then comment out. 
-  // IrtcSet(2026, 8, 10, 14, 30, 0); 
 } }
  
 void loop() { void loop() {
   IrtcDateTime now;   IrtcDateTime now;
-  if (IrtcRead(now)) { +  uint32_t unixTime = 0; 
-    Serial.print(now.year)+  float rtcTemperature = 0.0F; 
-    Serial.print('/')+  if (IrtcRead(now) && IrtcUnixTime(unixTime&& IrtcGetTemperature(rtcTemperature)) {  // Return the RTC's internal temperature/ Return the current time as Unix time/ Read the RTC date and time
-    Serial.print(now.month)+    Serial.print(unixTime); Serial.print(','); Serial.println(rtcTemperature, 2);
-    Serial.print('/'); +
-    Serial.print(now.day); +
-    Serial.print(' '); +
-    Serial.print(now.hour); +
-    Serial.print(':'); +
-    Serial.print(now.minute); +
-    Serial.print(':'); +
-    Serial.println(now.second);+
   }   }
   delay(1000);   delay(1000);
Line 51: Line 42:
  
 Run each device's corresponding ''Begin'' command first. Check I²C addresses and pin sharing; if the ''bool'' return value is ''false'', inspect wiring and power. Run each device's corresponding ''Begin'' command first. Check I²C addresses and pin sharing; if the ''bool'' return value is ''false'', inspect wiring and power.
 +
 +===== Built-in Commands in the Same Category =====
 +
 +  * [[:en-us_commands:reference:irtcbegin|IrtcBegin() View detailed description]]
 +  * [[:en-us_commands:reference:irtcread|IrtcRead() View detailed description]]
 +  * [[:en-us_commands:reference:irtcunixtime|IrtcUnixTime() View detailed description]]
 +  * [[:en-us_commands:reference:irtcgettemperature|IrtcGetTemperature() View detailed description]]
 +  * [[:en-us_commands:reference:irtctimevalid|IrtcTimeValid() View detailed description]]
 +  * [[:en-us_commands:reference:irtcclearoscillatorstopflag|IrtcClearOscillatorStopFlag() View detailed description]]
 +  * [[:en-us_commands:reference:irtcsetalarm1|IrtcSetAlarm1() View detailed description]]
 +  * [[:en-us_commands:reference:irtcsetalarm2|IrtcSetAlarm2() View detailed description]]
 +  * [[:en-us_commands:reference:irtcalarmenable|IrtcAlarmEnable() View detailed description]]
 +  * [[:en-us_commands:reference:irtcalarmenabled|IrtcAlarmEnabled() View detailed description]]
 +  * [[:en-us_commands:reference:irtcalarmtriggered|IrtcAlarmTriggered() View detailed description]]
 +  * [[:en-us_commands:reference:irtcsquarewave|IrtcSquareWave() View detailed description]]
 +  * [[:en-us_commands:reference:irtc32khz|Irtc32kHz() View detailed description]]
  
 [[:en-us_commands:builtin|← Built-in Command List]] [[:en-us_commands:builtin|← Built-in Command List]]
  
en-us_commands/reference/irtcset.1788785568.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki