Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use DS1307 RTC (Wokwi Compatible): Examples, Pinouts, and Specs

Image of DS1307 RTC (Wokwi Compatible)Design with DS1307 RTC (Wokwi Compatible) in Cirkit Designer

Introduction

The DS1307 RTC (Real-Time Clock) is a low-power, full binary-coded decimal (BCD) clock/calendar with 56 bytes of NV SRAM. It communicates with a microcontroller via the I2C protocol and is used to keep track of time even when the main device is powered off. The Wokwi Compatible version is designed for easy integration with the Wokwi simulation platform.

Explore Projects Built with DS1307 RTC (Wokwi Compatible)

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Arduino UNO with DS1307 RTC Controlled LED Lighting System: A project utilizing DS1307 RTC (Wokwi Compatible) in a practical application
Arduino UNO with DS1307 RTC Controlled LED Lighting System

This circuit features an Arduino UNO connected to a DS1307 Real Time Clock (RTC) module for timekeeping and a red LED with a series resistor for indication purposes. The Arduino communicates with the RTC via I2C (using A4 and A5 pins for SDA and SCL, respectively), and controls the LED connected to digital pin D8 through a 330-ohm resistor. The embedded code sets the RTC time, checks the current time, and turns the LED on or off based on the specified time condition (between 11:00 AM and 11:43 AM).

Open Project in Cirkit Designer
Image of Arduino UNO Controlled Servo with DS1307 Real-Time Clock: A project utilizing DS1307 RTC (Wokwi Compatible) in a practical application
Arduino UNO Controlled Servo with DS1307 Real-Time Clock

This circuit consists of an Arduino UNO microcontroller connected to a DS1307 Real Time Clock (RTC) module and a servo motor. The RTC module communicates with the Arduino via the I2C protocol using SDA and SCL lines, while the servo is controlled by a PWM signal from the Arduino. The circuit is designed to use the precise timekeeping of the RTC to schedule and execute movements with the servo motor.

Open Project in Cirkit Designer

Common Applications and Use Cases

Technical Specifications

Key Technical Details

Parameter Value
Operating Voltage 4.5V to 5.5V
Operating Current 1.5mA (typical)
Timekeeping Current 500nA (typical)
Interface I2C (2-wire)
Clock Accuracy ±2ppm from 0°C to +40°C
NV SRAM 56 bytes
Temperature Range -40°C to +85°C

Pin Configuration and Descriptions

Pin Name Description
1 GND Ground
2 VCC Power Supply (4.5V to 5.5V)
3 SCL Serial Clock Line (I2C)
4 SDA Serial Data Line (I2C)
5 SQW/OUT Square Wave/Output Driver (Open Drain)
6 NC No Connection
7 NC No Connection
8 VBAT Battery Backup Input (3V Lithium Cell)

Usage Instructions

How to Use the Component in a Circuit

  1. Power Supply: Connect the VCC pin to a 5V power supply and the GND pin to ground.
  2. I2C Communication: Connect the SCL pin to the I2C clock line of your microcontroller and the SDA pin to the I2C data line.
  3. Battery Backup: Connect a 3V lithium cell to the VBAT pin to maintain timekeeping when the main power is off.
  4. Optional Output: The SQW/OUT pin can be used to output a square wave or as a general-purpose output.

Important Considerations and Best Practices

Example Code for Arduino UNO

#include <Wire.h>
#include <RTClib.h>

RTC_DS1307 rtc;

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

  if (!rtc.isrunning()) {
    Serial.println("RTC is NOT running!");
    // Set the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  }
}

void loop() {
  DateTime now = rtc.now();

  Serial.print(now.year(), DEC);
  Serial.print('/');
  Serial.print(now.month(), DEC);
  Serial.print('/');
  Serial.print(now.day(), DEC);
  Serial.print(" ");
  Serial.print(now.hour(), DEC);
  Serial.print(':');
  Serial.print(now.minute(), DEC);
  Serial.print(':');
  Serial.print(now.second(), DEC);
  Serial.println();

  delay(1000);
}

Troubleshooting and FAQs

Common Issues Users Might Face

  1. RTC Not Keeping Time: Ensure the battery is properly connected to the VBAT pin.
  2. I2C Communication Failure: Check the connections and ensure pull-up resistors are in place.
  3. Incorrect Time: Verify that the RTC is initialized and set correctly.

Solutions and Tips for Troubleshooting

By following this documentation, users should be able to effectively integrate and utilize the DS1307 RTC in their projects, ensuring accurate timekeeping and reliable performance.