The DS1307 is a real-time clock IC by Maxim Integrated that keeps track of:
Seconds
Minutes
Hours (12 or 24-hour mode)
Day, Date, Month, Year
Automatically adjusts for leap years
β It communicates with microcontrollers using SPI (Serial Peripheral Interface) — unlike the more common DS1307, which uses I2C.
| Feature | Details |
|---|---|
| Interface | SPI |
| Voltage | 2.0V – 5.5V |
| Timekeeping | Seconds, Minutes, Hours, Day, Date |
| Battery backup | Yes (CR1220 or CR2032 coin cell) |
| Oscillator | Requires external 32.768 kHz crystal |
| Alarm + Square Wave | Built-in (configurable) |
| Component | Description |
|---|---|
| ESP32 board | Microcontroller |
| DS1306 RTC module | With CR2032 battery and SPI pins |
| Jumper wires | Male-to-female preferred |
| Breadboard | For clean prototyping |
| Arduino IDE | To program ESP32 |
| DS1306 Pin | ESP32 Pin | Description |
|---|---|---|
| VCC | 3.3V or 5V | Power supply |
| GND | GND | Ground |
| SCLK | GPIO 18 | SPI Clock |
| MISO | GPIO 19 | SPI MISO (Data In) |
| MOSI | GPIO 23 | SPI MOSI (Data Out) |
| CS | GPIO 5 | SPI Chip Select |
Make sure you connect the battery for backup timekeeping.
Since DS1306 uses SPI, and isn’t as widely supported as DS3231 or DS1307, we’ll use the DS1306 library (by Paul Stoffregen or compatible fork).
Go to Sketch > Include Library > Manage Libraries
Search for and install:
DS1306RTC (if not found, you may need to manually add)
You may also use RTClib but it doesn’t directly support DS1306.
If you're using this RTC for standard timekeeping, you might find DS1307 or DS3231 (I2C-based) much easier and better supported in Arduino.
If you're bound to DS1306, I can help you:
Add a working library
Write custom SPI functions to read/set time
Convert to RTClib-compatible class
| Application | Description |
|---|---|
| β° Digital Clock | Show real-world time & date |
| π Data Logging | Timestamp for sensor readings |
| π Power Saving | Wake up ESP32 at a set time |
| π¦ IoT Projects | Sync events to time-based triggers |
| π· Camera Trap | Time-stamp wildlife photos/videos |
| Feature | DS1306 | DS1307 | DS3231 (Recommended) |
|---|---|---|---|
| Protocol | SPI | I2C | I2C |
| Accuracy | Medium | Low | β Very High (±2ppm) |
| Battery Back | Yes | Yes | Yes |
| Code Support | Limited | Excellent | β Excellent |