Categories

I2C RTC DS1307 AT24C32 Real Time Clock For Arduino and Raspberry Pi

I2C RTC DS1307 AT24C32 Real Time Clock For Arduino and Raspberry Pi
Brand: Giga
Product Code: I2CRTCDS1307AT24C32
Availability: 8
Price: R49.00
Ex Tax: R49.00
Qty:     - OR -   Add to Wish List
Add to Compare

I2C RTC DS1307 AT24C32 Real Time Clock For Arduino Raspberry Pi

What it is:
The DS1307 RTC is a chip that keeps time. It keeps track of the hour, minute, second, day, month, and year. It runs off of it's own battery, so even if the alarm clock is not plugged in, the RTC will keep the current time. The lithium ion battery included with the DS1307 board should last a couple years.

 

Arduino Tiny I2C RTC DS1307 AT24C32 Real Time Clock module+board for AVR ARM PIC

Description

  • I2C interface
  • DS1307 based RTC with LIR2032 battery (Battery included)
  • Backup by AT24C32 32Kbit
  • DS1307,AT24C32 can work singleness
  • Dimention: 28x25x8.4mm
  • Weight:6.3g(include Battery)

How to hook it up:
Solder wires to Gnd, Vcc, Sda, and Scl. Gnd should connect to ground, Vcc should connect to the Arduino's built in 5V supply, Sda should connect to A4 (analog pin 4), and Scl should connect to A5 (analog pin 5).

Programming the RTC:
You need to run a program to set the time on the RTC to initialize it. I used the DS1307RTC library and the Time library to program my DS1307.

Arduino DS1307RTC library can be found at:

http://www.pjrc.com/teensy/arduino_libraries/DS1307RTC.zip

In the DS1307RTC library examples folder there should be a program called "SetTime". Run this program to set the time of your RTC to the current time on your computer. You can then run the ReadTest example to make sure that the time was set.

Basic Usage

RTC.get();
Reads the current date & time as a 32 bit "time_t" number. Zero is returned if the DS1307 is not running or does not respond.
RTC.set(t);
Sets the date & time, using a 32 bit "time_t" number. Returns true for success, or false if any error occurs.
RTC.read(tm);
Read the current date & time as TimeElements variable. See the Time library for TimeElements details. Returns true on success, or false if the time could not be read.
RTC.write(tm);
Sets the date & time, using a TimeElements variable. Returns true for
RTC.chipPresent();
Returns true if a DS1307 compatible chip was present after using the 4 functions. If an error occurs, this can be used to distinguish between a DS1307 that is not running vs no chip connected at all.
Example Program

DS1307RTC includes 2 examples, to read or set the time.
You can open this example from File > Examples > DS1307RTC > ReadTest.

#include <DS1307RTC.h>
#include <Time.h>
#include <Wire.h>

void setup() {
  Serial.begin(9600);
  while (!Serial) ; // wait for serial
  delay(200);
  Serial.println("DS1307RTC Read Test");
  Serial.println("-------------------");
}

void loop() {
  tmElements_t tm;

  if (RTC.read(tm)) {
    Serial.print("Ok, Time = ");
    print2digits(tm.Hour);
    Serial.write(':');
    print2digits(tm.Minute);
    Serial.write(':');
    print2digits(tm.Second);
    Serial.print(", Date (D/M/Y) = ");
    Serial.print(tm.Day);
    Serial.write('/');
    Serial.print(tm.Month);
    Serial.write('/');
    Serial.print(tmYearToCalendar(tm.Year));
    Serial.println();
  } else {
    if (RTC.chipPresent()) {
      Serial.println("The DS1307 is stopped.  Please run the SetTime");
      Serial.println("example to initialize the time and begin running.");
      Serial.println();
    } else {
      Serial.println("DS1307 read error!  Please check the circuitry.");
      Serial.println();
    }
    delay(9000);
  }
  delay(1000);
}

void print2digits(int number) {
  if (number >= 0 && number < 10) {
    Serial.write('0');
  }
  Serial.print(number);
}

Write a review

Your Name:


Your Review: Note: HTML is not translated!

Rating: Bad           Good

Enter the code in the box below:



Powered By OpenCart
Giga Technology © 2024