{ "info": { "author": "Adafruit Industries", "author_email": "circuitpython@adafruit.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Software Development :: Libraries", "Topic :: System :: Hardware" ], "description": "Introduction\n============\n\n.. image:: https://readthedocs.org/projects/adafruit-circuitpython-hcsr04/badge/?version=latest\n :target: https://circuitpython.readthedocs.io/projects/hcsr04/en/latest/\n :alt: Documentation Status\n\n.. image:: https://img.shields.io/discord/327254708534116352.svg\n :target: https://discord.gg/nBQh6qu\n :alt: Discord\n\n.. image:: https://travis-ci.com/adafruit/Adafruit_CircuitPython_HCSR04.svg?branch=master\n :target: https://travis-ci.com/adafruit/Adafruit_CircuitPython_HCSR04\n :alt: Build Status\n\n.. image:: https://github.com/adafruit/Adafruit_CircuitPython_HCSR04/blob/master/docs/hcsr04.jpg\n :width: 300px\n :alt: HCSR04\n\nThe HC-SR04 is an inexpensive solution for measuring distances using microcontrollers. This library provides a simple\ndriver for controlling these sensors from CircuitPython.\n\nDependencies\n=============\nThis driver depends on:\n\n* `Adafruit CircuitPython `_\n\nPlease ensure all dependencies are available on the CircuitPython filesystem.\nThis is easily achieved by downloading\n`the Adafruit library and driver bundle `_.\n\nUsage Example\n=============\n\n.. warning::\n\n The HC-SR04 uses 5V logic, so you will have to use a `level shifter\n `_ between it\n and your CircuitPython board (which uses 3.3V logic).\n\n.. note::\n\n If you want to use an HC-SR04 with `MicroPython `_, I recommend checking out `this library\n `_.\n\nYou'll need to dedicate two pins to communicating with the HC-SR04. The sensor communicates in a very rudimentary\nmanner, so it doesn't matter which pins you choose, as long as they're digital IO pins (pins that start with \"``D``\"\nare digital).\n\nThere are two ways of instantiating a :class:`~hcsr04.HCSR04` object: with or without using a context manager.\n\n.. note::\n\n It is technically possible to communicate with the HC-SR04 using only one wire since the trigger and echo signals\n aren't ever active at the same time. Once I have a chance to determine a safe way to do this, I plan to add this as\n a feature to the library.\n\n.. seealso::\n\n `Adafruit's guide on Lifetime and ContextManagers `_\n Gives more info on using context managers with CircuitPython drivers.\n\n :any:`board`\n A list of pins available on your device. To view this list, first `get a REPL\n `_ (the guide linked was written\n for the pyboard, but it still works), then input the following:\n\n ::\n\n import board\n dir(board)\n\nWithout a Context Manager\n-------------------------\n\nIn the example below, we create the :class:`~hcsr04.HCSR04` object directly, get the distance every 2 seconds, then\nde-initialize the device.\n\n::\n\n from hcsr04 import HCSR04\n sonar = HCSR04(trig, echo)\n try:\n while True:\n print(sonar.dist_cm())\n sleep(2)\n except KeyboardInterrupt:\n pass\n sonar.deinit()\n\n\nWith a Context Manager\n----------------------\n\nIn the example below, we use a context manager (the :any:`with ` statement) to create the :class:`~hcsr04.HCSR04`\ninstance, again get the distance every 2 seconds, but then the context manager handles de-initializing the device for\nus.\n\n::\n\n from hcsr04 import HCSR04\n with HCSR04(trig, echo) as sonar:\n try:\n while True:\n print(sonar.dist_cm())\n sleep(2)\n except KeyboardInterrupt:\n pass\n\n\nContributing\n============\n\nContributions are welcome! Please read our `Code of Conduct\n`_\nbefore contributing to help this project stay welcoming.\n\nBuilding locally\n================\n\nZip release files\n-----------------\n\nTo build this library locally you'll need to install the\n`circuitpython-build-tools `_ package.\n\n.. code-block:: shell\n\n python3 -m venv .env\n source .env/bin/activate\n pip install circuitpython-build-tools\n\nOnce installed, make sure you are in the virtual environment:\n\n.. code-block:: shell\n\n source .env/bin/activate\n\nThen run the build:\n\n.. code-block:: shell\n\n circuitpython-build-bundles --filename_prefix adafruit-circuitpython-hcsr04 --library_location .\n\nSphinx documentation\n-----------------------\n\nSphinx is used to build the documentation based on rST files and comments in the code. First,\ninstall dependencies (feel free to reuse the virtual environment from above):\n\n.. code-block:: shell\n\n python3 -m venv .env\n source .env/bin/activate\n pip install Sphinx sphinx-rtd-theme\n\nNow, once you have the virtual environment activated:\n\n.. code-block:: shell\n\n cd docs\n sphinx-build -E -W -b html . _build/html\n\nThis will output the documentation to ``docs/_build/html``. Open the index.html in your browser to\nview them. It will also (due to -W) error out on any warning like Travis will. This is a good way to\nlocally verify it will pass.", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/adafruit/Adafruit_CircuitPython_HCSR04", "keywords": "adafruit hcsr04 hardware micropython circuitpython ultrasonic", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "adafruit-circuitpython-hcsr04", "package_url": "https://pypi.org/project/adafruit-circuitpython-hcsr04/", "platform": "", "project_url": "https://pypi.org/project/adafruit-circuitpython-hcsr04/", "project_urls": { "Homepage": "https://github.com/adafruit/Adafruit_CircuitPython_HCSR04" }, "release_url": "https://pypi.org/project/adafruit-circuitpython-hcsr04/0.3.4/", "requires_dist": null, "requires_python": "", "summary": "CircuitPython library for controlling HC-SR04 ultrasonic range sensors.", "version": "0.3.4" }, "last_serial": 4696680, "releases": { "0.3.3": [ { "comment_text": "", "digests": { "md5": "2a423d7c61da2fe99ae0c369fa26689d", "sha256": "62c5a2671316def35ceac791c055ae45af8ab200e7ac679d3b786a1e30ec1f55" }, "downloads": -1, "filename": "adafruit-circuitpython-hcsr04-0.3.3.tar.gz", "has_sig": false, "md5_digest": "2a423d7c61da2fe99ae0c369fa26689d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 328067, "upload_time": "2018-10-02T21:48:49", "url": "https://files.pythonhosted.org/packages/e5/a7/3556c46d179e03663923c1ed18eadaa88f9a64e9dcba14f77d9fa9ef9ac1/adafruit-circuitpython-hcsr04-0.3.3.tar.gz" } ], "0.3.4": [ { "comment_text": "", "digests": { "md5": "8719c8d7c933f93fcd121a7dad480e0f", "sha256": "8b32db8c065b2a8b55429f5976c7e8c178cfb673deffec8a1f8393cc0bbe30e5" }, "downloads": -1, "filename": "adafruit-circuitpython-hcsr04-0.3.4.tar.gz", "has_sig": false, "md5_digest": "8719c8d7c933f93fcd121a7dad480e0f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 325367, "upload_time": "2019-01-15T00:22:04", "url": "https://files.pythonhosted.org/packages/49/9f/c4b141709a9352cfffd83f0d6b76945bfe06be387a1bae23e8f6f43525aa/adafruit-circuitpython-hcsr04-0.3.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8719c8d7c933f93fcd121a7dad480e0f", "sha256": "8b32db8c065b2a8b55429f5976c7e8c178cfb673deffec8a1f8393cc0bbe30e5" }, "downloads": -1, "filename": "adafruit-circuitpython-hcsr04-0.3.4.tar.gz", "has_sig": false, "md5_digest": "8719c8d7c933f93fcd121a7dad480e0f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 325367, "upload_time": "2019-01-15T00:22:04", "url": "https://files.pythonhosted.org/packages/49/9f/c4b141709a9352cfffd83f0d6b76945bfe06be387a1bae23e8f6f43525aa/adafruit-circuitpython-hcsr04-0.3.4.tar.gz" } ] }