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
- The module leads to the TX&RX pins, you could set the information via this port.
Usage steps
- Open Raspberry Pi I2C interface
command: sudo raspi-config
- Select "Advanced Options"
- Select "I2C"
- Select "YES"
- add the module
command: sudo vim.tiny /etc/modules
- Add "i2c-dev" device
- Install I2C tools
command: sudo apt-get install i2c-tools
- 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
- Input "sudo su--" to get "root"; input "modprobe i2c-dev" to load I2C device.
command: sudo su
command1: modprobe i2c-dev
- load to Raspberry Pi system I2C device.
command: echo "ds1307 0x68" \>/sys/class/i2c-adapter/i2c-1/new_device
- 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

Was this article helpful?
