DS1302 RTC Real Time Clock Module with CR2032 3V Battery
A Real Time Clock Module with battery backup using the easy to use DS1302 chip. The DS1302 chip uses a simple serial interface (see datasheet) and example code is available for Arduino, Raspberry Pi and many others.
Features
- Real-Time Clock Counts Seconds, Minutes, Hours, Date of the Month, Month, Day of the Week, and Year with Leap-Year Compensation Valid Up to 2100
- Serial I/O for Minimum Pin Count
- 2.0V to 5.5V Full Operation
- Uses Less than 300nA at 2.0V
- Single-Byte or Multiple-Byte (Burst Mode) Data Transfer for Read or Write of Clock or RAM Data
- Board Size: 44mm x 24mm
Documents
การต่อใช้งาน Arduino DS13021. ต่ออุปกรณ์ DS1302 โมดูลนาฬิกา กับ Arduino
DS1302 Module -> Arduino
VCC -> 5V
GND -> GND
CLK -> ขา4
DAT -> ขา3
RST -> ขา2
2.ดาวน์โหลด Library DS1302 โมดูลนาฬิกา ติดตั้งลง Arduino ide
3. อัพโหลดโค้ดตัวอย่างลงบอร์ด Arduino
// DS1302_Serial_Hard (C)2010 Henning Karlsen
2
// web: http://www.henningkarlsen.com/electronics
4
// A quick demo of how to use my DS1302-library to
5
// retrieve time- and date-date for you to manipulate.
7
// I assume you know how to connect the DS1302.
8
// DS1302: RST pin -> Arduino Digital 2
9
// DAT pin -> Arduino Digital 3
10
// CLK pin -> Arduino Digital 4
17
// Init a Time-data structure
22
// Set the clock to run-mode, and disable the write protection
24
rtc.writeProtect(false);
26
// Setup Serial connection
29
// The following lines can be commented out to use the values already stored in the DS1302
30
// rtc.setDOW(MONDAY); // Set Day-of-Week to FRIDAY
31
// rtc.setTime(15, 1, 0); // Set the time to 12:00:00 (24hr format)
32
// rtc.setDate(3, 6, 2019); // Set the date to August 6th, 2010
37
// Get data from the DS1302
40
// Send date over serial connection
41
Serial.print("Today is the ");
42
Serial.print(t.date, DEC);
43
Serial.print(" Day,");
44
Serial.print(rtc.getMonthStr());
45
Serial.print(" Month,");
46
Serial.print(t.year, DEC);
47
Serial.println(" year");
49
// Send Day-of-Week and time
50
Serial.print(t.hour, DEC);
51
Serial.print(" hour,");
52
Serial.print(t.min, DEC);
53
Serial.print(" minute,");
54
Serial.print(t.sec, DEC);
55
Serial.println(" second");
57
// Send a divider for readability
58
Serial.println(" - - - - - - - - - - - - - - - - - - - - -");
60
// Wait one second before repeating :)
4.ถ้าต้องการตั้งเวลาใหม่ให้เอา // หน้าบรรทัด 30 31 32 ออก