Skip to main content

CircuitPython library for connecting a TCA9555 16-Bit I2C GPIO expander

Project description

Introduction

Documentation Status Discord Build Status Code Style: Black

CircuitPython library for Texas Instruments TCA9555 Low-Voltage 16-Bit I2C and SMBus I/O Expander with Input / Output and Polarity Inversion.

DataSheet

Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle or individual libraries can be installed using circup.

Installing from PyPI

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:

pip3 install community-circuitpython-tca9555

To install system-wide (this may be required in some cases):

sudo pip3 install community-circuitpython-tca9555

To install in a virtual environment in your current project:

mkdir project-name && cd project-name
python3 -m venv .env
source .env/bin/activate
pip3 install community-circuitpython-tca9555

Usage Example

Create an instance of TCA9555 expander. This defaults to all 16 pins set as inputs with no polarity conversion.

from community_tca9555 import TCA9555
# If the board has I2C defined
expander = TCA9555(board.I2C())  # Use default address of 0x20
# Else specify the specific pins
expander = TCA9555(busio.I2C(scl=board.GP5, sda=board.GP4))  # for the RP Pico

Set the low 8 bits as inputs and the high 8 bits as outputs.

# set all 16 pins at once
expander.configuration_ports = 0x00FF

# or
# set port 0 (8bits) and port 1 (8 bits)
expander.configuration_port_0 = 0xFF  # Inputs
expander.configuration_port_1 = 0x00  # Outputs

# or
# set each pin individually
expander.configuration_port_0_pin_0 = True   # Input
# ...
expander.configuration_port_1_pin_7 = False  # Output

Set pins 6 and 7 of both port 0 and port 1 as polarity inverted.

# Set polarity inversion state for individual pins.
expander.polarity_inversion_port_0_pin_6 = True  # Inverted
expander.polarity_inversion_port_0_pin_7 = True
expander.polarity_inversion_port_1_pin_6 = True
expander.polarity_inversion_port_1_pin_7 = True

# or
# Set an 8bit port at once
expander.polarity_inversion_port_0 = 0xC0  # Just bits 6 and 7

# or
# Set all 16bits at once
expander.polarity_inversions = 0xC0C0

Read the input pins.

input_state = expander.input_port_0
print("Inputs: {:08b}".format(input_state))

Set the state of the output pins.

expander.output_port_1 = 0x42

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Documentation

For information on building library documentation, please check out this guide.

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

community-circuitpython-tca9555-0.2.2.tar.gz (31.8 kB view details)

Uploaded Source

File details

Details for the file community-circuitpython-tca9555-0.2.2.tar.gz.

File metadata

  • Download URL: community-circuitpython-tca9555-0.2.2.tar.gz
  • Upload date:
  • Size: 31.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for community-circuitpython-tca9555-0.2.2.tar.gz
Algorithm Hash digest
SHA256 eafe73ebec4037e0c7ecbab9bc343809bd7b2aa7aa4de880f15571f81ac3dd22
MD5 672f099b549b3c1c790ab68bc385922c
BLAKE2b-256 c722720dcf0c97c520e2e2806c2fe35cdba6f42bccf9977b5907b3ae19c85429

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page