{ "info": { "author": "Ole Weidner, Codewerft UG (haftungsbeschraenkt)", "author_email": "ole.weidner@codewerft.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Software Development :: Build Tools" ], "description": "# I2CRelay: A Python library and command line tool to control PCF8574 I2C relay boards\n\nI2CRelay is a small Python library that provides a simple API for controlling\nmultiple relay boards that are connected to a PCF8574 I2C I/O expander.\n\nThis library was tested with the following hardware:\n\n- PCF8574 I2C I/O Expansion Board (http://a.co/bdogwFe)\n- SainSmart 8-Channel Relay Module (http://a.co/48AtFQ6)\n\nYou can solder these into a single unit like this:\n\n[![Relay Board](https://raw.githubusercontent.com/oweidner/i2crelay/media/img/relay_small.jpeg)](https://raw.githubusercontent.com/oweidner/i2crelay/media/img/relay_fullsize.jpg)\n\n## Installation\n\nTo install the latest version from GitHub:\n\n git clone -b master --single-branch https://github.com/oweidner/i2crelay.git\n cd i2crelay\n pip install --upgrade .\n\n## Command-Line Tool\n\nTogether with the Python module installs the `i2crelay` command line tool:\n\n Usage: i2crelay [OPTIONS] [CMDS]...\n\n Control a PCF8574 I2C relay board.\n\n Options:\n --i2c-bus INTEGER The I2C bus (0 or 1) [required]\n --i2c-addr TEXT The I2C device address, e.g. 0x20 [required]\n --help Show this message and exit.\n\n For example, run this command to switch on relay 1 and 2, switch off relay 3 and toggle relay 8:\n\n i2crelay --i2c-bus=1 --i2c-addr=0x20 1:on 3:off 2:on 8:toggle\n\n## API Example\n\n from i2crelay import I2CRelayBoard\n\n # define I2C bus type\n # 0: Raspberry Pi Model B Rev 1.0\n # 1: Raspberry Pi Model B Rev 2.0, Model A, Model B+, Model A+, Raspberry Pi 2 Model B and Raspberry Pi 3 Model B\n I2C_BUS = 1\n\n # define I2C address of PCF8574 8-Bit I/O expander\n # depends on the hardware pins A0 - A2\n I2C_ADDR = 0x20\n\n r1 = I2CRelayBoard(I2C_BUS, I2C_ADDR)\n\n r1.switch_all_on()\n time.sleep(1.0)\n\n r1.switch_all_off()\n time.sleep(1.0)\n\n for relay in range(1, 9):\n print(\"Switching relay {}\".format(relay))\n r1.switch_on(relay)\n time.sleep(0.5)\n r1.switch_off(relay)\n time.sleep(0.5)\n\nThe code above should result in something like this:\n\n![relay_test](https://raw.githubusercontent.com/oweidner/i2crelay/media/vid/relay_test.gif)\n\n### Other Examples\n\nThe `examples` directory contains a few additional examples:\n\n* [rest_api.py](examples/rest_api.py) - A simple REST API example with Flask\n\n## I2C Device Setup\n\n### Bus and Device Numbers\n\nOn Linux you can use the `i2cdetect` tool to figure out bus and device numbers:\n\nTo find out the I2C bus number, run:\n\n i2cdetect -l\n\n i2c-1\ti2c \tbcm2835 I2C adapter \tI2C adapter\n\nTo find out the I2C device number, run:\n\n i2cdetect -y 1\n\n 0 1 2 3 4 5 6 7 8 9 a b c d e f\n 00: -- -- -- -- -- -- -- -- -- -- -- -- --\n 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n 20: 20 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n 70: -- -- -- -- -- -- -- --\n\n### Device Permissions\n\nThe user running the scripts needs access to the i2c devices in the Linux\ndevice tree. Instead of running the scripts as root you can add your user to the\ni2c group.\n\n## License\n\nThis program is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation; either version 2 of the License, or\n(at your option) any later version.\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/oweidner/i2crelay", "keywords": "relay i2c pcf8574 raspberry automation", "license": "GPL-2.0", "maintainer": "", "maintainer_email": "", "name": "i2crelay", "package_url": "https://pypi.org/project/i2crelay/", "platform": "", "project_url": "https://pypi.org/project/i2crelay/", "project_urls": { "Homepage": "https://github.com/oweidner/i2crelay" }, "release_url": "https://pypi.org/project/i2crelay/0.1.0/", "requires_dist": [ "smbus2", "click", "check-manifest; extra == 'dev'", "coverage; extra == 'test'" ], "requires_python": "", "summary": "A library and command line tool to control PCF8574 I2C relay boards", "version": "0.1.0" }, "last_serial": 3074837, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "eb95c51e8854a751196a4acd349f0b05", "sha256": "e01b823b5d91a89fb3f65b8d9f86d6654f0077caf7ba9ca7526a501de3dd6435" }, "downloads": -1, "filename": "i2crelay-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "eb95c51e8854a751196a4acd349f0b05", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7971, "upload_time": "2017-08-05T12:43:06", "url": "https://files.pythonhosted.org/packages/b0/d2/1d2ae70954297f3839bf4a158f5595840a2857ba784586c06ac8175b04a0/i2crelay-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c6b8a410788cb3a8f2c7763eaa5d9e1e", "sha256": "0f46a4207d5d089bc60ee886f270cc5ab7cd9ed8ef90fc9e76fca05d365bbf52" }, "downloads": -1, "filename": "i2crelay-0.1.0.tar.gz", "has_sig": false, "md5_digest": "c6b8a410788cb3a8f2c7763eaa5d9e1e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10805, "upload_time": "2017-08-05T12:43:07", "url": "https://files.pythonhosted.org/packages/a2/f4/08fe21d52e9c0f7acdc7f5e3ceeae6ef09d6616855657bb38ffbfda6aedc/i2crelay-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "eb95c51e8854a751196a4acd349f0b05", "sha256": "e01b823b5d91a89fb3f65b8d9f86d6654f0077caf7ba9ca7526a501de3dd6435" }, "downloads": -1, "filename": "i2crelay-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "eb95c51e8854a751196a4acd349f0b05", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7971, "upload_time": "2017-08-05T12:43:06", "url": "https://files.pythonhosted.org/packages/b0/d2/1d2ae70954297f3839bf4a158f5595840a2857ba784586c06ac8175b04a0/i2crelay-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c6b8a410788cb3a8f2c7763eaa5d9e1e", "sha256": "0f46a4207d5d089bc60ee886f270cc5ab7cd9ed8ef90fc9e76fca05d365bbf52" }, "downloads": -1, "filename": "i2crelay-0.1.0.tar.gz", "has_sig": false, "md5_digest": "c6b8a410788cb3a8f2c7763eaa5d9e1e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10805, "upload_time": "2017-08-05T12:43:07", "url": "https://files.pythonhosted.org/packages/a2/f4/08fe21d52e9c0f7acdc7f5e3ceeae6ef09d6616855657bb38ffbfda6aedc/i2crelay-0.1.0.tar.gz" } ] }