2015年1月26日 星期一

DS1307 RTC I²C使用方式

DS1307是RTC的便宜方案之ㄧ。圖片來源



買到的DS1307是I²C介面,接線方式參考EastBay CodeHaus

需要加入 DS1307 library,安裝好 library後,由 FilesExamples→RTClib-master→ds1307載入sketch,由 ToolsSerial Monitor可以查看時間。



adafruit的說明中提到,RTC中如未設定時間,ds1307sketch會自動帶入電腦的系統時間。
程式碼為
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));



2015年1月24日 星期六

DS1302 RTC測試

購買的DS1302 RTC(Real Time Clock)


http://playground.arduino.cc/Main/DS1302可以找到DS1302 RTC的資料及程式碼。


  • 提到要注意的是DS1302比較便宜,DS3231比較精準。
  • 沒有日光節約時間。
  • 沒有strftime(), timelocal(), getdate(), mktime()
  • 2012年,Arduino沒提供官方date 、time 的 library()(Arduino1.0.6有Time.h、DS1307RTC.h測試DS1302也可以)



我買到跟playground.arduino.cc接腳不一樣
主要接腳幾設定

VCC--->5V
GND--->GND
CLK--->Pin6
DAT--->Pin7
RST --->Pin8 (RST即CE)

使用Arduino1.0.6>Examples>Time>TineRTC,直接上傳,Tools>Serial Monitor

程式碼每秒於serial port 列印現在時間


測試成功。