{"id":17657364,"url":"https://github.com/azogue/i2csense","last_synced_at":"2025-05-07T11:46:21.352Z","repository":{"id":57437739,"uuid":"94543934","full_name":"azogue/i2csense","owner":"azogue","description":"Another library to handle sensors connected via I2c bus (SDA, SCL pins) to the Raspberry Pi","archived":false,"fork":false,"pushed_at":"2017-06-29T08:38:16.000Z","size":21,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-11T16:13:08.820Z","etag":null,"topics":["home-automation","i2c-bus","i2c-sensors","raspberry-pi","smbus"],"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/azogue.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}},"created_at":"2017-06-16T12:56:57.000Z","updated_at":"2023-03-23T20:35:42.000Z","dependencies_parsed_at":"2022-09-15T11:20:32.860Z","dependency_job_id":null,"html_url":"https://github.com/azogue/i2csense","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azogue%2Fi2csense","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azogue%2Fi2csense/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azogue%2Fi2csense/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azogue%2Fi2csense/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/azogue","download_url":"https://codeload.github.com/azogue/i2csense/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252873937,"owners_count":21817708,"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":["home-automation","i2c-bus","i2c-sensors","raspberry-pi","smbus"],"created_at":"2024-10-23T14:40:29.873Z","updated_at":"2025-05-07T11:46:21.326Z","avatar_url":"https://github.com/azogue.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# i2csense\n\nAnother library to handle sensors connected via **[I2c](https://en.wikipedia.org/wiki/I²C) bus** (SDA, SCL pins) to your **[Raspberry Pi](https://www.raspberrypi.org/)**.\n\nThis library implements the following i2c sensors:\n- **[Bosch BME280 Environmental sensor (temperature, humidity and pressure)](https://cdn-shop.adafruit.com/datasheets/BST-BME280_DS001-10.pdf)**\n- **[HTU21D temperature and humidity sensor](http://www.datasheetspdf.com/PDF/HTU21D/779951/1)**\n- **[BH1750FVI light level sensor](http://cpre.kmutnb.ac.th/esl/learning/bh1750-light-sensor/bh1750fvi-e_datasheet.pdf)**\n\n\n## Installation\n\nThis library needs the **i2c bus** to be enabled, and uses the `smbus-cffi` module to communicate with it, so, before installing with `pip`, make sure the bus is enabled, and the necessary dependencies are available:\n\n### Directions for installing smbus support on Raspberry Pi:\n\nEnable I2c interface with the Raspberry Pi config utility:\n```bash\n# Enable i2c interface\nsudo raspi-config\n```\nSelect `Interfacing options-\u003eI2C` choose `\u003cYes\u003e` and hit `Enter`, then go to `Finish` and you'll be prompted to reboot.\n\nInstall dependencies for use the `smbus-cffi` module and reboot:\n```bash\nsudo apt-get install build-essential libi2c-dev i2c-tools python-dev libffi-dev\nsudo reboot\n```\n\n###### Check the i2c address of the sensors\n\nAfter installing `i2c-tools`, a new utility is available to scan the addresses of the connected sensors:\n\n```bash\n/usr/sbin/i2cdetect -y 1\n```\n\nIt will output a table like this:\n\n```text\n     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f\n00:          -- -- -- -- -- -- -- -- -- -- -- -- --\n10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n20: -- -- -- 23 -- -- -- -- -- -- -- -- -- -- -- --\n30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n70: -- -- -- -- -- -- -- 77\n```\n\nSo you can see three sensors are present at **0x23 (BH1750)**, **0x40 (HTU21D)** and **0x77 (BME280)** addresses.\n\n### Install with pip\n\nFinally, in your python environment,\n\n```bash\npip install i2csense\n```\n\n## Usage\n\nThis library is intended to be used by other applications, where sensors are instantiated with their configuration parameters, to be read at the desired intervals.\nHowever, if you want to use as a simple logger via command line, a simple CLI is also available to test the sensors.\n\n```python\nimport smbus\nfrom i2csense.bme280 import BME280\n\nbus = smbus.Bus(1)\nsensor = BME280(bus)\ndelta_secs = 5\n\nwhile True:\n    sensor.update()\n    if not sensor.sample_ok:\n        print(\"An error has occured\")\n        break\n    print(sensor.current_state_str)\n    sleep(delta_secs)\n```\n\n**CLI usage**\n\nFind sensors:\n\n```bash\ni2csense\n# or specify the i2c bus:\ni2csense -b 0\n```\n\nTest sensors:\n\n```bash\n# Test BME280 sensor with default params:\ni2csense -s bme280\n\n# Test BME280 sensor with custom params every 10 secs:\ni2csense -d 10 --bus 0 --address 0x77 --sensor bme280 --params osrs_t=4 osrs_p=4 osrs_h=4 mode=2 filter_mode=1\n```\n\n## Changelog\n\n  - **v0.0.1**: First release with 3 sensors: **BME280, BH1750, HTU21D**.\n  - **v0.0.2**: Minor fixes.\n  - **v0.0.3**: Minor fixes for `BH1750`, fix `README.rst`.\n  - **v0.0.4**: Soft reset of `HTU21D` after bad sample, to restart sensor.\n\n## TODO:\n\n  - **Append more sensors**.\n  - finish CLI interface with better help and more configuration options.\n\nAlthough the library only covers three sensors, it would be ideal to continue completing it with more sensors or actuators running in the i2c bus, so I encourage you to contribute with more sensors, or to copy, change, edit, or suggest any changes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazogue%2Fi2csense","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazogue%2Fi2csense","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazogue%2Fi2csense/lists"}