User Tutorial

Last revision 2026/01/07

This tutorial provides a comprehensive guide on setting up and using the DS1307 RTC module with a Raspberry Pi 4B, covering hardware and software preparation, wiring, and enabling I2C interface for optimal performance.

Hardware Preparation

Software Preparation

  • Raspberry Pi OS

Wiring Diagram

  • Connect the module to your Pi
DFR0386 DS1307 RTC Module with Battery for Raspberry Pi (Compatible with Raspberry Pi 4B) Connection DFR0386 DS1307 RTC Module with Battery for Raspberry Pi (Compatible with Raspberry Pi 4B) Connection
  • The module leads to the TX&RX pins, you could set the information via this port.
DFR0386 DS1307 RTC Module with Battery for Raspberry Pi (Compatible with Raspberry Pi 4B) Connection DFR0386 DS1307 RTC Module with Battery for Raspberry Pi (Compatible with Raspberry Pi 4B) Connection

Usage steps

  • Open Raspberry Pi I2C interface

command: sudo raspi-config

DFR0386 DS1307 RTC Module with Battery for Raspberry Pi (Compatible with Raspberry Pi 4B) Test
  • Select "Advanced Options"
DFR0386 DS1307 RTC Module with Battery for Raspberry Pi (Compatible with Raspberry Pi 4B) Test
  • Select "I2C"
DFR0386 DS1307 RTC Module with Battery for Raspberry Pi (Compatible with Raspberry Pi 4B) Test
  • Select "YES"
DFR0386 DS1307 RTC Module with Battery for Raspberry Pi (Compatible with Raspberry Pi 4B) Test
  • add the module

command: sudo vim.tiny /etc/modules

DFR0386 DS1307 RTC Module with Battery for Raspberry Pi (Compatible with Raspberry Pi 4B) Test
  • Add "i2c-dev" device
DFR0386 DS1307 RTC Module with Battery for Raspberry Pi (Compatible with Raspberry Pi 4B) Test
  • Install I2C tools

command: sudo apt-get install i2c-tools

DFR0386 DS1307 RTC Module with Battery for Raspberry Pi (Compatible with Raspberry Pi 4B) Test
  • Input "sudo reboot" to reboot Raspberry Pi; Input "sudo i2cdetect-y1" after a reboot. If everything goes well, the module will be detected normally.

command: sudo reboot
command1: sudo i2cdetect-y 1

DFR0386 DS1307 RTC Module with Battery for Raspberry Pi (Compatible with Raspberry Pi 4B) Test
  • Input "sudo su--" to get "root"; input "modprobe i2c-dev" to load I2C device.

command: sudo su
command1: modprobe i2c-dev

DFR0386 DS1307 RTC Module with Battery for Raspberry Pi (Compatible with Raspberry Pi 4B) Test
  • load to Raspberry Pi system I2C device.

command: echo "ds1307 0x68" \>/sys/class/i2c-adapter/i2c-1/new_device

DFR0386 DS1307 RTC Module with Battery for Raspberry Pi (Compatible with Raspberry Pi 4B) Test
  • Now you can use "hwclock" command to use this module, refer to "man hwclock" for more details.

command: sudo hwclock -r Get RTC module time
command1: sudo hwclock -w Set system time

DFR0386 DS1307 RTC Module with Battery for Raspberry Pi (Compatible with Raspberry Pi 4B) Test

Was this article helpful?

TOP