{ "info": { "author": "Mark A Heywood", "author_email": "mark@shinex.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Intended Audience :: End Users/Desktop", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: Home Automation", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: System :: Hardware" ], "description": "Ultrasonic HC-SR04 Sensor Python Library for Raspberry Pi GPIO\n==============================================================\n\nThis sensor uses sound waves to provide a means to measure the \ndistance between the sensor and an object. It is not the most \naccurate distance sensor available, but many projects do not \nneed pinpoint accuracy. After a quick look at Banggood website, \nyou can get five HC-SR04 sensors for 5.07 GBP (6.86 USD). And \nwhile the sensor is not the most compact, its low price means \na robot vehicle can have a full sensor kit fitted very cheaply.\n\nYou can find the article here for more details:\n\n`Article `__.\n\nExample Code\n------------\n\nSimplest Program for Distance Measuring:\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n # Import necessary libraries.\n from Bluetin_Echo import Echo\n\n # Define GPIO pin constants.\n TRIGGER_PIN = 16\n ECHO_PIN = 12\n # Initialise Sensor with pins, speed of sound.\n speed_of_sound = 315\n echo = Echo(TRIGGER_PIN, ECHO_PIN, speed_of_sound)\n # Measure Distance 5 times, return average.\n samples = 5\n result = echo.read('cm', samples)\n # Print result.\n print(result, 'cm')\n # Reset GPIO Pins.\n echo.stop()\n\nExample for Taking Multiple Distance Measurements:\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n \"\"\"File: echo_loop.py\"\"\"\n # Import necessary libraries.\n from Bluetin_Echo import Echo\n\n # Define GPIO pin constants.\n TRIGGER_PIN = 16\n ECHO_PIN = 12\n # Initialise Sensor with pins, speed of sound.\n speed_of_sound = 315\n echo = Echo(TRIGGER_PIN, ECHO_PIN, speed_of_sound)\n # Measure Distance 5 times, return average.\n samples = 5\n # Take multiple measurements.\n for counter in range(0, 10):\n result = echo.read('cm', samples)\n # Print result.\n print(result, 'cm')\n\n # Reset GPIO Pins.\n echo.stop()\n\nLoop Through Multiple Sensors\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n \"\"\"File: echo_multi_sensor.py\"\"\"\n # Import necessary libraries.\n from time import sleep\n\n from Bluetin_Echo import Echo\n\n # Define pin constants\n TRIGGER_PIN_1 = 16\n ECHO_PIN_1 = 12\n TRIGGER_PIN_2 = 26\n ECHO_PIN_2 = 19\n\n # Initialise two sensors.\n echo = [Echo(TRIGGER_PIN_1, ECHO_PIN_1)\n , Echo(TRIGGER_PIN_2, ECHO_PIN_2)]\n\n def main():\n sleep(0.1)\n for counter in range(1, 6):\n for counter2 in range(0, len(echo)):\n result = echo[counter2].read('cm', 3)\n print('Sensor {} - {} cm'.format(counter2, round(result,2)))\n\n echo[0].stop()\n\n if __name__ == '__main__':\n main()\n\n\nLibrary v0.2.0\n--------------\n\nTest All Library Features\n~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n\t#!/usr/bin/env python3\n\n\tfrom time import sleep\n\tfrom Bluetin_Echo import Echo\n\n\t\"\"\" Define GPIO pin constants \"\"\"\n\tTRIGGER_PIN = 17\n\tECHO_PIN = 18\n\t\"\"\" Calibrate sensor with initial speed of sound m/s value \"\"\"\n\tSPEED_OF_SOUND = 343\n\t\"\"\" Initialise Sensor with pins, speed of sound. \"\"\"\n\techo = Echo(TRIGGER_PIN, ECHO_PIN, SPEED_OF_SOUND)\n\n\n\tdef main():\n\t\t\"\"\"\n\t\tTest class properties and methods.\n\t\t\"\"\"\n\n\t\tprint('\\n+++++ Properties +++++\\n')\n\n\t\t\"\"\"\n\t\tCheck that the sensor is ready to operate.\n\t\t\"\"\"\n\t\tprint('Sensor ready? {}'.format(echo.is_ready))\n\t\tsleep(0.06)\n\t\tprint('Sensor ready? {}'.format(echo.is_ready))\n\n\t\t\"\"\"\n\t\tYou can adjust the speed of sound to fit environmental conditions.\n\t\t\"\"\"\n\t\tspeed = echo.speed\n\t\tprint('Speed of sound Setting: {}m/s'.format(speed))\n\t\techo.speed = speed\n\n\t\t\"\"\"\n\t\tThis setting is important because it allows a rest period between\n\t\teach sensor activation. Accessing the sensor within a rest period\n\t\twill result in a Not Ready (2) error code. Reducing the value of\n\t\tthis setting can cause unstable sensor readings.\n\t\t\"\"\"\n\t\trestTime = echo.rest\n\t\tprint('Sensor rest time: {}s'.format(restTime))\n\t\techo.rest = restTime\n\n\t\t\"\"\"\n\t\tThe default is fine for this property. This timeout prevents the\n\t\tcode from getting stuck in an infinite loop in case the sensor\n\t\ttrigger pin fails to change state.\n\t\t\"\"\"\n\t\ttriggerTimeout = echo.trigger_timeout\n\t\tprint('Sensor trigger timeout: {}s'.format(triggerTimeout))\n\t\techo.trigger_timeout = triggerTimeout\n\n\t\t\"\"\"\n\t\tRead and update sensor echo timeout.\n\t\tThe is an alternative way to set a maximum sensor scan distance\n\t\tusing a time value.\n\t\t\"\"\"\n\t\techoTimeout = echo.echo_timeout\n\t\tprint('Sensor echo timeout: {}s'.format(echoTimeout))\n\t\techo.echo_timeout = echoTimeout\n\n\t\t\"\"\"\n\t\tThis property adds a time offset to the max sensor distance\n\t\tsetting. Adjust this property value to stop the sensor out of range\n\t\terror appearing below the maximum distance setting during operation.\n\t\t\"\"\"\n\t\techoOffset = echo.echo_return_offset\n\t\tprint('Sensor echo time offset: {}s'.format(echoOffset))\n\t\techo.echo_return_offset = echoOffset\n\n\t\t\"\"\"\n\t\tRead this property to get the error code following a sensor read.\n\t\tThe error codes are integer values; 0 = Good, 1 = Out of Range and\n\t\t2 = Not Ready.\n\t\t\"\"\"\n\t\terrorCode = echo.error_code\n\t\tprint('Error code from last sensor read: {}'.format(errorCode))\n\n\t\t\"\"\"\n\t\tThe default sensor scan distance is set to 3m. The following property\n\t\twill allow an alternate max scan distance setting. Any sensor echos\n\t\tthat fall outside the set distance will cause an out of range error.\n\t\tUnits mm, cm, m and inch are supported.\n\t\tYou can tune the sensor to match the max distance setting using the\n\t\techo_return_offset property.\n\t\t\"\"\"\n\t\techo.max_distance(30, 'cm')\n\n\t\t\"\"\"\n\t\tThis property sets the default measuring unit, which works with\n\t\tthe new send and samples methods. Set this property once with your \n\t\tprefered unit of measure. Then use the send method to return sensor\n\t\tresults in that unit you set. Class default is cm on initialisation.\n\t\t\"\"\"\n\t\tdefaultUnit = echo.default_unit\n\t\tprint('Current Unit Setting: {}'.format(defaultUnit))\n\t\techo.default_unit = defaultUnit\n\n\t\t\"\"\"\n\t\tTest using each unit of measure.\n\t\t\"\"\"\n\t\tprint('\\n+++++ Single sample sensor reads. +++++\\n')\n\t\tsleep(0.06)\n\t\taverageOf = 1\n\t\tresult = echo.read('mm', averageOf)\n\t\tprint('{:.2f} mm, Error: {}'.format(result, echo.error_code))\n\t\tsleep(0.06)\n\t\tresult = echo.read('cm', averageOf)\n\t\tprint('{:.2f} cm, Error: {}'.format(result, echo.error_code))\n\t\tsleep(0.06)\n\t\tresult = echo.read('m', averageOf)\n\t\tprint('{:.2f} m, Error: {}'.format(result, echo.error_code))\n\t\tsleep(0.06)\n\t\tresult = echo.read('inch', averageOf)\n\t\tprint('{:.2f} inch, Error: {}'.format(result, echo.error_code))\n\n\t\t\"\"\"\n\t\tThen, get an average of multiple reads.\n\t\t\"\"\"\n\t\tprint('\\n+++++ Return an average of multiple sensor reads. +++++\\n')\n\t\tsleep(0.06)\n\t\taverageOf = 10\n\t\tresult = echo.read('mm', averageOf)\n\t\tprint('Average: {:.2f} mm'.format(result))\n\t\tsleep(0.06)\n\t\tresult = echo.read('cm', averageOf)\n\t\tprint('Average: {:.2f} cm'.format(result))\n\t\tsleep(0.06)\n\t\tresult = echo.read('m', averageOf)\n\t\tprint('Average: {:.2f} m'.format(result))\n\t\tsleep(0.06)\n\t\tresult = echo.read('inch', averageOf)\n\t\tprint('Average: {:.2f} inch'.format(result))\n\n\t\t\"\"\"\n\t\tGet a single sensor read using the default unit of measure.\n\t\tCheck error codes after each sensor reading to monitor operation\n\t\tsuccess.\n\t\t\"\"\"\n\t\tprint('\\n+++++ Single sensor read using the default unit of measure. +++++\\n')\n\t\tsleep(0.06)\n\t\techo.default_unit = 'm'\n\t\tresult = echo.send()\n\t\tprint('{:.2f} m, Error: {}'.format(result, echo.error_code))\n\n\t\t\"\"\"\n\t\tGet an average value from multiple sensor readings. Returns an average of\n\t\tonly the good sensor reads. The average value is returned with\n\t\tthe number of samples used to make the average sum calculation.\n\t\t\"\"\"\n\t\tprint('\\n+++++ Return an average from multiple sensor reads. +++++')\n\t\tprint('+++++ Returns two values; average and good samples. +++++\\n')\n\t\tsleep(0.06)\n\t\techo.default_unit = 'm'\n\t\tresult, samples = echo.samples(10)\n\t\tprint('Average: {:.2f} m, From {} good samples'.format(result, samples))\n\n\t\t\"\"\" Reset GPIO Pins. \"\"\"\n\t\techo.stop()\n\n\n\tif __name__ == \"__main__\":\n\t\tmain()\n\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/MarkAHeywood/Bluetin_Python_Echo", "keywords": "RPI,GPIO,Raspberry Pi,Ultrasonic,HC-SR04,Transducer,Distance Measuring,Sensor", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "Bluetin-Echo", "package_url": "https://pypi.org/project/Bluetin-Echo/", "platform": "", "project_url": "https://pypi.org/project/Bluetin-Echo/", "project_urls": { "Homepage": "https://github.com/MarkAHeywood/Bluetin_Python_Echo" }, "release_url": "https://pypi.org/project/Bluetin-Echo/0.2.0/", "requires_dist": [ "RPi.GPIO" ], "requires_python": "", "summary": "Raspberry Pi Python Library for Ultrasonic Module HC-SR04 Distance Measuring Transducer.", "version": "0.2.0" }, "last_serial": 5377715, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "886696ac18195fe7b95daa4f92f64e2a", "sha256": "a654678f7b4158555511edceddc93560ee47d2714ff0b5c89ef1a3415c81d8f3" }, "downloads": -1, "filename": "Bluetin_Echo-0.1.0.tar.gz", "has_sig": false, "md5_digest": "886696ac18195fe7b95daa4f92f64e2a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3041, "upload_time": "2018-03-06T00:50:24", "url": "https://files.pythonhosted.org/packages/e9/dc/3ff43d7c7dcd0a2a261de8f0d0c3734f59adb97f534cbd1f9740fa483338/Bluetin_Echo-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "5334650e3bda7d979c86d7659702054e", "sha256": "7a5387fd932adc7b65b5dcc6906bc87813c04de36486eae69923c5df5a3c2c05" }, "downloads": -1, "filename": "Bluetin_Echo-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "5334650e3bda7d979c86d7659702054e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6773, "upload_time": "2018-03-09T17:20:44", "url": "https://files.pythonhosted.org/packages/7a/d1/58f7d497df7c1543650798c7f8c4129c603db3cdcfecb3dbfcde602d1253/Bluetin_Echo-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f71ac97f18fc8a3440a8d57e68904362", "sha256": "40aabf86ddb3df1444dc2c7230be20d0f39d135d002c9da8e81ec5038644d4b2" }, "downloads": -1, "filename": "Bluetin_Echo-0.1.1.tar.gz", "has_sig": false, "md5_digest": "f71ac97f18fc8a3440a8d57e68904362", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4951, "upload_time": "2018-03-09T17:20:46", "url": "https://files.pythonhosted.org/packages/dd/74/21ec2dc64d983160ae3ff6e2f4efbb748fe4431f7a22aeb924f05f837b17/Bluetin_Echo-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "98610b76eed14dc4f99f198f47417b17", "sha256": "abf9c0d37a9bd84a8fe6824d63b46b5a9d7546a1381134813cae9fbba7bb0679" }, "downloads": -1, "filename": "Bluetin_Echo-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "98610b76eed14dc4f99f198f47417b17", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8672, "upload_time": "2019-06-09T13:34:54", "url": "https://files.pythonhosted.org/packages/1d/7d/5ad3e2a10ff13a14b29310734b3fdd1e5e2b38cae7b8ccec4df782caad37/Bluetin_Echo-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c7204ab23e1a10c51b9fc2e9f70f6462", "sha256": "edc5c0ba50bd4d430f12a5f16af501ee90eeddbc25d8fcd1a18801c3970184cf" }, "downloads": -1, "filename": "Bluetin_Echo-0.2.0.tar.gz", "has_sig": false, "md5_digest": "c7204ab23e1a10c51b9fc2e9f70f6462", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7876, "upload_time": "2019-06-09T13:34:56", "url": "https://files.pythonhosted.org/packages/e6/c9/5f67b9fa933ad9d3ead886f2c007a11880d1970abaf5d1dd90bac8d2aad6/Bluetin_Echo-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "98610b76eed14dc4f99f198f47417b17", "sha256": "abf9c0d37a9bd84a8fe6824d63b46b5a9d7546a1381134813cae9fbba7bb0679" }, "downloads": -1, "filename": "Bluetin_Echo-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "98610b76eed14dc4f99f198f47417b17", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8672, "upload_time": "2019-06-09T13:34:54", "url": "https://files.pythonhosted.org/packages/1d/7d/5ad3e2a10ff13a14b29310734b3fdd1e5e2b38cae7b8ccec4df782caad37/Bluetin_Echo-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c7204ab23e1a10c51b9fc2e9f70f6462", "sha256": "edc5c0ba50bd4d430f12a5f16af501ee90eeddbc25d8fcd1a18801c3970184cf" }, "downloads": -1, "filename": "Bluetin_Echo-0.2.0.tar.gz", "has_sig": false, "md5_digest": "c7204ab23e1a10c51b9fc2e9f70f6462", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7876, "upload_time": "2019-06-09T13:34:56", "url": "https://files.pythonhosted.org/packages/e6/c9/5f67b9fa933ad9d3ead886f2c007a11880d1970abaf5d1dd90bac8d2aad6/Bluetin_Echo-0.2.0.tar.gz" } ] }