{"id":16389437,"url":"https://github.com/mnishiguchi/i2c_server","last_synced_at":"2025-03-23T04:31:36.909Z","repository":{"id":57506103,"uuid":"362258800","full_name":"mnishiguchi/i2c_server","owner":"mnishiguchi","description":"Wrap an I2C device in a separate process","archived":false,"fork":false,"pushed_at":"2021-08-26T12:10:56.000Z","size":82,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-01T11:48:33.380Z","etag":null,"topics":["elixir","i2c","i2c-bus","i2c-device","nerves","nerves-project"],"latest_commit_sha":null,"homepage":"","language":"Elixir","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/mnishiguchi.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}},"created_at":"2021-04-27T21:42:54.000Z","updated_at":"2021-10-11T21:15:57.000Z","dependencies_parsed_at":"2022-08-29T20:00:31.345Z","dependency_job_id":null,"html_url":"https://github.com/mnishiguchi/i2c_server","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnishiguchi%2Fi2c_server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnishiguchi%2Fi2c_server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnishiguchi%2Fi2c_server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnishiguchi%2Fi2c_server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mnishiguchi","download_url":"https://codeload.github.com/mnishiguchi/i2c_server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244270287,"owners_count":20426371,"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":["elixir","i2c","i2c-bus","i2c-device","nerves","nerves-project"],"created_at":"2024-10-11T04:32:59.086Z","updated_at":"2025-03-23T04:31:36.530Z","avatar_url":"https://github.com/mnishiguchi.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# I2C Server\n\n[![Hex.pm](https://img.shields.io/hexpm/v/i2c_server.svg)](https://hex.pm/packages/i2c_server)\n[![API docs](https://img.shields.io/hexpm/v/i2c_server.svg?label=docs)](https://hexdocs.pm/i2c_server)\n[![CI](https://github.com/mnishiguchi/i2c_server/actions/workflows/ci.yml/badge.svg)](https://github.com/mnishiguchi/i2c_server/actions/workflows/ci.yml)\n\nI2C Server wraps [`Circuits.I2C`](https://hexdocs.pm/circuits_i2c/readme.html) [reference](http://erlang.org/documentation/doc-6.0/doc/reference_manual/data_types.html#id67235) in a [`GenServer`](https://hexdocs.pm/elixir/GenServer.html), creating a separate\nprocess per [I2C](https://en.wikipedia.org/wiki/I%C2%B2C) bus. I2C bus processes are\nidentified with a bus name (e.g., `\"i2c-1\"`).\n\n## Installation\n\nJust add `i2c_server` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:i2c_server, \"~\u003e 0.2\"}\n  ]\nend\n```\n\n## Usage\n\n```elixir\n# Get a PID for the device at the address 0x77 on the \"i2c-1\" bus\niex\u003e {:ok, device} = I2cServer.start_link(bus_name: \"i2c-1\", bus_address: 0x77)\n#PID\u003c0.233.0\u003e\n\n# Write 0xff to the register 0x8A\niex\u003e I2cServer.write(device, [0x8A, \u003c\u003c0xff\u003e\u003e])\n:ok\n\n# Read 3 bytes\niex\u003e I2cServer.read(device, 3)\n:ok\n\n# Read 3 bytes from the register 0xE1\niex\u003e I2cServer.write_read(device, 0xE1, 3)\n{:ok, \u003c\u003c0, 0, 0\u003e\u003e}\n\n# Do multiple operations sequentially blocking the bus worker process\niex\u003e I2cServer.bulk(device, [\n...\u003e   {:write, [0xBA]},\n...\u003e   {:sleep, 10},\n...\u003e   {:write, [0xAC, \u003c\u003c0x33, 0x00\u003e\u003e]},\n...\u003e   {Process, :sleep, [10]},\n...\u003e   fn(_) -\u003e \"something\" end\n...\u003e ])\n[:ok, :ok, :ok, :ok, \"something\"]\n```\n\nI2C bus processes will be created under `I2cServer.I2cBusSupervisor` dynamically.\n\n![](https://user-images.githubusercontent.com/7563926/117657605-c2083e00-b167-11eb-8f76-3595b4fa5785.png)\n\n## Configuration\n\nYou can change settings in your config file such as `config/config.exs` file.\n\n### Registry module\n\nBy default, I2C bus processes are\nstored in [`Registry`](https://hexdocs.pm/elixir/Registry.html), but you can alternatively use\n[`:global`](http://erlang.org/doc/man/global.html).\n\n```elixir\nconfig :i2c_server,\n  bus_registry_module: :global\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmnishiguchi%2Fi2c_server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmnishiguchi%2Fi2c_server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmnishiguchi%2Fi2c_server/lists"}