Library for communication with PCF8575 IO expander over I2C
Python library for the PCF8575 I2C IO expander. It abstracts the 16 bit IO port as a Python list, and allows the read/writing of individual pins or the whole port at once. This is a modified version of the PCF8574 library to support the extra 8 ports.
The library depends on the
smbus-cffi package. You may need to
apt-get install libffi-dev if you're on a debian based system. Otherwise, simply:
pip install pcf8575
In : from pcf8575 import PCF8575 In : i2c_port_num = 1 In : pcf_address = 0x20 In : pcf = PCF8575(i2c_port_num, pcf_address) In : pcf.port Out: [True, True, True, True, True, True, True, True] In : pcf.port = False In : pcf.port Out: [False, True, True, True, True, True, True, True] In : pcf.port = [True, False, True, False, True, False, True, False] In : pcf.port Out: [True, False, True, False, True, False, True, False] In : pcf.port Out: False In : pcf.port Out: True
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.