A module to access GPIO expanders MCP23S17 from a Raspberry Pi.
Project description
This is a Python module that abstracts the GPIO expander MCP23S17. It is intended for the use on a Raspberry Pi.
Provided Functions
As a quick overview, the module provides the following functions. Refer to the module documentation for details:
open
close
setPullupMode
setDirection
digitalRead
digitalWrite
writeGPIO
readGPIO
Installation
If not already done, you need to install PIP via:
sudo apt-get install python-dev python-pip
Install from PyPI:
pip install RPiMCP23S17
Example
The following demo peridically toggles all pins of two MCP23S17 components:
from RPiMCP23S17.MCP23S17 import MCP23S17 import time mcp1 = MCP23S17(bus=0x00, pin_cs=0x00, device_id=0x00) mcp2 = MCP23S17(bus=0x00, pin_cs=0x00, device_id=0x01) mcp1.open() mcp2.open() for x in range(0, 16): mcp1.setDirection(x, mcp1.DIR_OUTPUT) mcp2.setDirection(x, mcp1.DIR_OUTPUT) print "Starting blinky on all pins (CTRL+C to quit)" while (True): for x in range(0, 16): mcp1.digitalWrite(x, MCP23S17.LEVEL_HIGH) mcp2.digitalWrite(x, MCP23S17.LEVEL_HIGH) time.sleep(1) for x in range(0, 16): mcp1.digitalWrite(x, MCP23S17.LEVEL_LOW) mcp2.digitalWrite(x, MCP23S17.LEVEL_LOW) time.sleep(1) # the lines below essentially have the same effect as the lines above mcp1.writeGPIO(0xFFF) mcp2.writeGPIO(0xFFF) time.sleep(1) mcp1.writeGPIO(0x0) mcp2.writeGPIO(0x0) time.sleep(1)
Change Log
1.0.0
Added possibility to set reset pin
0.2.3
Fixed error “NameError: global name ‘MCP23S17_GPIOB’ is not defined” in function digitalRead
0.2.2
Fixed example in documentation
0.2.1
Updated documentation
0.2.0
Reorganized module structure
0.1.1
Enhanced package setup script setup.py
Updated documentation
0.1.0
Initial release
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file RPiMCP23S17-1.0.0.tar.gz
.
File metadata
- Download URL: RPiMCP23S17-1.0.0.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45667d578468717e6b0e992da7405a603efba0bb5b98d0972ca00796a84b5036 |
|
MD5 | c1a73e70d41fe6a6c5ba21b76f836c34 |
|
BLAKE2b-256 | c9f619c421a58aa2b3f5abaaabe2f5b69c9d04826c8d8320010dddf8874703f1 |
File details
Details for the file RPiMCP23S17-1.0.0-py3.5.egg
.
File metadata
- Download URL: RPiMCP23S17-1.0.0-py3.5.egg
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a0fd3afb3a3aa9ab64f5348d8bf61a182fe28ab9ad580c06e5d6116a7c61a41 |
|
MD5 | eb453ac9bdc511aa9c196cf8c08e9fce |
|
BLAKE2b-256 | 791bbc79d70b52f11f7b0e78fe30da1befd96c15ad13c86244cf19f5fb8ec117 |
File details
Details for the file RPiMCP23S17-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: RPiMCP23S17-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89343cbaadc01866da521f32fee1d55a4f0a52fa42091557c7bcec86763b8b36 |
|
MD5 | 1de97b9e2a7e1679f933964030a9fd63 |
|
BLAKE2b-256 | 8e392dfa37e88e21164aab3b737ac3489a89ab3b392af5e698bba212ade5eb0d |