Introduction
============
.. image:: https://readthedocs.org/projects/adafruit-circuitpython-mcp3xxx/badge/?version=latest
:target: https://docs.circuitpython.org/projects/mcp3xxx/en/latest/
:alt: Documentation Status
.. image:: https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_Bundle/main/badges/adafruit_discord.svg
:target: https://adafru.it/discord
:alt: Discord
.. image:: https://github.com/adafruit/Adafruit_CircuitPython_MCP3xxx/workflows/Build%20CI/badge.svg
:target: https://github.com/adafruit/Adafruit_CircuitPython_MCP3xxx/actions/
:alt: Build Status
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
:alt: Code Style: Black
CircuitPython library for the MCP3xxx series of analog-to-digital converters.
Currently supports:
* `MCP3008: 8-Channel 10-Bit ADC With SPI Interface <https://www.adafruit.com/product/856>`_
Dependencies
=============
This driver depends on:
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
* `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_
Please ensure all dependencies are available on the CircuitPython filesystem.
This is easily achieved by downloading
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
Installing from PyPI
====================
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
PyPI <https://pypi.org/project/adafruit-circuitpython-mcp3xxx/>`_. To install for current user:
.. code-block:: shell
pip3 install adafruit-circuitpython-mcp3xxx
To install system-wide (this may be required in some cases):
.. code-block:: shell
sudo pip3 install adafruit-circuitpython-mcp3xxx
To install in a virtual environment in your current project:
.. code-block:: shell
mkdir project-name && cd project-name
python3 -m venv .venv
source .venv/bin/activate
pip3 install adafruit-circuitpython-mcp3xxx
Usage Example
=============
MCP3008 Single Ended
---------------------
.. code-block:: python
import busio
import digitalio
import board
import adafruit_mcp3xxx.mcp3008 as MCP
from adafruit_mcp3xxx.analog_in import AnalogIn
# create the spi bus
spi = busio.SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI)
# create the cs (chip select)
cs = digitalio.DigitalInOut(board.D5)
# create the mcp object
mcp = MCP.MCP3008(spi, cs)
# create an analog input channel on pin 0
chan = AnalogIn(mcp, MCP.P0)
print('Raw ADC Value: ', chan.value)
print('ADC Voltage: ' + str(chan.voltage) + 'V')
MCP3008 Differential
--------------------
.. code-block:: python
import busio
import digitalio
import board
import adafruit_mcp3xxx.mcp3008 as MCP
from adafruit_mcp3xxx.analog_in import AnalogIn
# create the spi bus
spi = busio.SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI)
# create the cs (chip select)
cs = digitalio.DigitalInOut(board.D5)
# create the mcp object
mcp = MCP.MCP3008(spi, cs)
# create a differential ADC channel between Pin 0 and Pin 1
chan = AnalogIn(mcp, MCP.P0, MCP.P1)
print('Differential ADC Value: ', chan.value)
print('Differential ADC Voltage: ' + str(chan.voltage) + 'V')
MCP3004 Single-Ended
---------------------
.. code-block:: python
import busio
import digitalio
import board
import adafruit_mcp3xxx.mcp3004 as MCP
from adafruit_mcp3xxx.analog_in import AnalogIn
# create the spi bus
spi = busio.SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI)
# create the cs (chip select)
cs = digitalio.DigitalInOut(board.D5)
# create the mcp object
mcp = MCP.MCP3004(spi, cs)
# create an analog input channel on pin 0
chan = AnalogIn(mcp, MCP.P0)
print('Raw ADC Value: ', chan.value)
print('ADC Voltage: ' + str(chan.voltage) + 'V')
MCP3004 Differential
--------------------
.. code-block:: python
import busio
import digitalio
import board
import adafruit_mcp3xxx.mcp3004 as MCP
from adafruit_mcp3xxx.analog_in import AnalogIn
# create the spi bus
spi = busio.SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI)
# create the cs (chip select)
cs = digitalio.DigitalInOut(board.D5)
# create the mcp object
mcp = MCP.MCP3004(spi, cs)
# create a differential ADC channel between Pin 0 and Pin 1
chan = AnalogIn(mcp, MCP.P0, MCP.P1)
print('Differential ADC Value: ', chan.value)
print('Differential ADC Voltage: ' + str(chan.voltage) + 'V')
Documentation
=============
API documentation for this library can be found on `Read the Docs <https://docs.circuitpython.org/projects/mcp3xxx/en/latest/>`_.
For information on building library documentation, please check out `this guide <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/sharing-our-docs-on-readthedocs#sphinx-5-1>`_.
Contributing
============
Contributions are welcome! Please read our `Code of Conduct
<https://github.com/adafruit/adafruit_CircuitPython_MCP3xxx/blob/main/CODE_OF_CONDUCT.md>`_
before contributing to help this project stay welcoming.
Raw data
{
"_id": null,
"home_page": null,
"name": "adafruit-circuitpython-mcp3xxx",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "adafruit, mcp3xxx, hardware, micropython, circuitpython",
"author": null,
"author_email": "Adafruit Industries <circuitpython@adafruit.com>",
"download_url": "https://files.pythonhosted.org/packages/c1/df/019934f371f4bc517bfe05d2a3909a0dc3f3dcb39def8368043145c4cc34/adafruit_circuitpython_mcp3xxx-1.4.18.tar.gz",
"platform": null,
"description": "Introduction\n============\n\n.. image:: https://readthedocs.org/projects/adafruit-circuitpython-mcp3xxx/badge/?version=latest\n :target: https://docs.circuitpython.org/projects/mcp3xxx/en/latest/\n :alt: Documentation Status\n\n.. image:: https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_Bundle/main/badges/adafruit_discord.svg\n :target: https://adafru.it/discord\n :alt: Discord\n\n.. image:: https://github.com/adafruit/Adafruit_CircuitPython_MCP3xxx/workflows/Build%20CI/badge.svg\n :target: https://github.com/adafruit/Adafruit_CircuitPython_MCP3xxx/actions/\n :alt: Build Status\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n :target: https://github.com/psf/black\n :alt: Code Style: Black\n\nCircuitPython library for the MCP3xxx series of analog-to-digital converters.\n\nCurrently supports:\n\n* `MCP3008: 8-Channel 10-Bit ADC With SPI Interface <https://www.adafruit.com/product/856>`_\n\n\nDependencies\n=============\nThis driver depends on:\n\n* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_\n* `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_\n\nPlease ensure all dependencies are available on the CircuitPython filesystem.\nThis is easily achieved by downloading\n`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.\n\nInstalling from PyPI\n====================\n\nOn supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from\nPyPI <https://pypi.org/project/adafruit-circuitpython-mcp3xxx/>`_. To install for current user:\n\n.. code-block:: shell\n\n pip3 install adafruit-circuitpython-mcp3xxx\n\nTo install system-wide (this may be required in some cases):\n\n.. code-block:: shell\n\n sudo pip3 install adafruit-circuitpython-mcp3xxx\n\nTo install in a virtual environment in your current project:\n\n.. code-block:: shell\n\n mkdir project-name && cd project-name\n python3 -m venv .venv\n source .venv/bin/activate\n pip3 install adafruit-circuitpython-mcp3xxx\n\nUsage Example\n=============\n\n\nMCP3008 Single Ended\n---------------------\n\n.. code-block:: python\n\n import busio\n import digitalio\n import board\n import adafruit_mcp3xxx.mcp3008 as MCP\n from adafruit_mcp3xxx.analog_in import AnalogIn\n\n # create the spi bus\n spi = busio.SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI)\n\n # create the cs (chip select)\n cs = digitalio.DigitalInOut(board.D5)\n\n # create the mcp object\n mcp = MCP.MCP3008(spi, cs)\n\n # create an analog input channel on pin 0\n chan = AnalogIn(mcp, MCP.P0)\n\n print('Raw ADC Value: ', chan.value)\n print('ADC Voltage: ' + str(chan.voltage) + 'V')\n\n\nMCP3008 Differential\n--------------------\n\n.. code-block:: python\n\n import busio\n import digitalio\n import board\n import adafruit_mcp3xxx.mcp3008 as MCP\n from adafruit_mcp3xxx.analog_in import AnalogIn\n\n # create the spi bus\n spi = busio.SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI)\n\n # create the cs (chip select)\n cs = digitalio.DigitalInOut(board.D5)\n\n # create the mcp object\n mcp = MCP.MCP3008(spi, cs)\n\n # create a differential ADC channel between Pin 0 and Pin 1\n chan = AnalogIn(mcp, MCP.P0, MCP.P1)\n\n print('Differential ADC Value: ', chan.value)\n print('Differential ADC Voltage: ' + str(chan.voltage) + 'V')\n\nMCP3004 Single-Ended\n---------------------\n\n.. code-block:: python\n\n import busio\n import digitalio\n import board\n import adafruit_mcp3xxx.mcp3004 as MCP\n from adafruit_mcp3xxx.analog_in import AnalogIn\n\n # create the spi bus\n spi = busio.SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI)\n\n # create the cs (chip select)\n cs = digitalio.DigitalInOut(board.D5)\n\n # create the mcp object\n mcp = MCP.MCP3004(spi, cs)\n\n # create an analog input channel on pin 0\n chan = AnalogIn(mcp, MCP.P0)\n\n print('Raw ADC Value: ', chan.value)\n print('ADC Voltage: ' + str(chan.voltage) + 'V')\n\nMCP3004 Differential\n--------------------\n\n.. code-block:: python\n\n import busio\n import digitalio\n import board\n import adafruit_mcp3xxx.mcp3004 as MCP\n from adafruit_mcp3xxx.analog_in import AnalogIn\n\n # create the spi bus\n spi = busio.SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI)\n\n # create the cs (chip select)\n cs = digitalio.DigitalInOut(board.D5)\n\n # create the mcp object\n mcp = MCP.MCP3004(spi, cs)\n\n # create a differential ADC channel between Pin 0 and Pin 1\n chan = AnalogIn(mcp, MCP.P0, MCP.P1)\n\n print('Differential ADC Value: ', chan.value)\n print('Differential ADC Voltage: ' + str(chan.voltage) + 'V')\n\n\n\nDocumentation\n=============\n\nAPI documentation for this library can be found on `Read the Docs <https://docs.circuitpython.org/projects/mcp3xxx/en/latest/>`_.\n\nFor information on building library documentation, please check out `this guide <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/sharing-our-docs-on-readthedocs#sphinx-5-1>`_.\n\nContributing\n============\n\nContributions are welcome! Please read our `Code of Conduct\n<https://github.com/adafruit/adafruit_CircuitPython_MCP3xxx/blob/main/CODE_OF_CONDUCT.md>`_\nbefore contributing to help this project stay welcoming.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "CircuitPython library for the MCP3xxx Analog-to-Digital converters.",
"version": "1.4.18",
"project_urls": {
"Homepage": "https://github.com/adafruit/Adafruit_CircuitPython_MCP3xxx"
},
"split_keywords": [
"adafruit",
" mcp3xxx",
" hardware",
" micropython",
" circuitpython"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1e7bda0c57a4f30fbc4f2966c2fb1cb30054a3bb305a9b8de0303ba3293abe38",
"md5": "3f369c204571f52caa4ccc7cefa05ada",
"sha256": "cab6b22060f635b0748c548d5399a336221c03002b68d5eba30bd1a120f46fc1"
},
"downloads": -1,
"filename": "adafruit_circuitpython_mcp3xxx-1.4.18-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3f369c204571f52caa4ccc7cefa05ada",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 9750,
"upload_time": "2024-10-07T22:13:02",
"upload_time_iso_8601": "2024-10-07T22:13:02.389286Z",
"url": "https://files.pythonhosted.org/packages/1e/7b/da0c57a4f30fbc4f2966c2fb1cb30054a3bb305a9b8de0303ba3293abe38/adafruit_circuitpython_mcp3xxx-1.4.18-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c1df019934f371f4bc517bfe05d2a3909a0dc3f3dcb39def8368043145c4cc34",
"md5": "008e23a46b52bc87ac464bf76754f7e7",
"sha256": "133363ba33d7face3238eff4565d6a9f489a216499c5baa0503aef9113cf104a"
},
"downloads": -1,
"filename": "adafruit_circuitpython_mcp3xxx-1.4.18.tar.gz",
"has_sig": false,
"md5_digest": "008e23a46b52bc87ac464bf76754f7e7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 28400,
"upload_time": "2024-10-07T22:13:04",
"upload_time_iso_8601": "2024-10-07T22:13:04.017399Z",
"url": "https://files.pythonhosted.org/packages/c1/df/019934f371f4bc517bfe05d2a3909a0dc3f3dcb39def8368043145c4cc34/adafruit_circuitpython_mcp3xxx-1.4.18.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-07 22:13:04",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "adafruit",
"github_project": "Adafruit_CircuitPython_MCP3xxx",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "adafruit-circuitpython-mcp3xxx"
}