pyftdi: FTDI Device Driver
pyftdi is a pure Python driver for FTDI devices, providing access to their various functionalities including USB-to-serial, SPI, I2C, and GPIO. It acts as a wrapper around the `libftdi` C library, enabling cross-platform control of FTDI-based hardware. The current version is 0.57.1, with an active development cadence supporting recent Python versions.
Warnings
- gotcha pyftdi requires the `libftdi` C library to be installed on the system. `pip install pyftdi` only installs the Python wrapper, not the underlying C library. Without `libftdi`, pyftdi will not function.
- gotcha On Linux and macOS, accessing USB devices directly often requires specific user permissions (e.g., udev rules). Without these permissions, pyftdi may fail to detect or interact with FTDI devices.
- gotcha On Windows, pyftdi (via libusb) may conflict with standard FTDI drivers (e.g., VCP, D2XX). You might need to replace the standard drivers with WinUSB (using tools like Zadig) for pyftdi to detect the device.
- breaking Support for Python 3.8 and older versions has been deprecated and removed. Running pyftdi on Python 3.8 or earlier will result in errors or installation failure due to `Requires-Python` metadata.
Install
-
pip install pyftdi -
pip install pyftdi[pyusb]
Imports
- Ftdi
from pyftdi.ftdi import Ftdi
- SpiController
from pyftdi.spi import SpiController
- I2cController
from pyftdi.i2c import I2cController
Quickstart
from pyftdi.ftdi import Ftdi
def list_ftdi_devices():
"""
Scans and lists available FTDI devices.
Requires 'libftdi' to be installed on the system and appropriate
USB permissions.
"""
print("Scanning for FTDI devices...")
try:
# Ftdi.show_devices() prints detected devices to stdout
Ftdi.show_devices()
print("\nIf no devices are listed, ensure they are connected,")
print("libftdi is installed, and USB permissions are correct.")
except Exception as e:
print(f"Error scanning for devices: {e}")
print("Ensure 'libftdi' is installed and USB permissions are set correctly.")
if __name__ == "__main__":
list_ftdi_devices()