{"id":13802299,"url":"https://github.com/mcauser/micropython-pcf8575","last_synced_at":"2025-07-28T05:32:49.409Z","repository":{"id":150620711,"uuid":"224465356","full_name":"mcauser/micropython-pcf8575","owner":"mcauser","description":"MicroPython driver for PCF8575 16-Bit I2C I/O Expander with Interrupt","archived":false,"fork":false,"pushed_at":"2024-02-11T04:11:13.000Z","size":2873,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-22T12:34:56.206Z","etag":null,"topics":["io-expander","micropython","pcf8575"],"latest_commit_sha":null,"homepage":null,"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/mcauser.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-27T15:50:50.000Z","updated_at":"2024-08-04T00:07:07.563Z","dependencies_parsed_at":"2024-08-04T00:17:53.245Z","dependency_job_id":null,"html_url":"https://github.com/mcauser/micropython-pcf8575","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/mcauser/micropython-pcf8575","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicropython-pcf8575","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicropython-pcf8575/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicropython-pcf8575/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicropython-pcf8575/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcauser","download_url":"https://codeload.github.com/mcauser/micropython-pcf8575/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicropython-pcf8575/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267468383,"owners_count":24092332,"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","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["io-expander","micropython","pcf8575"],"created_at":"2024-08-04T00:01:41.498Z","updated_at":"2025-07-28T05:32:48.782Z","avatar_url":"https://github.com/mcauser.png","language":"Python","readme":"# MicroPython PCF8575\n\nA MicroPython library for PCF8575 16-Bit I2C I/O Expander with Interrupt.\n\n![demo](docs/demo.jpg)\n\nThe PCF8575 consists of a 16-bit quasi-bidirectional port and an I2C-bus interface.\n\nThe device includes latched outputs with high current drive capability for directly driving LEDs.\n\nThe interrupt has an open-drain output, which means you need a pull-up on your microcontroller\nto detect when the PCF8575 drives it LOW.\n\nWhen setting a pin HIGH, it acts as both output AND input. The pin internally uses a weak\ncurrent-source pull-up to latch output HIGH.\nWhen driven LOW, for example, with a push button, the pin will read as LOW.\n\nAn interrupt fires on any rising or falling edge of the pins in input mode (HIGH).\nInterrupt is cleared when the pins are changed or the port is read.\n\nThe pins are labelled P00-P07 for port A and P10-P17 for port B.\nWhen using the pin() method, there is no pins 8-9.\nPort B's numbering scheme starts at 10 so the right-most digit for both ports is 0-7.\n\nWhen accessing the 16-bit port directly, there is no gaps. bit0 is P00 and bit8 is P10.\n\nAt power on, all pins are driven HIGH and can be immediately used as inputs.\n\nOperating voltage: 2.5V - 5.5V\n\n\n## Installation\n\nUsing mip via mpremote:\n\n```bash\n$ mpremote mip install github:mcauser/micropython-pcf8575\n$ mpremote mip install github:mcauser/micropython-pcf8575/examples\n```\n\nUsing mip directly on a WiFi capable board:\n\n```python\n\u003e\u003e\u003e import mip\n\u003e\u003e\u003e mip.install(\"github:mcauser/micropython-pcf8575\")\n\u003e\u003e\u003e mip.install(\"github:mcauser/micropython-pcf8575/examples\")\n```\n\nManual installation:\n\nCopy `src/pcf8575.py` to the root directory of your device.\n\n\n## Examples\n\n**Basic Usage**\n\n```python\nimport pcf8575\nfrom machine import I2C, Pin\n\n# TinyPICO (ESP32)\ni2c = I2C(0)\npcf = pcf8575.PCF8575(i2c, 0x20)\n\n# read pin 2\npcf.pin(2)\n\n# set pin 3 HIGH\npcf.pin(3, 1)\n\n# set pin 4 LOW\npcf.pin(4, 0)\n\n# toggle pin 5\npcf.toggle(5)\n\n# set all pins at once with 16-bit int\npcf.port = 0xFF00\n\n# read all pins at once as 16-bit int\npcf.port\n# returns 65280 (0xFF00)\n```\n\nFor more detailed examples, see [examples](/examples).\n\nIf you mip installed them above, you can run them like so:\n\n```python\nimport pcf8575.examples.basic\n```\n\n## Methods\n\nConstruct with a reference to I2C and set the device address.\nValid address range 0x20-0x27.\nIf are you not sure what it is, run an `i2c.scan()`.\nSee below for address selection.\n```python\n__init__(i2c, address=0x20)\n```\n\nScans the I2C bus for the provided address and returns True if a device is present\notherwise raises an OSError.\n```python\ncheck()\n```\n\nMethod for getting or setting a single pin.\nIf no value is provided, the port will be read and value of specified pin returned.\nIf a value is provided, the port will be updated and device written to.\nThe port is written to after each call. If you intend to toggle many pins at once, use the\nport property instead. See below.\nValid pin range 0-7 and 10-17.\n```python\npin(pin, value=None)\n```\n\nMethod for flipping the value of a single pin.\nValid pin range 0-7 and 10-17.\n```python\ntoggle(pin)\n```\n\nPrivate method for checking the supplied pin number is within valid ranges.\n```python\n_validate_pin()\n```\n\nPrivate method for loading _port from the device.\n```python\n_read()\n```\n\nPrivate method for sending _port to the device.\n```python\n_write()\n```\n\n\n## Properties\n\nGetter reads the port from the device and returns a 16 bit integer.\n```python\nport\n```\n\nSetter writes a 16-bit integer representing the port to the device.\nIf you are setting multiple pins at once, use this instead of the pin() method as\nthis writes the entire 16-bit port to the device once, rather than 16 separate writes.\n```python\nport = 0xFFFF\n```\n\n\n## Ports\n\n* P00-P07 - Port A\n* P10-P17 - Port B\n\nWhy is there no P08 and P09? Because they skipped them when naming the pins,\nso that the lest significant digit is 0-7 for both ports. There's still only 16 bits.\nPort B pins are just labelled +2.\n\nThis chip only has two ports (16 pins). If you only need 8 pins, the\n[PCF8574](https://github.com/mcauser/micropython-pcf8574) has a single port (8 pins).\n\n\n## Interrupts\n\n* INT - Active LOW\n\nShared by both ports A and B. Triggered by either.\n\n\n## I2C Interface\n\nIf you are using a module, most contain 10k pull-ups on the SCL and SDA lines.\n\nIf you are using the PCF8575 chip directly, you'll need to add your own.\n\n\n### I2C Address\n\nThe chip supports I2C addresses 0x20-0x27 and is customisable using address pins A0, A1, A2\n\nA0  | A1  | A2  | I2C Address\n----|-----|-----|------------\nGND | GND | GND | 0x20 (default)\n3V3 | GND | GND | 0x21\nGND | 3V3 | GND | 0x22\n3V3 | 3V3 | GND | 0x23\nGND | GND | 3V3 | 0x24\n3V3 | GND | 3V3 | 0x25\nGND | 3V3 | 3V3 | 0x26\n3V3 | 3V3 | 3V3 | 0x27\n\n\n## Parts\n\n* [PCF8575 blue module](https://s.click.aliexpress.com/e/_DdXNOaN)\n* [PCF8575 blue module](https://s.click.aliexpress.com/e/_DFBcPc5)\n* [PCF8575 blue module](https://s.click.aliexpress.com/e/_DDFiuqV)\n* [PCF8575 red module](https://s.click.aliexpress.com/e/_DmRWVFx)\n* [PCF8575 10x SSOP-24](https://s.click.aliexpress.com/e/_DDBKEJP)\n* [TinyPICO](https://www.tinypico.com/)\n\n\n## Connections\n\n### TinyPICO ESP32\n\n```python\nfrom machine import SoftI2C, Pin\ni2c = SoftI2C(scl=Pin(22), sda=Pin(21))\n\nfrom machine import I2C, Pin\ni2c = I2C(0)\n```\n\nPCF8575 Module | TinyPICO (ESP32)\n-------------- | ----------------\nSDA            | 21 (SDA)\nSCL            | 22 (SCL)\nVCC            | 3V3\nGND            | GND\nINT (optional) | 4\n\n\n## Links\n\n* [micropython.org](http://micropython.org)\n* [PCF8575 datasheet](docs/pcf8575.pdf)\n* [TinyPICO Getting Started](https://www.tinypico.com/gettingstarted)\n\n\n## License\n\nLicensed under the [MIT License](http://opensource.org/licenses/MIT).\n\nCopyright (c) 2019 Mike Causer\n","funding_links":[],"categories":["Libraries"],"sub_categories":["IO"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcauser%2Fmicropython-pcf8575","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcauser%2Fmicropython-pcf8575","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcauser%2Fmicropython-pcf8575/lists"}