{"id":13802322,"url":"https://github.com/mcauser/micropython-xl9535-kxv5-relay","last_synced_at":"2025-10-19T15:21:24.846Z","repository":{"id":220677285,"uuid":"752267294","full_name":"mcauser/micropython-xl9535-kxv5-relay","owner":"mcauser","description":"A MicroPython library for jxl XL9535-KxV5 I2C relay boards","archived":false,"fork":false,"pushed_at":"2024-02-04T11:00:45.000Z","size":2634,"stargazers_count":12,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-04T15:50:38.287Z","etag":null,"topics":["micropython","relay","relay-board","xl9535"],"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/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}},"created_at":"2024-02-03T14:31:35.000Z","updated_at":"2025-03-30T02:02:36.000Z","dependencies_parsed_at":"2024-02-12T03:32:22.963Z","dependency_job_id":null,"html_url":"https://github.com/mcauser/micropython-xl9535-kxv5-relay","commit_stats":null,"previous_names":["mcauser/micropython-xl9535-kxv5-relay"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/mcauser/micropython-xl9535-kxv5-relay","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicropython-xl9535-kxv5-relay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicropython-xl9535-kxv5-relay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicropython-xl9535-kxv5-relay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicropython-xl9535-kxv5-relay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcauser","download_url":"https://codeload.github.com/mcauser/micropython-xl9535-kxv5-relay/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicropython-xl9535-kxv5-relay/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267468368,"owners_count":24092330,"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":["micropython","relay","relay-board","xl9535"],"created_at":"2024-08-04T00:01:42.018Z","updated_at":"2025-10-19T15:21:24.748Z","avatar_url":"https://github.com/mcauser.png","language":"Python","funding_links":[],"categories":["Libraries"],"sub_categories":["IO"],"readme":"# MicroPython XL9535 KxV5 Relay\n\nA MicroPython library for jxl XL9535-KxV5 I2C relay boards.\n\nThe board features a XL9535 16-bit I/O Expander with I2C Interface.\n\n![demo](docs/xl9535_kxv5.jpg)\n\n\n## Installation\n\nUsing mip via mpremote:\n\n```bash\n$ mpremote mip install github:mcauser/micropython-xl9535-kxv5-relay\n$ mpremote mip install github:mcauser/micropython-xl9535-kxv5-relay/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-xl9535-kxv5-relay\")\n\u003e\u003e\u003e mip.install(\"github:mcauser/micropython-xl9535-kxv5-relay/examples\")\n```\n\nManual installation:\n\nCopy `src/xl9535_relay.py` to the root directory of your device.\n\n\n## Examples\n\n**Basic usage**\n\n```python\nfrom machine import I2C, Pin\ni2c = I2C(0)\n\ni2c.scan()\n# [32]\n\nimport xl9535_relay\nboard = xl9535_relay.XL9535_KXV5(i2c, 0x20)\n\n# start with all circuits on, all relays off\nboard.init()\n\n# switch relay A0 on\nboard.relay(0, True)\n\n# switch relay A1 on\nboard.relay(1, True)\n\n# switch relay A2 off\nboard.relay(2, False)\n\n# switch relay A3 on\nboard.relay(3, True)\n\n# is relay A0 on?\nboard.relay(0)\n# True\n\n# what relays are on?\nboard.relays()\n# 11\n# 11 == 0b_0000_0000_0000_1011 = 0x000B\n# bit0 = relay A0 on\n# bit1 = relay A1 on\n# bit2 = relay A2 off\n# bit3 = relay A3 on\n# ...\n# bit14 = relay B6 off\n# bit15 = relay B7 off\n\n# turn all relays on\nboard.relays(0xffff)\n\n# turn all relays off\nboard.relays(0x0000)\n```\n\nFor more detailed examples, see [examples](/examples).\n\n\n## Board info\n\nA continuity check confirms all (SCL/SDA/5V/GND) I2C ports share the same bus.\nThe JST PH2.0 4P connector is the same size as Seeed's Grove connector, but the pin order is different.\nSupports 400kHz I2C frequency.\n\nAll of the power sockets are common, I2C, DC jack, USB-C.\nEach support 2.3 - 5.5V.\nThe DC jack is NOT 12V compatible!\n\nThere is no logic-level conversion on the I2C pins.\nThe XL9535 is 5V tolerant and works fine on a 3.3V MCU.\n\nSupplying power on any source lights the red PWR LED.\nWhen a relay is triggered, it's corresponding blue LED is lit.\n\n![buses](docs/buses.jpg)\n\nIf the yellow jumper J1 is removed, all relays are switched off.\n\nAfter reconnecting, you will need to reconfigure the outputs/config, ie. call `board.init()`\n\nThe board uses the XL9535 I/O expander as output only, and doesn't use interrupts.\nEach IO pin is connected to a relay and it doesn't make sense configuring it as an input.\n\n\n## Board variants\n\nThere are 5 variants of this board, featuring 1,2,4,8 or 16 relays.\n\n* XL9535-K1V5\n* XL9535-K2V5\n* XL9535-K4V5\n* XL9535-K8V5\n* XL9535-K16V5\n\n![variants](docs/variants.jpg)\n\n\n## Relays\n\nThe relays are Songle SRD-05VDC-SL-C with a 10A switching capacity.\n\nIf a relay's blue LED is on, COM is connected to NO and NC is not connected.\n\n`NC-x-COM\u003c-\u003eNO`\n\nIf a relay's blue LED is off, COM is connected to NC and NO is not connected.\n\n`NC\u003c--\u003eCOM-x-NO`\n\n![relays](docs/relays.jpg)\n\n\n## I2C Interface\n\nThere are three address select pins (A0,A1,A2) providing addresses 0x20-0x27 for up to 8 of these devices on the I2C bus.\n\nThe board includes pull-up resistors on the SCL + SDA lines.\n\nAdd a dab of solder to bridge the address select pads to pull A0,A1,A2 up to VCC.\n\n| A0  | A1  | A2  | I2C Address\n| :---|:----|:----|:-----------\n| -   | -   | -   | 0x20 (default)\n| VCC | -   | -   | 0x21\n| -   | VCC | -   | 0x22\n| VCC | VCC | -   | 0x23\n| -   | -   | VCC | 0x24\n| VCC | -   | VCC | 0x25\n| -   | VCC | VCC | 0x26\n| VCC | VCC | VCC | 0x27\n\n\n## Parts\n\n* [XL9535-KxV5 boards](https://s.click.aliexpress.com/e/_DnDJHmd)\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\nXL9535-KxV5  | TinyPICO (ESP32)\n------------ | ----------------\nGND          | GND\nVCC          | 3V3\nSDA          | 21 (SDA)\nSCL          | 22 (SCL)\n\n\n## Links\n\n* [micropython.org](http://micropython.org)\n* [XL9535 datasheet](docs/XL9535.pdf)\n* [SRD-05VDC-SL-C datasheet](docs/SRD-05VDC-SL-C.pdf)\n* [SRD-05VDC-SL-C (CN) datasheet](docs/SRD-05VDC-SL-C-cn.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) 2024 Mike Causer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcauser%2Fmicropython-xl9535-kxv5-relay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcauser%2Fmicropython-xl9535-kxv5-relay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcauser%2Fmicropython-xl9535-kxv5-relay/lists"}