{"id":15375012,"url":"https://github.com/novi/i2c-swift","last_synced_at":"2025-04-15T15:13:12.761Z","repository":{"id":139037552,"uuid":"79193521","full_name":"novi/i2c-swift","owner":"novi","description":"I2C Bus Library for Swift","archived":false,"fork":false,"pushed_at":"2017-02-06T10:50:08.000Z","size":14,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T15:13:06.676Z","etag":null,"topics":["i2c","linux","raspberrypi","swift"],"latest_commit_sha":null,"homepage":null,"language":"Swift","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/novi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2017-01-17T05:50:33.000Z","updated_at":"2023-12-26T06:25:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"480b0541-5a53-4c85-903e-6e0aedb9e89c","html_url":"https://github.com/novi/i2c-swift","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novi%2Fi2c-swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novi%2Fi2c-swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novi%2Fi2c-swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novi%2Fi2c-swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/novi","download_url":"https://codeload.github.com/novi/i2c-swift/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249094933,"owners_count":21211837,"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":["i2c","linux","raspberrypi","swift"],"created_at":"2024-10-01T14:00:35.427Z","updated_at":"2025-04-15T15:13:12.737Z","avatar_url":"https://github.com/novi.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# i2c-swift\n\nI2C Bus Library for Swift\n\n## Supported Platform\n\n* [I2C tiny USB](https://github.com/novi/i2c_tiny_usb) adapter (Mac, Linux)\n* I2C Kernel device (/dev/i2c-*) (Linux, Raspberry Pi etc...)\n\n## Building\n\nInstall libusb package.\n\n### macOS\n\n```\n$ brew install libusb-compat libusb\n```\n\n### Linux(Ubuntu 16.04)\n\n\n```\n$ sudo apt-get install i2c-tools libi2c-dev\n```\n\n## Usage\n\n```swift\n// create a device (see table below.)\nlet device = try I2CTinyUSB()\n// or\nlet device = try I2CBusDevice(portNumber: 0) \n\n// write data and read 5 bytes of data to slave address 0x23\nlet readData = try device.write(toAddress: 0x23, data: dataToWrite, readBytes: 5)\nreadData.count == 5 // true\n\n```\n\n| Platform |      Bus connection      |    Driver    |      Class     |\n|----------|--------------------------|--------------|----------------|\n|  macOS   | I2C tiny USB             |    libusb    | `I2CTinyUSB`   |\n|  Linux   | I2C tiny USB             |    libusb    | not supported, use `/dev/i2c-*`   |\n|  Linux   | I2C tiny USB             | `/dev/i2c-*` | `I2CBusDevice` | \n|  Linux   | Native I2C bus (on GPIO) | `/dev/i2c-*` | `I2CBusDevice` |  \n\nSee [demo project](https://github.com/novi/i2c-swift-example) for every platform.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnovi%2Fi2c-swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnovi%2Fi2c-swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnovi%2Fi2c-swift/lists"}