#215 RTC I2C Brick

Overview
リアルタイムクロックを使用したBrickです。
I2Cでデータを取得できます。
接続
I2Cコネクタへ接続します。

PCF2129 Datasheet
Register
回路図

Library


ライブラリ名:「FaBo 215 RTC PCF2129」
ソースコード
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 | /**
@file rtc.ino
@brief This is an Example for the FaBo RTC I2C Brick.
http://fabo.io/215.html
Released under APACHE LICENSE, VERSION 2.0
http://www.apache.org/licenses/
@author FaBo<info@fabo.io>
*/
#include <Wire.h>
#include <FaBoRTC_PCF2129.h>
FaBoRTC_PCF2129 faboRTC;
void setup() {
Serial.begin(9600);
Serial.println();
Serial.println("RESET");
// デバイス初期化
Serial.println("Checking I2C device...");
if (faboRTC.searchDevice()) {
Serial.println("configuring FaBo RTC I2C Brick");
faboRTC.configure();
} else {
Serial.println("device not found");
while(1);
}
// 日付時刻の設定
Serial.println("set date/time");
faboRTC.setDate(2016,4,1,12,1,50);
}
void loop() {
// 日付時刻の取得
DateTime now = faboRTC.now();
// 日付時刻の表示
Serial.print("Time: ");
Serial.print(now.year());
Serial.print("/");
Serial.print(now.month());
Serial.print("/");
Serial.print(now.day());
Serial.print(" ");
Serial.print(now.hour());
Serial.print(":");
Serial.print(now.minute());
Serial.print(":");
Serial.print(now.second());
Serial.println();
delay(1000);
}
|
Parts
GitHub
- https://github.com/FaBoPlatform/FaBo/tree/master/215_rtc