Skip to main content

Python driver for PCF8574 8bit IO Expander board

Developed for the Raspberry Pi, requires python-smbus2 package to access the I2C bus.

Tested on raspberry pi 3b plus with two PCF8574 boards.

First install smbus2 using: pip3 install smbus2

then install the actual package using: pip3 install pcf8574-io

Usage Example:

import pcf8574_io

# You can use up to 8 PCF8574 boards
# the board will start in input mode
# the pins are HIGH in input mode
p1 = pcf8574_io.PCF(0x20)

# You can use multiple boards with different addresses
#p2 = pcf8574_io.PCF(0x21)

# p0 to p7 are the pins name
# INPUT or OUTPUT is the mode
p1.pin_mode("p0", "INPUT")
print(p1.read("p0"))

# You can write and read the output pins
# use HIGH or LOW to set the pin, HIGH is +3.3v LOW is 0v
p1.pin_mode("p7", "OUTPUT")
p1.write("p7", "LOW")
print(p1.read("p7"))

# Additional you can do the following
p1.set_i2cBus(1)
p1.get_i2cBus()
print(p1.get_pin_mode("p7")) # returns string OUTPUT, INPUT
print(p1.is_pin_output("p7")) # returns boolean True, False
print(p1.get_all_mode()) # returns list of all pins ["OUTPUT","INPUT",...etc]

Note: the board has only 25mA output current so if you want to control some relay modules, that need more than 25mA use more than one pin to control each relay.

The board been used: alt text

#Link https://pypi.org/project/pcf8574-io/

Release files for pcf8574-io 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pcf8574-io 0.1.1
File Size Uploaded
pcf8574_io-0.1.1.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pcf8574-io 0.1.1
File Interpreter ABI Platform
pcf8574_io-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 7.9 kB

Release files / pcf8574_io-0.1.1.tar.gz

Download URL pcf8574_io-0.1.1.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
cc6f88b2deaa589a28a3748b6b2ca4212d0707d67685f9a0ed4221037e9c9fe9
BLAKE2b-256 checksum
How to use checksums
35267a0b7fd47a46b03cfc9d419bf7be8d50dcf7b0f2f46a0d0231826d63c4b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.7

Release files / pcf8574_io-0.1.1-py3-none-any.whl

Download URL pcf8574_io-0.1.1-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
117126d8671fad811259d2d53211c8e2bae612254996e8acc7c8ffae5d040311
BLAKE2b-256 checksum
How to use checksums
ee1158b2c5d2ba38aa713c4294dc62aaab7795fa6eb7f1b45f29c8a5201ea357
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.7

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page