{"id":15018622,"url":"https://github.com/adafruit/adafruit_circuitpython_ds3231","last_synced_at":"2026-04-23T22:01:38.939Z","repository":{"id":45884494,"uuid":"73966112","full_name":"adafruit/Adafruit_CircuitPython_DS3231","owner":"adafruit","description":"Adafruit CircuitPython drivers for the DS3231 realtime clock.","archived":false,"fork":false,"pushed_at":"2025-01-17T18:38:48.000Z","size":613,"stargazers_count":21,"open_issues_count":2,"forks_count":20,"subscribers_count":23,"default_branch":"main","last_synced_at":"2025-04-06T11:08:20.277Z","etag":null,"topics":["circuitpython","hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adafruit.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-16T22:15:58.000Z","updated_at":"2025-03-29T12:53:13.000Z","dependencies_parsed_at":"2023-12-24T00:22:35.003Z","dependency_job_id":"ed7713aa-5f2f-41c3-a0bf-a7890d7f8d93","html_url":"https://github.com/adafruit/Adafruit_CircuitPython_DS3231","commit_stats":{"total_commits":115,"total_committers":23,"mean_commits":5.0,"dds":0.808695652173913,"last_synced_commit":"61753f32a2701f1c0348089d558ce57a74df78aa"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adafruit%2FAdafruit_CircuitPython_DS3231","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adafruit%2FAdafruit_CircuitPython_DS3231/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adafruit%2FAdafruit_CircuitPython_DS3231/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adafruit%2FAdafruit_CircuitPython_DS3231/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adafruit","download_url":"https://codeload.github.com/adafruit/Adafruit_CircuitPython_DS3231/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247471520,"owners_count":20944158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["circuitpython","hacktoberfest"],"created_at":"2024-09-24T19:52:12.029Z","updated_at":"2026-04-23T22:01:38.932Z","avatar_url":"https://github.com/adafruit.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Introduction\n=============\n\n.. image:: https://readthedocs.org/projects/adafruit-circuitpython-ds3231-x/badge/?version=latest\n    :target: https://docs.circuitpython.org/projects/ds3231/en/latest/\n    :alt: Documentation Status\n\n.. image:: https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_Bundle/main/badges/adafruit_discord.svg\n    :target: https://adafru.it/discord\n    :alt: Discord\n\n.. image:: https://github.com/adafruit/Adafruit_CircuitPython_DS3231/workflows/Build%20CI/badge.svg\n    :target: https://github.com/adafruit/Adafruit_CircuitPython_DS3231/actions/\n    :alt: Build Status\n\n.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json\n    :target: https://github.com/astral-sh/ruff\n    :alt: Code Style: Ruff\n\nThe datasheet for the DS3231 explains that this part is an\n\"Extremely Accurate I²C-Integrated RTC/TCXO/Crystal\". And,\nhey, it does exactly what it says on the tin! This Real Time\nClock (RTC) is the most precise you can get in a small, low\npower package.\n\nMost RTCs use an external 32kHz timing crystal that is used\nto keep time with low current draw. And that's all well and\ngood, but those crystals have slight drift, particularly when\nthe temperature changes (the temperature changes the oscillation\nfrequency very very very slightly but it does add up!) This\nRTC is in a beefy package because the crystal is inside the\nchip! And right next to the integrated crystal is a temperature\nsensor. That sensor compensates for the frequency changes by\nadding or removing clock ticks so that the timekeeping stays\non schedule.\n\nThis is the finest RTC you can get, and now we have it in a\ncompact, breadboard-friendly breakout. With a coin cell\nplugged into the back, you can get years of precision\ntimekeeping, even when main power is lost. Great for\ndatalogging and clocks, or anything where you need to\nreally know the time.\n\n.. image:: ../docs/_static/3013-01.jpg\n    :alt: DS3231 Product Image\n\nDependencies\n=============\nThis driver depends on:\n\n* `Adafruit CircuitPython \u003chttps://github.com/adafruit/circuitpython\u003e`_\n* `Bus Device \u003chttps://github.com/adafruit/Adafruit_CircuitPython_BusDevice\u003e`_\n* `Register \u003chttps://github.com/adafruit/Adafruit_CircuitPython_Register\u003e`_\n\nPlease ensure all dependencies are available on the CircuitPython filesystem.\nThis is easily achieved by downloading\n`the Adafruit library and driver bundle \u003chttps://github.com/adafruit/Adafruit_CircuitPython_Bundle\u003e`_.\n\nInstalling from PyPI\n====================\n\nOn supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from\nPyPI \u003chttps://pypi.org/project/adafruit-circuitpython-ds3231/\u003e`_. To install for current user:\n\n.. code-block:: shell\n\n    pip3 install adafruit-circuitpython-ds3231\n\nTo install system-wide (this may be required in some cases):\n\n.. code-block:: shell\n\n    sudo pip3 install adafruit-circuitpython-ds3231\n\nTo install in a virtual environment in your current project:\n\n.. code-block:: shell\n\n    mkdir project-name \u0026\u0026 cd project-name\n    python3 -m venv .venv\n    source .venv/bin/activate\n    pip3 install adafruit-circuitpython-ds3231\n\nUsage Notes\n===========\n\nBasics\n------\n\nOf course, you must import the library to use it:\n\n.. code:: python3\n\n    import adafruit_ds3231\n    import time\n\nAll the Adafruit RTC libraries take an instantiated and active I2C object\n(from the ``board`` library) as an argument to their constructor. The way to\ncreate an I2C object depends on the board you are using. For boards with labeled\nSCL and SDA pins, you can:\n\n.. code:: python3\n\n    import board\n\nNow, to initialize the I2C bus:\n\n.. code:: python3\n\n    i2c = board.I2C()  # uses board.SCL and board.SDA\n\nOnce you have created the I2C interface object, you can use it to instantiate\nthe RTC object:\n\n.. code:: python3\n\n    rtc = adafruit_ds3231.DS3231(i2c)\n\nDate and time\n-------------\n\nTo set the time, you need to set ``datetime`` to a ``time.struct_time`` object:\n\n.. code:: python3\n\n    rtc.datetime = time.struct_time((2017,1,9,15,6,0,0,9,-1))\n\nAfter the RTC is set, you retrieve the time by reading the ``datetime``\nattribute and access the standard attributes of a struct_time such as ``tm_year``,\n``tm_hour`` and ``tm_min``.\n\n.. code:: python3\n\n    t = rtc.datetime\n    print(t)\n    print(t.tm_hour, t.tm_min)\n\nAlarm\n-----\n\nTo set the time, you need to set ``alarm1`` or ``alarm2`` to a tuple with a\n``time.struct_time`` object and string representing the frequency such as \"hourly\":\n\n.. code:: python3\n\n    rtc.alarm1 = (time.struct_time((2017,1,9,15,6,0,0,9,-1)), \"daily\")\n\nAfter the RTC is set, you retrieve the alarm status by reading the corresponding\n``alarm1_status`` or ``alarm2_status`` attributes. Once True, set it back to False\nto reset.\n\n.. code:: python3\n\n    if rtc.alarm1_status:\n        print(\"wake up!\")\n        rtc.alarm1_status = False\n\nDocumentation\n=============\n\nAPI documentation for this library can be found on `Read the Docs \u003chttps://docs.circuitpython.org/projects/ds3231/en/latest/\u003e`_.\n\nFor information on building library documentation, please check out `this guide \u003chttps://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/sharing-our-docs-on-readthedocs#sphinx-5-1\u003e`_.\n\nContributing\n============\n\nContributions are welcome! Please read our `Code of Conduct\n\u003chttps://github.com/adafruit/Adafruit_CircuitPython_DS3231/blob/main/CODE_OF_CONDUCT.md\u003e`_\nbefore contributing to help this project stay welcoming.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadafruit%2Fadafruit_circuitpython_ds3231","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadafruit%2Fadafruit_circuitpython_ds3231","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadafruit%2Fadafruit_circuitpython_ds3231/lists"}