micropython-eeprom


Namemicropython-eeprom JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/brainelectronics/micropython-eeprom
SummaryMicroPython driver for AT24Cxx EEPROM
upload_time2023-06-12 18:13:43
maintainer
docs_urlNone
authorbrainelectronics
requires_python
licenseMIT
keywords micropython i2c eeprom driver
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # MicroPython EEPROM

[![Downloads](https://pepy.tech/badge/micropython-eeprom)](https://pepy.tech/project/micropython-eeprom)
![Release](https://img.shields.io/github/v/release/brainelectronics/micropython-eeprom?include_prereleases&color=success)
![MicroPython](https://img.shields.io/badge/micropython-Ok-green.svg)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![codecov](https://codecov.io/github/brainelectronics/micropython-eeprom/branch/main/graph/badge.svg)](https://app.codecov.io/github/brainelectronics/micropython-eeprom)
[![CI](https://github.com/brainelectronics/micropython-eeprom/actions/workflows/release.yml/badge.svg)](https://github.com/brainelectronics/micropython-eeprom/actions/workflows/release.yml)

MicroPython driver for AT24Cxx EEPROM

---------------

## General

MicroPython driver for AT24Cxx EEPROM

📚 The latest documentation is available at
[MicroPython EEPROM ReadTheDocs][ref-rtd-micropython-eeprom] 📚

<!-- MarkdownTOC -->

- [Installation](#installation)
    - [Install required tools](#install-required-tools)
- [Setup](#setup)
    - [Install package with upip](#install-package-with-upip)
        - [General](#general)
        - [Specific version](#specific-version)
        - [Test version](#test-version)
    - [Manually](#manually)
        - [Upload files to board](#upload-files-to-board)
- [Usage](#usage)
- [Contributing](#contributing)
    - [Unittests](#unittests)
- [Credits](#credits)

<!-- /MarkdownTOC -->

## Installation

### Install required tools

Python3 must be installed on your system. Check the current Python version
with the following command

```bash
python --version
python3 --version
```

Depending on which command `Python 3.x.y` (with x.y as some numbers) is
returned, use that command to proceed.

```bash
python3 -m venv .venv
source .venv/bin/activate

pip install -r requirements.txt
```

## Setup

### Install package with upip

Connect the MicroPython device to a network (if possible)

```python
import network
station = network.WLAN(network.STA_IF)
station.active(True)
station.connect('SSID', 'PASSWORD')
station.isconnected()
```

#### General

Install the latest package version of this lib on the MicroPython device

```python
import mip
mip.install("github:brainelectronics/micropython-eeprom")
```

For MicroPython versions below 1.19.1 use the `upip` package instead of `mip`

```python
import upip
upip.install('micropython-eeprom')
```

#### Specific version

Install a specific, fixed package version of this lib on the MicroPython device

```python
import mip
# install a verions of a specific branch
mip.install("github:brainelectronics/micropython-eeprom", version="feature/initial-implementation")
# install a tag version
mip.install("github:brainelectronics/micropython-eeprom", version="0.1.0")
```

For MicroPython versions below 1.19.1 use the `upip` package instead of `mip`

```python
import upip
upip.install('micropython-eeprom')
```

#### Test version

Install a specific release candidate version uploaded to
[Test Python Package Index](https://test.pypi.org/) on every PR on the
MicroPython device. If no specific version is set, the latest stable version
will be used.

```python
import mip
mip.install("github:brainelectronics/micropython-eeprom", version="0.1.0-rc1.dev1")
```

For MicroPython versions below 1.19.1 use the `upip` package instead of `mip`

```python
import upip
# overwrite index_urls to only take artifacts from test.pypi.org
upip.index_urls = ['https://test.pypi.org/pypi']
upip.install('micropython-eeprom')
```

See also [brainelectronics Test PyPi Server in Docker][ref-brainelectronics-test-pypiserver]
for a test PyPi server running on Docker.

### Manually

#### Upload files to board

Copy the module to the MicroPython board and import them as shown below
using [Remote MicroPython shell][ref-remote-upy-shell]

Open the remote shell with the following command. Additionally use `-b 115200`
in case no CP210x is used but a CH34x.

```bash
rshell --port /dev/tty.SLAB_USBtoUART --editor nano
```

Perform the following command inside the `rshell` to copy all files and
folders to the device

```bash
mkdir /pyboard/lib
mkdir /pyboard/lib/eeprom

cp eeprom/* /pyboard/lib/eeprom

cp examples/main.py /pyboard
cp examples/boot.py /pyboard
```

## Usage

```python
from eeprom import EEPROM
from machine import I2C, Pin

I2C_ADDR = 0x50     # DEC 80, HEX 0x50
EEPROM_SIZE = 32    # AT24C32 on 0x50

# define custom I2C interface, default is 'I2C(0)'
# check the docs of your device for further details and pin infos
i2c = I2C(0, scl=Pin(13), sda=Pin(12), freq=800000)
eeprom = EEPROM(addr=I2C_ADDR, at24x=EEPROM_SIZE, i2c=i2c)

# write 'micropython' to address 10
eeprom.write(10, 'micropython')

# read 11 bytes starting at address 10
eeprom.read(10, 11)

# update content at address 10 with 'MicroPython'
# only changed values are written, here 'm' -> 'M' and 'p' -> 'P'
eeprom.write(10, 'MicroPython')
```

## Contributing

### Unittests

Run the unittests locally with the following command after installing this
package in a virtual environment

```bash
# run all tests
nose2 --config tests/unittest.cfg

# run only one specific tests
nose2 tests.test_eeprom.TestEEPROM.test_addr
```

Generate the coverage files with

```bash
python create_report_dirs.py
coverage html
```

The coverage report is placed at `reports/coverage/html/index.html`

## Credits

Based on
[Mike Causer's MicroPython TinyRTC I2C module][ref-micropython-tinyrtc-i2c]
and the [PyPa sample project][ref-pypa-sample]

<!-- Links -->
[ref-rtd-micropython-eeprom]: https://micropython-eeprom.readthedocs.io/en/latest/
[ref-remote-upy-shell]: https://github.com/dhylands/rshell
[ref-brainelectronics-test-pypiserver]: https://github.com/brainelectronics/test-pypiserver
[ref-micropython-tinyrtc-i2c]: https://github.com/mcauser/micropython-tinyrtc-i2c
[ref-pypa-sample]: https://github.com/pypa/sampleproject
[ref-test-pypi]: https://test.pypi.org/
[ref-pypi]: https://pypi.org/



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/brainelectronics/micropython-eeprom",
    "name": "micropython-eeprom",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "micropython,i2c,eeprom,driver",
    "author": "brainelectronics",
    "author_email": "info@brainelectronics.de",
    "download_url": "https://files.pythonhosted.org/packages/b5/a2/1ad3a5851de33dfeac7bdad3667ea2e63e071b19bee8ef653d32ef6eb0dd/micropython-eeprom-0.1.1.tar.gz",
    "platform": null,
    "description": "# MicroPython EEPROM\n\n[![Downloads](https://pepy.tech/badge/micropython-eeprom)](https://pepy.tech/project/micropython-eeprom)\n![Release](https://img.shields.io/github/v/release/brainelectronics/micropython-eeprom?include_prereleases&color=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-eeprom/branch/main/graph/badge.svg)](https://app.codecov.io/github/brainelectronics/micropython-eeprom)\n[![CI](https://github.com/brainelectronics/micropython-eeprom/actions/workflows/release.yml/badge.svg)](https://github.com/brainelectronics/micropython-eeprom/actions/workflows/release.yml)\n\nMicroPython driver for AT24Cxx EEPROM\n\n---------------\n\n## General\n\nMicroPython driver for AT24Cxx EEPROM\n\n\ud83d\udcda The latest documentation is available at\n[MicroPython EEPROM ReadTheDocs][ref-rtd-micropython-eeprom] \ud83d\udcda\n\n<!-- MarkdownTOC -->\n\n- [Installation](#installation)\n    - [Install required tools](#install-required-tools)\n- [Setup](#setup)\n    - [Install package with upip](#install-package-with-upip)\n        - [General](#general)\n        - [Specific version](#specific-version)\n        - [Test version](#test-version)\n    - [Manually](#manually)\n        - [Upload files to board](#upload-files-to-board)\n- [Usage](#usage)\n- [Contributing](#contributing)\n    - [Unittests](#unittests)\n- [Credits](#credits)\n\n<!-- /MarkdownTOC -->\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-eeprom\")\n```\n\nFor MicroPython versions below 1.19.1 use the `upip` package instead of `mip`\n\n```python\nimport upip\nupip.install('micropython-eeprom')\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-eeprom\", version=\"feature/initial-implementation\")\n# install a tag version\nmip.install(\"github:brainelectronics/micropython-eeprom\", 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-eeprom')\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-eeprom\", 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-eeprom')\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/eeprom\n\ncp eeprom/* /pyboard/lib/eeprom\n\ncp examples/main.py /pyboard\ncp examples/boot.py /pyboard\n```\n\n## Usage\n\n```python\nfrom eeprom import EEPROM\nfrom machine import I2C, Pin\n\nI2C_ADDR = 0x50     # DEC 80, HEX 0x50\nEEPROM_SIZE = 32    # AT24C32 on 0x50\n\n# define custom I2C interface, default is 'I2C(0)'\n# check the docs of your device for further details and pin infos\ni2c = I2C(0, scl=Pin(13), sda=Pin(12), freq=800000)\neeprom = EEPROM(addr=I2C_ADDR, at24x=EEPROM_SIZE, i2c=i2c)\n\n# write 'micropython' to address 10\neeprom.write(10, 'micropython')\n\n# read 11 bytes starting at address 10\neeprom.read(10, 11)\n\n# update content at address 10 with 'MicroPython'\n# only changed values are written, here 'm' -> 'M' and 'p' -> 'P'\neeprom.write(10, 'MicroPython')\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_eeprom.TestEEPROM.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<!-- Links -->\n[ref-rtd-micropython-eeprom]: https://micropython-eeprom.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\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "MicroPython driver for AT24Cxx EEPROM",
    "version": "0.1.1",
    "project_urls": {
        "Bug Reports": "https://github.com/brainelectronics/micropython-eeprom/issues",
        "Homepage": "https://github.com/brainelectronics/micropython-eeprom",
        "Source": "https://github.com/brainelectronics/micropython-eeprom"
    },
    "split_keywords": [
        "micropython",
        "i2c",
        "eeprom",
        "driver"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b5a21ad3a5851de33dfeac7bdad3667ea2e63e071b19bee8ef653d32ef6eb0dd",
                "md5": "c8523fd9c65a5fe38957fd4658d56a38",
                "sha256": "fcc5a8e1d8ee066c0f09096c2e7be14740731ff30d7521270796169cab1a1060"
            },
            "downloads": -1,
            "filename": "micropython-eeprom-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "c8523fd9c65a5fe38957fd4658d56a38",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5606,
            "upload_time": "2023-06-12T18:13:43",
            "upload_time_iso_8601": "2023-06-12T18:13:43.628146Z",
            "url": "https://files.pythonhosted.org/packages/b5/a2/1ad3a5851de33dfeac7bdad3667ea2e63e071b19bee8ef653d32ef6eb0dd/micropython-eeprom-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-12 18:13:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "brainelectronics",
    "github_project": "micropython-eeprom",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [],
    "lcname": "micropython-eeprom"
}
        
Elapsed time: 2.12457s