{"id":28381346,"url":"https://github.com/timboring/atlas_i2c","last_synced_at":"2025-06-25T02:32:03.294Z","repository":{"id":57412372,"uuid":"233341846","full_name":"timboring/atlas_i2c","owner":"timboring","description":"Package for communicating with Atlas Scientific devices over I2C","archived":false,"fork":false,"pushed_at":"2024-03-20T15:31:53.000Z","size":46,"stargazers_count":8,"open_issues_count":7,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-06T04:16:35.101Z","etag":null,"topics":["i2c-sensors","iot","python3"],"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/timboring.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-01-12T05:12:43.000Z","updated_at":"2025-04-16T19:03:28.000Z","dependencies_parsed_at":"2025-05-30T04:04:55.452Z","dependency_job_id":"ef6a5633-e2b0-4032-96f4-0a37cbe763df","html_url":"https://github.com/timboring/atlas_i2c","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/timboring/atlas_i2c","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timboring%2Fatlas_i2c","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timboring%2Fatlas_i2c/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timboring%2Fatlas_i2c/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timboring%2Fatlas_i2c/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timboring","download_url":"https://codeload.github.com/timboring/atlas_i2c/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timboring%2Fatlas_i2c/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261791024,"owners_count":23210082,"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-sensors","iot","python3"],"created_at":"2025-05-30T04:04:50.322Z","updated_at":"2025-06-25T02:32:03.282Z","avatar_url":"https://github.com/timboring.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Continuous integration](https://github.com/timboring/atlas_i2c/workflows/Continuous%20integration/badge.svg) ![Continous delivery](https://github.com/timboring/atlas_i2c/workflows/Continous%20delivery/badge.svg)\n\n# AtlasI2C: A Python package to communicate with Atlas Scientific devices in I2C mode.\n\nThis package provides functionality that is based on the [example code](https://github.com/AtlasScientific/Raspberry-Pi-sample-code) from Atlas Scientific. It has the following goals:\n\n1. Provide a simple and clean codebase with test coverage\n2. Reduce code duplication by making the codebase available from PyPi\n3. Provide comprehensive support for Atlas Scientific EZO sensors\n\n# Overview\nThis package provides the following modules:\n\n- [atlas_i2c](https://github.com/timboring/atlas_i2c/blob/master/src/atlas_i2c/atlas_i2c.py)\n- [commands](https://github.com/timboring/atlas_i2c/blob/master/src/atlas_i2c/commands.py)\n- [constants](https://github.com/timboring/atlas_i2c/blob/master/src/atlas_i2c/constants.py)\n- [sensors](https://github.com/timboring/atlas_i2c/blob/master/src/atlas_i2c/sensors.py)\n\n## module: atlas_i2c\nThe `atlas_i2c` module can be thought of as the client that talks to the server, similar to how an HTTP client talks to an HTTP server. The server in this scenario is the Atlas Scientfic EZO sensor. Instead of talking over TCP using HTTP, however, it talks to the server over the I2C bus, using Linux device files (e.g. `/dev/i2c-1`).\n\nThe module uses the following protocol to communicate with a sensor:\n1. Open the device file for reading and writing\n2. Send a command string (e.g. \"R\") to the device by writing it to the device file\n3. Wait for N milliseconds for the sensor to process the command\n4. Read the resulting data from the device file\n\nAt the lowest level, this module's `read()` and `write()` methods can be combined with `time.sleep()`  to communicate with a sensor:\n```py\nIn [1]: from atlas_i2c import atlas_i2c\nIn [2]: sensor_address = 102\nIn [3]: dev = atlas_i2c.AtlasI2C()\nIn [4]: dev.set_i2c_address(sensor_address)\nIn [5]: dev.write(\"R\")\nIn [6]: time.sleep(1.5)\nIn [15]: result = dev.read(\"R\")\nIn [16]: result.status_code\nOut[16]: 1\nIn [17]: result.data\nOut[17]: b'0.922'\nIn [18]: result.original_cmd\nOut[18]: 'R'\n```\n\nThe module also provides a `query()` method to conveniently wrap the above protocol into a single method:\n\n```py\nIn [19]: result = dev.query(\"R\", processing_delay=1500)\nIn [20]: result.status_code\nOut[20]: 1\nIn [21]: result.data\nOut[21]: b'0.926'\nIn [22]: result.original_cmd\nOut[22]: 'R'\n```\n\nThe result of calling the `read()` and `query()` methods in the above code snippets is a `CommandReponse` object. Here is an example of creating a `CommandResponse` object manually and populating it:\n```py\nIn [1]: from atlas_i2c import atlas_i2c\nIn [2]: response = atlas_i2c.CommandResponse()\nIn [3]: response\nOut[3]: \u003catlas_i2c.atlas_i2c.CommandResponse at 0x7fbd40f48370\u003e\nIn [6]: response.sensor_address = 10\nIn [7]: response.sensor_address = 102\nIn [8]: response.original_cmd = \"R\"\nIn [9]: response.response_type = \"str\"\nIn [10]: response.status_code = raw_data[0] \n```\n\n## module: commands\nThe `commands` module provides encapsulations intended to simplify interactions with sensors. Command attributes and methods can be accessed at the class level, thus it's not necessary to instantiate a command.\n\nThe module defines constants for each command class:\n```py\nIn [19]: from atlas_i2c import commands\n# To find the arguments a command supports:\nIn [24]: commands.BAUD.arguments\nOut[24]: (300, 1200, 2400, 9600, 19200, 38400, 57600, 115200)\n# To get a formatted command string:\nIn [25]: commands.BAUD.format_command(300)\nOut[25]: 'Baud,300'\n# A command may not support any arguments:\nIn [24]: commands.READ.arguments\nIn [25]:\n```\nNot all commands have been implemented. The `format_command` method on unimplemented commands will raise a `NotImplementedError` exception.\n\n## module: sensors\nThe `sensors` module provides a higher-level encapsulation of a sensor in the form of the `Sensor` class. The intention is that the `Sensor` class is used as the primary means of communication; it uses the lower-level `AtlasI2C` class to perform all functions, such as reading data from a sensor.\n\n```py\nIn [25]: from atlas_i2c import sensors\nIn [26]: sensor = sensors.Sensor(\"Temperature\", 102)\nIn [27]: sensor.connect()\nIn [28]: response = sensor.query(commands.READ)\nIn [29]: response.status_code\nOut[29]: 1\nIn [30]: response.data\nOut[30]: b'0.923'\nIn [31]: response.original_cmd\nOut[31]: 'R'\n```\n\n# Supported Python Versions\nThis module requires Python \u003e= 3.6.\n\n# Tests\n`atlas_i2c` uses Tox for test automation, which includes linting, formatting and static type checking. To run Tox:\n\n```sh\n\u003e tox\n[output truncated]\npy38: commands succeeded\npy37: commands succeeded\npy36: commands succeeded\nmypy: commands succeeded\nlint: commands succeeded\nformat: commands succeeded\ncongratulations :)\n```\n\n# Installation\n## From PyPi\nInstallation can be done using Pip:\n\n```sh\n\u003e pip install atlas-i2c\n```\n\n## From source\n```sh\n\u003e python setup.py bdist_wheel\n\u003e pip install dist/atlas_i2c-$version-py3-none-any.whl\n```\n\n# Atlas Scientific Sensor Datasheets\n- [pH](https://www.atlas-scientific.com/files/pH_EZO_Datasheet.pdf)\n- [temp](https://www.atlas-scientific.com/files/EZO_RTD_Datasheet.pdf)\n- [orp](https://www.atlas-scientific.com/files/ORP_EZO_Datasheet.pdf)\n- [do](https://www.atlas-scientific.com/files/DO_EZO_Datasheet.pdf)\n- [ec](https://www.atlas-scientific.com/files/EC_EZO_Datasheet.pdf)\n- [co2](https://www.atlas-scientific.com/files/EZO_CO2_Datasheet.pdf)\n- [flo](https://www.atlas-scientific.com/files/flow_EZO_Datasheet.pdf)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimboring%2Fatlas_i2c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimboring%2Fatlas_i2c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimboring%2Fatlas_i2c/lists"}