wiringpi


Namewiringpi JSON
Version 2.60.1 PyPI version JSON
download
home_pagehttps://github.com/WiringPi/WiringPi-Python/
SummaryA python interface to WiringPi 2.0 library which allows for easily interfacing with the GPIO pins of the Raspberry Pi. Also supports i2c and SPI.
upload_time2021-02-20 05:53:57
maintainer
docs_urlNone
authorPhilip Howard
requires_python
licenseLGPL
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Note
~~~~

This is an unofficial port of Gordon's WiringPi library. Please do not
email Gordon if you have issues, he will not be able to help.

For support, comments, questions, etc please join the WiringPi Discord
channel: https://discord.gg/SM4WUVG

WiringPi for Python
===================

WiringPi: An implementation of most of the Arduino Wiring functions for
the Raspberry Pi.

WiringPi implements new functions for managing IO expanders.

Quick Install
=============

.. image:: https://badge.fury.io/py/wiringpi.svg
   :alt: PyPI version badge
   :target: https://pypi.org/project/wiringpi/

The library is packaged on PyPI and can be installed with pip:

``pip install wiringpi``

Usage
=====

.. code:: python

    import wiringpi

    # One of the following MUST be called before using IO functions:
    wiringpi.wiringPiSetup()      # For sequential pin numbering
    # OR
    wiringpi.wiringPiSetupSys()   # For /sys/class/gpio with GPIO pin numbering
    # OR
    wiringpi.wiringPiSetupGpio()  # For GPIO pin numbering

**General IO:**

.. code:: python

    wiringpi.pinMode(6, 1)       # Set pin 6 to 1 ( OUTPUT )
    wiringpi.digitalWrite(6, 1)  # Write 1 ( HIGH ) to pin 6
    wiringpi.digitalRead(6)      # Read pin 6

**Setting up a peripheral:**

WiringPi supports expanding your range of available "pins" by setting up
a port expander. The implementation details of your port expander will
be handled transparently, and you can write to the additional pins
(starting from PIN\_OFFSET >= 64) as if they were normal pins on the Pi.

.. code:: python

    wiringpi.mcp23017Setup(PIN_OFFSET, I2C_ADDR)

This example was tested on a quick2wire board with one digital IO
expansion board connected via I2C:

.. code:: python

    wiringpi.mcp23017Setup(65, 0x20)
    wiringpi.pinMode(65, 1)
    wiringpi.digitalWrite(65, 1)

**Soft Tone:**

Hook a speaker up to your Pi and generate music with softTone. Also
useful for generating frequencies for other uses such as modulating A/C.

.. code:: python

    wiringpi.softToneCreate(PIN)
    wiringpi.softToneWrite(PIN, FREQUENCY)

**Bit shifting:**

.. code:: python

    wiringpi.shiftOut(1, 2, 0, 123)  # Shift out 123 (b1110110, byte 0-255) to data pin 1, clock pin 2

**Serial:**

.. code:: python

    serial = wiringpi.serialOpen('/dev/ttyAMA0', 9600)  # Requires device/baud and returns an ID
    wiringpi.serialPuts(serial, "hello")
    wiringpi.serialClose(serial)  # Pass in ID

**SPI:**

The ``wiringPiSPIDataRW()`` function needs to be passed a ``bytes``
object in Python 3. In Python 2, it takes a string. The following should
work in either Python 2 or 3:

.. code:: python

    wiringpi.wiringPiSPISetup(channel, speed)
    buf = bytes([your data here])
    retlen, retdata = wiringpi.wiringPiSPIDataRW(0, buf)

Now, ``retlen`` will contain the number of bytes received/read by the
call. ``retdata`` will contain the data itself, and in Python 3, ``buf``
will have been modified to contain it as well (that won't happen in
Python 2, because then ``buf`` is a string, and strings are immutable).

**Full details of the API at:** http://www.wiringpi.com

Manual Build
============

Get/setup repo
--------------

.. code:: bash

    git clone --recursive https://github.com/WiringPi/WiringPi-Python.git
    cd WiringPi-Python

Don't forget the ``--recursive``; it is required to also pull in the
WiringPi C code from its own repository.

Prerequisites
-------------

To rebuild the bindings you **must** first have installed ``swig``,
``python-dev``, and ``python-setuptools`` (or their ``python3-``
equivalents). WiringPi should also be installed system-wide for access
to the ``gpio`` tool.

.. code:: bash

    sudo apt-get install python-dev python-setuptools swig wiringpi

Build & install with
--------------------

``sudo python setup.py install``

Or Python 3:

``sudo python3 setup.py install``




            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/WiringPi/WiringPi-Python/",
    "name": "wiringpi",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Philip Howard",
    "author_email": "phil@gadgetoid.com",
    "download_url": "https://files.pythonhosted.org/packages/d3/9c/08eb589c718cda9f2168649f1952aa9cb3711dc93d765991a6741cf6a8b7/wiringpi-2.60.1.tar.gz",
    "platform": "",
    "description": "Note\n~~~~\n\nThis is an unofficial port of Gordon's WiringPi library. Please do not\nemail Gordon if you have issues, he will not be able to help.\n\nFor support, comments, questions, etc please join the WiringPi Discord\nchannel: https://discord.gg/SM4WUVG\n\nWiringPi for Python\n===================\n\nWiringPi: An implementation of most of the Arduino Wiring functions for\nthe Raspberry Pi.\n\nWiringPi implements new functions for managing IO expanders.\n\nQuick Install\n=============\n\n.. image:: https://badge.fury.io/py/wiringpi.svg\n   :alt: PyPI version badge\n   :target: https://pypi.org/project/wiringpi/\n\nThe library is packaged on PyPI and can be installed with pip:\n\n``pip install wiringpi``\n\nUsage\n=====\n\n.. code:: python\n\n    import wiringpi\n\n    # One of the following MUST be called before using IO functions:\n    wiringpi.wiringPiSetup()      # For sequential pin numbering\n    # OR\n    wiringpi.wiringPiSetupSys()   # For /sys/class/gpio with GPIO pin numbering\n    # OR\n    wiringpi.wiringPiSetupGpio()  # For GPIO pin numbering\n\n**General IO:**\n\n.. code:: python\n\n    wiringpi.pinMode(6, 1)       # Set pin 6 to 1 ( OUTPUT )\n    wiringpi.digitalWrite(6, 1)  # Write 1 ( HIGH ) to pin 6\n    wiringpi.digitalRead(6)      # Read pin 6\n\n**Setting up a peripheral:**\n\nWiringPi supports expanding your range of available \"pins\" by setting up\na port expander. The implementation details of your port expander will\nbe handled transparently, and you can write to the additional pins\n(starting from PIN\\_OFFSET >= 64) as if they were normal pins on the Pi.\n\n.. code:: python\n\n    wiringpi.mcp23017Setup(PIN_OFFSET, I2C_ADDR)\n\nThis example was tested on a quick2wire board with one digital IO\nexpansion board connected via I2C:\n\n.. code:: python\n\n    wiringpi.mcp23017Setup(65, 0x20)\n    wiringpi.pinMode(65, 1)\n    wiringpi.digitalWrite(65, 1)\n\n**Soft Tone:**\n\nHook a speaker up to your Pi and generate music with softTone. Also\nuseful for generating frequencies for other uses such as modulating A/C.\n\n.. code:: python\n\n    wiringpi.softToneCreate(PIN)\n    wiringpi.softToneWrite(PIN, FREQUENCY)\n\n**Bit shifting:**\n\n.. code:: python\n\n    wiringpi.shiftOut(1, 2, 0, 123)  # Shift out 123 (b1110110, byte 0-255) to data pin 1, clock pin 2\n\n**Serial:**\n\n.. code:: python\n\n    serial = wiringpi.serialOpen('/dev/ttyAMA0', 9600)  # Requires device/baud and returns an ID\n    wiringpi.serialPuts(serial, \"hello\")\n    wiringpi.serialClose(serial)  # Pass in ID\n\n**SPI:**\n\nThe ``wiringPiSPIDataRW()`` function needs to be passed a ``bytes``\nobject in Python 3. In Python 2, it takes a string. The following should\nwork in either Python 2 or 3:\n\n.. code:: python\n\n    wiringpi.wiringPiSPISetup(channel, speed)\n    buf = bytes([your data here])\n    retlen, retdata = wiringpi.wiringPiSPIDataRW(0, buf)\n\nNow, ``retlen`` will contain the number of bytes received/read by the\ncall. ``retdata`` will contain the data itself, and in Python 3, ``buf``\nwill have been modified to contain it as well (that won't happen in\nPython 2, because then ``buf`` is a string, and strings are immutable).\n\n**Full details of the API at:** http://www.wiringpi.com\n\nManual Build\n============\n\nGet/setup repo\n--------------\n\n.. code:: bash\n\n    git clone --recursive https://github.com/WiringPi/WiringPi-Python.git\n    cd WiringPi-Python\n\nDon't forget the ``--recursive``; it is required to also pull in the\nWiringPi C code from its own repository.\n\nPrerequisites\n-------------\n\nTo rebuild the bindings you **must** first have installed ``swig``,\n``python-dev``, and ``python-setuptools`` (or their ``python3-``\nequivalents). WiringPi should also be installed system-wide for access\nto the ``gpio`` tool.\n\n.. code:: bash\n\n    sudo apt-get install python-dev python-setuptools swig wiringpi\n\nBuild & install with\n--------------------\n\n``sudo python setup.py install``\n\nOr Python 3:\n\n``sudo python3 setup.py install``\n\n\n\n",
    "bugtrack_url": null,
    "license": "LGPL",
    "summary": "A python interface to WiringPi 2.0 library which allows for easily interfacing with the GPIO pins of the Raspberry Pi. Also supports i2c and SPI.",
    "version": "2.60.1",
    "project_urls": {
        "Homepage": "https://github.com/WiringPi/WiringPi-Python/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "235532c3abb6516bc8a2b0624063df3a800b3565a52adf46dd8e6740c99854b5",
                "md5": "cf4ec2fe93d30cc5d1a34dbc4dfa2b25",
                "sha256": "267120d890fd67ef3e630e52e8b671f9bc1a52ef227fcb5fff44cfe124ec4a4e"
            },
            "downloads": -1,
            "filename": "wiringpi-2.60.1-cp35-cp35m-linux_armv7l.whl",
            "has_sig": false,
            "md5_digest": "cf4ec2fe93d30cc5d1a34dbc4dfa2b25",
            "packagetype": "bdist_wheel",
            "python_version": "cp35",
            "requires_python": null,
            "size": 265625,
            "upload_time": "2021-02-20T05:53:53",
            "upload_time_iso_8601": "2021-02-20T05:53:53.617927Z",
            "url": "https://files.pythonhosted.org/packages/23/55/32c3abb6516bc8a2b0624063df3a800b3565a52adf46dd8e6740c99854b5/wiringpi-2.60.1-cp35-cp35m-linux_armv7l.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "73155853dd8775985ab1c43baee0492d628125765eefaa49b1840fae6266c914",
                "md5": "381f4085d7cdb809eb3ba61a9b8e10d4",
                "sha256": "daf0570b5928f8824c366afedfacd78f2948577b527b43c5e525265dd5e7ad60"
            },
            "downloads": -1,
            "filename": "wiringpi-2.60.1-cp36-cp36m-linux_armv7l.whl",
            "has_sig": false,
            "md5_digest": "381f4085d7cdb809eb3ba61a9b8e10d4",
            "packagetype": "bdist_wheel",
            "python_version": "cp36",
            "requires_python": null,
            "size": 284624,
            "upload_time": "2021-02-20T05:53:55",
            "upload_time_iso_8601": "2021-02-20T05:53:55.159162Z",
            "url": "https://files.pythonhosted.org/packages/73/15/5853dd8775985ab1c43baee0492d628125765eefaa49b1840fae6266c914/wiringpi-2.60.1-cp36-cp36m-linux_armv7l.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ac6d29381c226c296df5896c1e6855acbd59d40fa8b7ee6e82b289cb9dd940ef",
                "md5": "9fcefe281904487724de8c9b10f7cda3",
                "sha256": "7a54e5a879b828eb113228b835a5dbf13695aae06c206ec11940641346fabc24"
            },
            "downloads": -1,
            "filename": "wiringpi-2.60.1-cp37-cp37m-linux_armv7l.whl",
            "has_sig": false,
            "md5_digest": "9fcefe281904487724de8c9b10f7cda3",
            "packagetype": "bdist_wheel",
            "python_version": "cp37",
            "requires_python": null,
            "size": 285534,
            "upload_time": "2021-02-20T05:53:56",
            "upload_time_iso_8601": "2021-02-20T05:53:56.816025Z",
            "url": "https://files.pythonhosted.org/packages/ac/6d/29381c226c296df5896c1e6855acbd59d40fa8b7ee6e82b289cb9dd940ef/wiringpi-2.60.1-cp37-cp37m-linux_armv7l.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d39c08eb589c718cda9f2168649f1952aa9cb3711dc93d765991a6741cf6a8b7",
                "md5": "78beceab8a759be2e6ab6e6d507f180c",
                "sha256": "b0c65d5d7c65d0bbef25c56d90237ca4098b1edabc528fb48dc6b61d62cd4b7d"
            },
            "downloads": -1,
            "filename": "wiringpi-2.60.1.tar.gz",
            "has_sig": false,
            "md5_digest": "78beceab8a759be2e6ab6e6d507f180c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 130871,
            "upload_time": "2021-02-20T05:53:57",
            "upload_time_iso_8601": "2021-02-20T05:53:57.841565Z",
            "url": "https://files.pythonhosted.org/packages/d3/9c/08eb589c718cda9f2168649f1952aa9cb3711dc93d765991a6741cf6a8b7/wiringpi-2.60.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-02-20 05:53:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "WiringPi",
    "github_project": "WiringPi-Python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "wiringpi"
}
        
Elapsed time: 0.58990s