The Adafruit DS1307 RTC Breakout is a real-time clock (RTC) module that keeps track of the current time and date. It is based on the DS1307 RTC IC from Maxim Integrated. This component is widely used in electronics projects that require timekeeping functionality, such as data loggers, clocks, and schedulers. Its ability to maintain accurate timekeeping even when the main power is off, thanks to a backup battery, makes it a reliable choice for time-sensitive applications.
Pin Number | Name | Description |
---|---|---|
1 | GND | Ground connection |
2 | VCC | Power supply (4.5V to 5.5V) |
3 | SDA | I2C Data Line |
4 | SCL | I2C Clock Line |
5 | SQW | Square Wave/Output Driver |
6 | 32K | 32.768 kHz Output |
7 | RST | Reset (active low) |
Before using the RTC, you need to set the current time. This is typically done through an initialization routine in your Arduino sketch.
#include <Wire.h>
#include <RTClib.h>
RTC_DS1307 rtc;
void setup() {
Wire.begin();
rtc.begin();
if (!rtc.isrunning()) {
// The following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
}
void loop() {
DateTime now = rtc.now();
// Print the current date and time to the Serial Monitor
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); // Wait for 1 second before repeating the loop
}
Q: How do I replace the backup battery? A: Carefully remove the old battery and insert a new CR1220 coin cell battery.
Q: Can the DS1307 RTC operate at 3.3V? A: The DS1307 is designed to operate at 4.5V to 5.5V. For 3.3V applications, consider using a different RTC module like the DS3231 which is compatible with 3.3V logic.
Q: How do I read the temperature from the DS1307? A: The DS1307 does not have a built-in temperature sensor. If you need temperature readings, you will need to use a separate temperature sensor.
Remember to keep your documentation up-to-date with the latest information and best practices to ensure users have the most accurate and helpful guidance.