{"id":13802038,"url":"https://github.com/brainelectronics/micropython-ds1307","last_synced_at":"2025-04-12T01:16:08.660Z","repository":{"id":160012973,"uuid":"634801590","full_name":"brainelectronics/micropython-ds1307","owner":"brainelectronics","description":"MicroPython driver for DS1307 RTC","archived":false,"fork":false,"pushed_at":"2023-06-12T18:43:37.000Z","size":30,"stargazers_count":7,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T01:16:01.670Z","etag":null,"topics":["ds1307","i2c","i2c-device","library","micropython","micropython-lib","rtc"],"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/brainelectronics.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-05-01T08:23:59.000Z","updated_at":"2025-01-13T12:54:19.000Z","dependencies_parsed_at":"2024-01-07T21:53:24.424Z","dependency_job_id":"4c1732d2-e78e-459a-be20-900a619186c9","html_url":"https://github.com/brainelectronics/micropython-ds1307","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":"brainelectronics/micropython-package-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainelectronics%2Fmicropython-ds1307","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainelectronics%2Fmicropython-ds1307/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainelectronics%2Fmicropython-ds1307/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainelectronics%2Fmicropython-ds1307/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brainelectronics","download_url":"https://codeload.github.com/brainelectronics/micropython-ds1307/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248501859,"owners_count":21114684,"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":["ds1307","i2c","i2c-device","library","micropython","micropython-lib","rtc"],"created_at":"2024-08-04T00:01:33.943Z","updated_at":"2025-04-12T01:16:08.637Z","avatar_url":"https://github.com/brainelectronics.png","language":"Python","readme":"# MicroPython DS1307\n\n[![Downloads](https://pepy.tech/badge/micropython-ds1307)](https://pepy.tech/project/micropython-ds1307)\n![Release](https://img.shields.io/github/v/release/brainelectronics/micropython-ds1307?include_prereleases\u0026color=success)\n![MicroPython](https://img.shields.io/badge/micropython-Ok-green.svg)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![codecov](https://codecov.io/github/brainelectronics/micropython-ds1307/branch/main/graph/badge.svg)](https://app.codecov.io/github/brainelectronics/micropython-ds1307)\n[![CI](https://github.com/brainelectronics/micropython-ds1307/actions/workflows/release.yml/badge.svg)](https://github.com/brainelectronics/micropython-ds1307/actions/workflows/release.yml)\n\nMicroPython driver for DS1307 RTC\n\n---------------\n\n## General\n\nMicroPython driver for DS1307 RTC\n\n📚 The latest documentation is available at\n[MicroPython DS1307 ReadTheDocs][ref-rtd-micropython-ds1307] 📚\n\n\u003c!-- MarkdownTOC --\u003e\n\n- [Installation](#installation)\n\t- [Install required tools](#install-required-tools)\n- [Setup](#setup)\n\t- [Install package with upip](#install-package-with-upip)\n\t\t- [General](#general)\n\t\t- [Specific version](#specific-version)\n\t\t- [Test version](#test-version)\n\t- [Manually](#manually)\n\t\t- [Upload files to board](#upload-files-to-board)\n- [Usage](#usage)\n- [Contributing](#contributing)\n\t- [Unittests](#unittests)\n- [Credits](#credits)\n\n\u003c!-- /MarkdownTOC --\u003e\n\n## Installation\n\n### Install required tools\n\nPython3 must be installed on your system. Check the current Python version\nwith the following command\n\n```bash\npython --version\npython3 --version\n```\n\nDepending on which command `Python 3.x.y` (with x.y as some numbers) is\nreturned, use that command to proceed.\n\n```bash\npython3 -m venv .venv\nsource .venv/bin/activate\n\npip install -r requirements.txt\n```\n\n## Setup\n\n### Install package with upip\n\nConnect the MicroPython device to a network (if possible)\n\n```python\nimport network\nstation = network.WLAN(network.STA_IF)\nstation.active(True)\nstation.connect('SSID', 'PASSWORD')\nstation.isconnected()\n```\n\n#### General\n\nInstall the latest package version of this lib on the MicroPython device\n\n```python\nimport mip\nmip.install(\"github:brainelectronics/micropython-ds1307\")\n```\n\nFor MicroPython versions below 1.19.1 use the `upip` package instead of `mip`\n\n```python\nimport upip\nupip.install('micropython-ds1307')\n```\n\n#### Specific version\n\nInstall a specific, fixed package version of this lib on the MicroPython device\n\n```python\nimport mip\n# install a verions of a specific branch\nmip.install(\"github:brainelectronics/micropython-ds1307\", version=\"feature/initial-implementation\")\n# install a tag version\nmip.install(\"github:brainelectronics/micropython-ds1307\", version=\"0.1.0\")\n```\n\nFor MicroPython versions below 1.19.1 use the `upip` package instead of `mip`\n\n```python\nimport upip\nupip.install('micropython-ds1307')\n```\n\n#### Test version\n\nInstall a specific release candidate version uploaded to\n[Test Python Package Index](https://test.pypi.org/) on every PR on the\nMicroPython device. If no specific version is set, the latest stable version\nwill be used.\n\n```python\nimport mip\nmip.install(\"github:brainelectronics/micropython-ds1307\", version=\"0.1.0-rc1.dev1\")\n```\n\nFor MicroPython versions below 1.19.1 use the `upip` package instead of `mip`\n\n```python\nimport upip\n# overwrite index_urls to only take artifacts from test.pypi.org\nupip.index_urls = ['https://test.pypi.org/pypi']\nupip.install('micropython-ds1307')\n```\n\nSee also [brainelectronics Test PyPi Server in Docker][ref-brainelectronics-test-pypiserver]\nfor a test PyPi server running on Docker.\n\n### Manually\n\n#### Upload files to board\n\nCopy the module to the MicroPython board and import them as shown below\nusing [Remote MicroPython shell][ref-remote-upy-shell]\n\nOpen the remote shell with the following command. Additionally use `-b 115200`\nin case no CP210x is used but a CH34x.\n\n```bash\nrshell --port /dev/tty.SLAB_USBtoUART --editor nano\n```\n\nPerform the following command inside the `rshell` to copy all files and\nfolders to the device\n\n```bash\nmkdir /pyboard/lib\nmkdir /pyboard/lib/ds1307\n\ncp ds1307/* /pyboard/lib/ds1307\n\ncp examples/main.py /pyboard\ncp examples/boot.py /pyboard\n```\n\n## Usage\n\n```python\nfrom ds1307 import DS1307\nfrom machine import I2C, Pin\nfrom time import gmtime, time\n\n# DS1307 on 0x68\nI2C_ADDR = 0x68     # DEC 104, HEX 0x68\n\n# define custom I2C interface, default is 'I2C(0)'\n# check the docs of your device for further details and pin infos\n# this are the pins for the Raspberry Pi Pico adapter board\ni2c = I2C(0, scl=Pin(13), sda=Pin(12), freq=800000)\nds1307 = DS1307(addr=I2C_ADDR, i2c=i2c)\n\n# get the current RTC time\nprint(\"Current RTC time: {}\".format(ds1307.datetime))\n\n# set the RTC time to the current system time\nnow = gmtime(time())\nds1307.datetime = now\n\nprint(\"Current RTC time: {}\".format(ds1307.datetime))\n\n# Print the date and time in ISO8601 format: 2023-04-18T21:14:22\nprint(\"Today is {:04d}-{:02d}-{:02d}T{:02d}:{:02d}:{:02d}\".format(\n    ds1307.year, ds1307.month, ds1307.day,\n    ds1307.hour, ds1307.minute, ds1307.second))\n```\n\n## Contributing\n\n### Unittests\n\nRun the unittests locally with the following command after installing this\npackage in a virtual environment\n\n```bash\n# run all tests\nnose2 --config tests/unittest.cfg\n\n# run only one specific tests\nnose2 tests.test_ds1307.TestDS1307.test_addr\n```\n\nGenerate the coverage files with\n\n```bash\npython create_report_dirs.py\ncoverage html\n```\n\nThe coverage report is placed at `reports/coverage/html/index.html`\n\n## Credits\n\nBased on\n[Mike Causer's MicroPython TinyRTC I2C module][ref-micropython-tinyrtc-i2c]\nand the [PyPa sample project][ref-pypa-sample]\n\n\u003c!-- Links --\u003e\n[ref-rtd-micropython-ds1307]: https://micropython-ds1307.readthedocs.io/en/latest/\n[ref-remote-upy-shell]: https://github.com/dhylands/rshell\n[ref-brainelectronics-test-pypiserver]: https://github.com/brainelectronics/test-pypiserver\n[ref-micropython-tinyrtc-i2c]: https://github.com/mcauser/micropython-tinyrtc-i2c\n[ref-pypa-sample]: https://github.com/pypa/sampleproject\n[ref-test-pypi]: https://test.pypi.org/\n[ref-pypi]: https://pypi.org/\n","funding_links":[],"categories":["Libraries"],"sub_categories":["Communications"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrainelectronics%2Fmicropython-ds1307","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrainelectronics%2Fmicropython-ds1307","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrainelectronics%2Fmicropython-ds1307/lists"}