Arduino 記事本 06 : Read-Time Clock(RTC)模組
網頁筆記本-006 Arduino 記事本 06 : Read-Time Clock(RTC)模組 RTC:時鐘,可於系統端無電力供應狀態下,使用電池持續計數時間。 硬體&接線: RTC模組 Tiny RTC I2C Modules (DS1307) 使用DS1307晶片。 電池使用LIR2032(3.6V),消耗少於500nA。 電池如改用CR2032(3.0V)需拆除D1、R4、R5、R6後,並短路R6接點。 未改裝會爆電池。 VCC電壓使用5V。 二線式I2C介面(SDA、SCL)。 準確日曆至2100年 輸出:年/月/日,時:分:秒,具閏年補償。 提供4kBit EEPROM。 其它資料參考-1 接線 VCC => 5V GND => 0V SDA => SDA SCL => SCL LIB 安裝程式庫(LIB) 選擇草稿碼 => 匯入程式庫 => 管理程式庫... 尋找DS1307RTC => 安裝LIB(DS1307RTC by Michael Margolis),可以有<DS1307RTC.h> 尋找RTC => 安裝LIB(Time by Michael Margolis),可以有<TimeLib.h> Code // RTC寫入/讀出時間 #include < Time . h > #include < TimeLib . h > #include < Wire . h > #include < DS1307RTC . h > tmElements_t tmTime ; tmElements_t tmRTime ; /* tmElements_t 定義在TimeLib.h內,內容如下 * uint8_t Second; * uint8_t Minute; * uint8_t Hour; * uint8_t Wday; // day of week, sunday is day 1 * ui...




留言
張貼留言