DS1302 RTC Real Time Clock Module with battery

The DS1302 trickle-charge timekeeping chip module with battery backup contains a real-time clock/calendar and 31 bytes of static RAM. It communicates with a microprocessor via a simple serial interface. The real-time clock/calendar provides seconds,minutes, hours, day, date, month, and year information.

SKU: AA122 Categories: , Tag:

EGP75.00

In stock

In stock

13 People watching this product now!
  • Pick up from the Ekostra Store

To pick up today

Free

  • Courier delivery

Our courier will deliver to the specified address

1-3 Days

50 LE

  • Free 14-Day returns

Payment Methods:

Description

DS1302 is DALLAS company launched a trickle charge clock chip, containing a real-time clock/calendar and 31 bytes of static RAM, communicating through serial interface simple and single-chip microcomputer. The real-time clock/calendar circuit provides seconds, hours, days, weeks, months, years of information, a number of days in the month and leap year can automatically adjust. The clock operation instructions through the AM/PM decided to use 24 or 12-hour format.

Between DS1302 and single-chip microcomputer can simply use synchronous serial communication method, only three lines:
(1) RST
(2) I/O reset the data line
(3) SCLK serial clock.

Clock /RAM read/write data to a byte character set or as many as 31-byte communication. DS1302 work power consumption is very low to keep the data and clock information when power is less than 1mW

Wiring method (to provide procedures, for example, can pick up any IO port, in the procedure to modify the port definitions :

VCC:+5V/3.3V
GND: GND
CLK: P02
DAT: P01
RST: P00

Note:

1.VCC and GND do not reverse, so as not to burn the chip
2.51 SCM P0 port to receive a pull-up resistor, if your computer is not connected pull-up resistor, the data can be the string to the other port.


Specifications and Features:

  1. The real-time clock counts minutes, seconds, date, hours, month day of the week, year and leap-year compensation up to 2100.
  2. 318 temporary data storage RAM
  3. Working current of 2.0V, less than 300nA
  4. Read / Write clock or RAM data with two kinds of mode of single-byte transfer mode and multi-byte character set
  5. 8 pin DIP package or optional 8 pin SOIC package based on the surface assembly
  6. Simple 3 wire interface
  7. Compatible with TTL Vcc=5V
  8. Double power supply pipe for main power and backup power supply.

Useful Links:

Arduino DS1302 Real Time Clock 
Using the Real-Time Clock module on Raspberry Pi


Package Includes:

1 x DS1302 RTC Real Time Clock Module with Battery

Specification

Overview

Input Supply Voltage (VDC)

3.3

Operating Voltage (VDC)

2V ~ 5.5

Operating Temperature (°C)

-40 to 85

Storage condition (℃)

-55 to 125

Shipping Info

Weight 9.0000 g
Dimensions 43 × 23 × 13 mm

Code

    /* 
www.ekostra.com
*/


// CONNECTIONS:
// DS1302 CLK/SCLK --> 5
// DS1302 DAT/IO --> 4
// DS1302 RST/CE --> 2
// DS1302 VCC --> 3.3v - 5v
// DS1302 GND --> GND

#include <ThreeWire.h>  
#include <RtcDS1302.h>

ThreeWire myWire(4,5,2); // IO, SCLK, CE
RtcDS1302<ThreeWire> Rtc(myWire);

void setup () 
{
    Serial.begin(9600);

    Serial.print("compiled: ");
    Serial.print(__DATE__);
    Serial.println(__TIME__);

    Rtc.Begin();

    RtcDateTime compiled = RtcDateTime(__DATE__, __TIME__);
    printDateTime(compiled);
    Serial.println();

    if (!Rtc.IsDateTimeValid()) 
    {
        // Common Causes:
        //    1) first time you ran and the device wasn't running yet
        //    2) the battery on the device is low or even missing

        Serial.println("RTC lost confidence in the DateTime!");
        Rtc.SetDateTime(compiled);
    }

    if (Rtc.GetIsWriteProtected())
    {
        Serial.println("RTC was write protected, enabling writing now");
        Rtc.SetIsWriteProtected(false);
    }

    if (!Rtc.GetIsRunning())
    {
        Serial.println("RTC was not actively running, starting now");
        Rtc.SetIsRunning(true);
    }

    RtcDateTime now = Rtc.GetDateTime();
    if (now < compiled) 
    {
        Serial.println("RTC is older than compile time!  (Updating DateTime)");
        Rtc.SetDateTime(compiled);
    }
    else if (now > compiled) 
    {
        Serial.println("RTC is newer than compile time. (this is expected)");
    }
    else if (now == compiled) 
    {
        Serial.println("RTC is the same as compile time! (not expected but all is fine)");
    }
}

void loop () 
{
    RtcDateTime now = Rtc.GetDateTime();

    printDateTime(now);
    Serial.println();

    if (!now.IsValid())
    {
        // Common Causes:
        //    1) the battery on the device is low or even missing and the power line was disconnected
        Serial.println("RTC lost confidence in the DateTime!");
    }

    delay(5000); // five seconds
}

#define countof(a) (sizeof(a) / sizeof(a[0]))

void printDateTime(const RtcDateTime& dt)
{
    char datestring[20];

    snprintf_P(datestring, 
            countof(datestring),
            PSTR("%02u/%02u/%04u %02u:%02u:%02u"),
            dt.Month(),
            dt.Day(),
            dt.Year(),
            dt.Hour(),
            dt.Minute(),
            dt.Second() );
    Serial.print(datestring);
}

 

Library Installation

Go to Library manager and install the Rtc by Makuna library.