Thanks to visit codestin.com
Credit goes to lib.rs

#rtc #driver #clock #time #ds1307

no-std ds1307-rtc

A no_std driver for the DS1307 Real Time Clock (RTC) module

5 releases

Uses new Rust 2024

0.2.3 Sep 9, 2025
0.2.2 Sep 5, 2025
0.2.1 Sep 2, 2025
0.2.0 Sep 1, 2025
0.1.0 Aug 31, 2025

#524 in Embedded development

Codestin Search App Codestin Search App

207 downloads per month

MIT license

94KB
2K SLoC

DS1307 RTC Driver

A Rust driver for the DS1307 Real-Time Clock (RTC) chip, implementing the embedded-hal and rtc-hal traits for integration with embedded Rust projects.

Features

  • Read and set date/time
  • Control power (start/stop the clock)
  • Use 56 bytes of memory storage
  • Generate square wave signals
  • Control output pin

Basic usage

use ds1307_rtc::Ds1307;
use rtc_hal::rtc::Rtc;  // rtc_hal trait required to be imported to be used
use rtc_hal::datetime::DateTime;

// Set up I2C (depends on your board)
let i2c = /* your I2C setup */;

// Create the driver
let mut rtc = Ds1307::new(i2c);

// Set time to August 21, 2025 at 2:30 PM
let time = DateTime::new(2025, 8, 21, 14, 30, 0).unwrap();
rtc.set_datetime(&time).unwrap();

// Read current time
let now = rtc.get_datetime().unwrap();

Examples

Example projects are available in the separate ds1307-examples repository to help you get started.

License

This project is licensed under the MIT License.

Dependencies

~240KB