Adafruit Ft232h Breakout
Adafruit Ft232h Breakout
Adafruit Ft232h Breakout
Guide Contents 2
Overview 3
Assembly & Wiring 4
Assembly 4
Wiring 4
Serial UART 6
USB Serial Drivers 6
Windows Serial Driver Installation 6
Serial Usage 8
Windows 9
Mac OSX 10
Linux 11
Other Serial UART Uses 11
MPSSE Setup 13
Windows 15
libusb Driver Install 15
libftdi Install 17
Adafruit Python GPIO Library Install 18
libusb Driver Uninstall 20
Mac OSX 22
Disable FTDI Driver on OSX 10.11 El Capitan 23
Linux 24
MPSSE Usage 26
GPIO 27
SPI 31
Driving NeoPixels With SPI 32
I2C 38
Software Usage 38
Other I2C Libraries 39
I2C Device Enumeration 39
More Info 40
Erase EEPROM For Programming With FT_PROG 40
Downloads 42
Files 42
Schematic 42
Fabrication Print 42
Wouldn't it be cool to drive a tiny OLED display (https://adafru.it/eau), read a color sensor (http://adafru.it/1334), or even
just flash some LEDs directly from your computer? Sure you can program an Arduino (http://adafru.it/50) or
Trinket (http://adafru.it/2000) to talk to these devices and your computer, but why can't your computer just talk to those
devices and sensors itself? Well, now your computer can talk to devices using the Adafruit FT232H breakout board!
What can the FT232H chip do? This chip from FTDI (https://adafru.it/c97) is similar to their USB to serial converter
chips but adds a 'multi-protocol synchronous serial engine' which allows it to speak many common protocols like SPI,
I2C, serial UART, JTAG, and more! There's even a handful of digital GPIO pins that you can read and write to do things
like flash LEDs, read switches or buttons, and more. The FT232H breakout is like adding a little swiss army knife
for serial protocols to your computer!
Interested in learning more about the FT232H and its capabilities? Continue on to read about how to assemble,
configure, and access the capabilities of the FT232H breakout. Also be sure to skim and read the FT232H
datasheet (https://adafru.it/eav) for more information about the chip.
Assembly
To assemble the FT232H breakout you'll need to solder the included headers to the breakout board. If you haven't
soldered before, make sure to first read the guide to excellent soldering (https://adafru.it/dgp) and try practicing with
some scrap wires and components.
Start by trimming the male headers to the length of the pin holes on the breakout board. You should have two rows of
male headers with 10 pins each.
Then insert the longer pins of the headers into a breadboard so that the pin holes on the FT232H breakout slide
perfectly through the header pins sticking out the top of the breadboard.
Using a soldering iron and some solder, carefully solder all the pins to the FT232H breakout board.
If you aren't clear on the steps above, check out an assembly guide for other breakout boards like the VS1053 audio
board (https://adafru.it/jFo). You should follow the same steps to solder the header pins to the FT232H breakout
board.
Once the headers are soldered to the board, plug in a micro USB cable to the port on the FT232H breakout and then
plug the cable into a computer or laptop. You should see a green LED next to the 5V pin on the breakout light up.
Congratulations your FT232H board is assembled!
Wiring
Below is a quick description of the pins on the FT232H breakout. You'll learn about these pins in more detail in the
Serial UART (https://adafru.it/jFp) and MPSSE Setup (https://adafru.it/jFq) sections of the guide.
When used as a serial UART the FT232H breakout pins have the following serial functions:
D0 - TX or transmit pin. This pin is the serial data output by the FT232H chip and should be connected to the RX
or receive pin of a serial device.
D1 - RX or receive pin. This pin is the serial data input for the FT232H chip and should be connected to the TX or
transmist pin of a serial device.
D2 - RTS or ready to send pin. This is an optional pin for flow control of serial connections.
D3 - CTS or clear to send pin. Like RTS, this is an optional pin for flow control.
D4 - DTR or data terminal ready pin. Another optional pin for flow control in RS-232 serial connections.
D5 - DSR or data set ready pin. Like DTR, this is another optional pin for flow control in RS-232 serial
connections.
D6 - DCD or data carrier detect pin. This is an optional pin that is sometimes used in RS-232 serial
communication.
The most important and commonly used serial pins are D0 and D1 for the TX and RX pins. The other pins are only
necessary if you're using a device with flow control or specific RS-232 serial needs.
Specifically Mac OSX Mavericks or greater have the FTDI serial driver included automatically. Linux kernel versions
since ~2.6 also have the FTDI serial driver included, so modern Linux distributions like Ubuntu 12.04 or 14.04 should
work without any driver installation. Windows can usually search online to find the driver automatically, however if that
fails see below for manual driver installation instructions.
If for some reason your operating system doesn't have FTDI serial drivers installed, you can download and install official
drivers from FTDI's site (https://adafru.it/aJv). There are drivers available for Windows 7 & 8, Mac OSX, and Linux.
First start with your Windows 7, 8, or 8.1 machine booted and the FT232H board disconnected from the PC.
Download the FTDI serial driver (sometimes called VCP or virtual COM port) here (https://adafru.it/aJv), make sure to
pick the Windows setup executable version of the driver.
Next open explorer and navigate to the folder where the driver executable was downloaded. Right click on the file
and select Run as administrator as shown below to start the installation. It's important to run as administartor or else
the driver installation will fail to copy files to Window's system directories.
Once the installation is done you might need to reboot your machine if the installation program tells you to do so.
After rebooting, plug in the FT232H breakot to your PC using a USB micro cable. You should see a message pop up
that the device is recognized and a driver is being installed.
To check that the serial port installed successfully and find the COM port assigned to it, open device manager by
clicking the start menu and searching for Device Manager.
Inside device manager look under the Ports (COM & LPT) node and you should see a USB Serial Port (COMx) device,
where x is a number like 5. This COMx is the COM port assigned to the FT232H serial UART, and what you should use
when connecting to the serial port in the Arduino IDE or with a serial terminal program.
However if for some reason you don't see the USB Serial Port (COMx) device or Ports (COM & LPT) node, you might
need to enable the VCP mode for the FTDI device. To do this open the Universal Serial Bus controllers node at the
bottom of Device Manager and you should see a USB Serial Converter node. Right click this node and click the
Properties menu, then click the Advanced tab at the top. Make sure the Load VCP checkbox is checked and then click
OK. See the picture below for the configuration page and device manager view you should see.
Serial Usage
Once any necessary serial port drivers are installed, you're ready to use the FT232H as a USB to serial UART. Let's
perform a simple loopback test to confirm you can read and write data with the UART. This test will connect the TX pin
to the RX pin so any data sent to serial UART will be immediately received and echoed back to you.
Using a jumper wire, connect pin D0 (TX) to D1 (RX) on the FT232H breakout as shown below.
Windows
On Windows you can use PuTTY (https://adafru.it/aWh) as a serial console. Download and run PuTTY, then configure it
for a Connection type of Serial as shown below on the right. The Serial line should be set to the COM port you found
for the USB serial converter in device manager (shown on the left), in this case COM5. Speed should be set to 9600
baud.
Click open and you should see an empty terminal screen appear. Try typing a message and you should see what you
If you don't see anything, make sure you've connected the D0 pin to the D1 pin on the FT232H board.
Also make sure you're using the right COM port for the FT232H device. Try unplugging any other USB to serial
converter (including development boards like Arduinos!) and only connecting the FT232H board to make sure you can
find its COM port in device manager.
Mac OSX
On a Mac you can use a few included terminal commands to list serial ports and connect to a serial port to test the
loopback connection.
First start with the FT232H board disconnected and open a terminal to run the following command to list all serial
ports.
ls /dev/tty.*
/dev/tty.Bluetooth-Incoming-Port /dev/tty.usbmodem20
/dev/tty.Bluetooth-Modem /dev/tty.usbmodem22
/dev/tty.usbmodem1d111 /dev/tty.usbmodem24
Now connect the FT232H breakout to the computer, wait a moment, and run the same ls command again. You should
see a new device in the list, such as:
/dev/tty.Bluetooth-Incoming-Port /dev/tty.usbmodem20
/dev/tty.Bluetooth-Modem /dev/tty.usbmodem22
/dev/tty.usbmodem1d111 /dev/tty.usbmodem24
/dev/tty.usbserial-0000111D
Replace the /dev/tty.usbserial name with the name of the device you found after running the ls commands above. The
9600 after the name is the baud rate to open the screen connection.
Once screen opens the connection you should see a blank screen. Try typing characters and you should see them
echoed back in the terminal. Congratulations, your serial loopback test is a success!
Linux
On Linux distributions such as Ubuntu 12.04 or 14.04 you can run terminal commands that are very similar to those
shown above for Mac OSX. The only difference is that you should run the following ls command to list serial devices:
ls /dev/tty*
Run the above command before and after plugging in the FT232H breakout to find the path to the new device that
was added. On a distribution like Ubuntu you will typically see a path like /dev/ttyUSB0.
To open the serial port use the exact same screen command as mentioned above for Mac OSX. Replace the path
parameter with the path to the FT232H device you found above.
Note you might need to press Ctrl-a and then \ to quit screen on Ubuntu or other Linux distributions.
For example to connect to a Raspberry Pi just connect the FT232H ground to Raspberry Pi ground, D0 (TX) to
Raspberry Pi RX, and D1 (RX) to Raspberry Pi TX like below:
You can find more details on accessing a Raspberry Pi through its serial console in this console cable
guide (https://adafru.it/jFr). The FT232H breakout can be used instead of the console cable mentioned in the guide!
D0 - Clock signal output. This line can be configured as a clock that runs at speeds between ~450Hz to 30Mhz.
D1 - Serial data output. This is for outputting a serial signal, like the MOSI line in a SPI connection.
D2 - Serial data input. This is for reading a serial signal, like the MISO line in a SPI connection.
D3 - Serial select signal. This is a chip select or chip enable signal to tell a connected device that the FT232H is
ready to talk to it.
In addition to the serial protocol pins above, the MPSSE mode allows you to control other pins as general purpose
digital inputs or outputs. These are great for controlling chip select, reset, or other lines on chips. You can even use
the GPIO to read switches, blink LEDs, and more!
The pins which are controllable as GPIO in MPSSE mode are D4 to D7 and C0 to C7, for a total of 12 GPIO pins. These
pins can be configured individually as digital inputs or outputs.
Note that pins C8 and C9 are not controllable as GPIO pins. These two pins have a special function that can be set in
the EEPROM of the chip--you'll learn more about these later.
To use the MPSSE mode of the chip you'll need to use some special software and programming libraries. There are
actually a few options for software that can talk to the FT232H and its MPSSE component:
These libraries build on top of the D2XX driver above and provide a simpler interface to I2C and SPI
communication with the FT232H's MPSSE component.
Like the libMPSSE-I2C and libMPSSE-SPI libraries, this library builds on the libFTDI library and provides a
simpler interface for I2C and SPI protocols using the MPSSE component. One thing to note is that his
library is currently only supported on Mac OSX and Linux.
Adafruit Python GPIO library (https://adafru.it/eaG)
To make using the FT232H simpler, Adafruit's Python GPIO library has been updated to include a simple
interface for accessing GPIO, SPI, and I2C on the FT232H with the Python programming language. Using
this library you can control the GPIO pins and send or received SPI & I2C commands much like
programming those interfaces on a Raspberry Pi or BeagleBone Black. This library is built on top of the
libFTDI library and supports Windows, Mac OSX, and Linux platforms.
One thing to note, when you're using the MPSSE mode of the FT232H the serial UART mode will be disabled. This
means you can't use both the serial UART and MPSSE GPIO, SPI, I2C, etc. modes of the chip at the same time.
To learn how to enable MPSSE modes and install the Adafruit Python GPIO library, continue on to the next page that's
appropriate for your platform (Windows, Mac OSX, or Linux).
Note: When you enable MPSSE mode the serial UART driver will be disabled. If you want to disable MPSSE mode and
enable the serial UART again I'll show instructions at the end of the page.
First before you get started make sure you have Python 2.7 installed. You can download the latest Python 2.7 installer
here (https://adafru.it/eaH) (at the time of writing it's version 2.7.8, but any 2.7.x version should work--unfortunately the
3.x series isn't supported yet).
Download the MSI installer for your version of Windows, you must install the 32-bit version, and run the installer.
Install Python into its standard location, typically C:\python27. Also make sure to install the option to add Python to
the system path so you can easily call the Python interpretor from a command terminal.
Before you run the tool unplug all FTDI devices from your computer. This includes devices likebArduinos which
include an FTDI chip as a USB to serial converter. You want to unplug these devices to make sure you don't
accidentally select one with the tool and replace its driver.
After all the FTDI devices are unplugged, plug in your FT232H breakout to the computer so it is the only FTDI device
connected to the computer.
Now run the Zadig tool executable you just downloaded (there is no installation necessary, the executable is the
program). Click the Options menu and select the List All Devices item below:
The list box of devices should populate with many devices. Select the USB Serial Converter device shown below.
Note: Make sure to select the device with Driver equal to FTDIBUS and USB ID equal to 0403 6014! If you pick the
wrong device you might accidentally uninstall another device's driver and make it inoperable.
Now click the Replace Driver button to replace the FTDI driver with the libusb-based driver. After the driver
replacement finishes you can close Zadig tool.
To check that the driver was successfully replaced, open Device Manager from Control Panel or searching in the Start
menu. You should see a new top level node libusbK USB Devices and the USB Serial Converter underneath it as
shown below.
If you see the libusbK node and USB serial device, move on to the next step to install libftdi.
If you don't see the libusbK node, try unplugging and plugging back in the FT232H breakout. If you still don't see the
node, run Zadig tool again and follow the steps above again to make sure you replace the FTDI driver for the device
with the libusbK driver.
Start by downloading the binary version of the libftdi library by clicking the button below. This binary is provided by the
picusb USB resources project (https://adafru.it/srb).
https://adafru.it/src
https://adafru.it/src
Unzip the archive and you should see a series of folders like below:
We need to copy some files from libftdi into Python's package directory. Open another Explorer window and navigate
to the location you installed Python earlier, typically C:\python27. Inside the Python directory navigate to the Lib > site-
packages folder. Files you copy into this folder will be available globally as packages that your Python scripts can use.
From the libftdi archive folder, copy all the .DLL files from the bin folder into the Python site-packages folder,
specifically:
bin\libftdi1.dll
bin\libftdipp1.dll
bin\libgcc_s_dw2-1.dll
bin\libiconv-2.dll
bin\libintl-8.dll
bin\libstdc++-6.dll
bin\libusb-1.0.dll
Then also copy in the files from the python2.7 folder of the libftdi archive into the Python site-packages folder:
python2.7\_ftdi.pyd
python2.7\ftdi1.py
That's all you need to do to install libftdi. Let's move on to install the Adafruit Python GPIO library next.
https://adafru.it/eaL
https://adafru.it/eaL
Unzip the contents and then open a command terminal and navigate to the directory where the library was unzipped.
Execute the following command to install the library:
Note if you see an error that Python can't be found then make sure you installed Python 2.7 as mentioned at the top of
the page, and that it was added to your system path. Here's more details on how to manually add Python to your
system path (https://adafru.it/eaM).
You should see the Python library install itself with text similar to the below:
python
Once the Python interpretor has loaded, type the following at the >>> prompt:
import Adafruit_GPIO
import ftdi1
You should see no response from the Python interpretor after entering each command like below:
No response from the Python interpretor is a good sign because it means Python was able to successfully load the
libraries.
Once you've confirmed Python can load the libraries, exit the Python interpretor by typing:
quit()
Congratulations, the MPSSE mode drivers and Python libraries are installed and ready to use! Move on to the next
section to see how to use the MPSSE mode to access GPIO, SPI, I2C, etc.
First make sure the FT232H breakout is plugged in to the computer. Then open Device Manager and find the libusbK
USB Devices node and the USB Serial Converter child of that node. Right click the device and select Uninstall as
shown below:
In the dialog that appears make sure the 'Delete the driver software for this device.' option is checked as shown below:
Now unplug the FT232H breakout board and go back to the Serial UART page (https://adafru.it/jFp) to find the
instructions for installing the Windows serial driver. Follow those instructions again and you should be set with the
device acting as a USB serial UART again.
Note that these steps were tested using OSX Mavericks. The steps should work for later versions like Yosemite, but
you might need to search for extra help on installing Xcode command line tools below.
First before you get started you will need to make sure you have Xcode (https://adafru.it/eaN) and the Xcode
command line tools installed. This is required to compile and build libraries from source. Follow the steps in the
answer to this Stackoverflow question (https://adafru.it/df2) for a good walkthrough of how to install the Xcode
command line tools.
Next install the Homebrew package manager (https://adafru.it/df3) which will be used to install the necessary libftdi
depedencies. Follow the installation instructions from the bottom of Homebrew's homepage (https://adafru.it/df3) to
install it.
Now run the following commands in a terminal in order to install libftdi and its dependencies:
The commands above should complete without any errors. If you do see errors, make sure you have Xcode and
Homebrew successfully installed and try again.
Next download the Adafruit Python GPIO library by clicking the button below:
https://adafru.it/eaL
https://adafru.it/eaL
Unzip the archive and navigate to the folder inside a terminal. Then run the following command to install the library:
You should see the Python library successfully install without any errors.
To test the libraries are installed run the following command in a terminal to open the Python interpretor:
python
At the Python interpretor >>> prompt type the following commands to test loading the libraries:
import Adafruit_GPIO
import ftdi1
If there are no errors, congratulations you've successfully installed libftdi and the Adafruit Python GPIO library! Move
on to the next section to learn how to access the MPSSE mode GPIO, SPI, I2C, etc.
quit()
Note that these steps are made for Ubuntu 12.04/14.04 and should work with any Debian-based distribution. If you're
using a different distribution you might need to check its package manager for the appropriate commands to install the
mentioned dependencies.
In a command terminal execute the following commands to install libftdi and its dependencies.
NOTE: This assumes you're installing on a Debian/Ubuntu/Raspbian-based system and will use Python 2.7. If you're
using a different version of Python or your distribution installs Python in a different location you might need to change
the paths of the -DPYTHON_xxxx environment variables in the cmake command.
The commands above should complete without any errors. If you do see errors, make sure all the dependencies were
installed with the apt-get install command.
Next download the Adafruit Python GPIO library by clicking the button below:
https://adafru.it/eaL
https://adafru.it/eaL
Unzip the archive and navigate to the folder inside a terminal. Then run the following command to install the library:
You should see the Python library successfully install without any errors.
To test the libraries are installed run the following command in a terminal to open the Python interpretor:
python
At the Python interpretor >>> prompt type the following commands to test loading the libraries:
import Adafruit_GPIO
import ftdi1
If there are no errors, congratulations you've successfully installed libftdi and the Adafruit Python GPIO library! Move
on to the next section to learn how to access the MPSSE mode GPIO, SPI, I2C, etc.
quit()
Make sure you've first installed the libftdi library & Adafruit Python GPIO library by following the steps for your platform
in the previous section!
With this configuration pin C0 will be a digital output that controls if the LED is on or off, depending on the level of the
C0 output. Pin D7 will be a digital input that reads if it's at a high level (3-5 volts) or low level (ground).
Now create a file named gpio_test.py in a text editor and fill it with the following Python code:
# Temporarily disable the built-in FTDI serial driver on Mac & Linux platforms.
FT232H.use_FT232H()
# Create an FT232H object that grabs the first available FT232H device found.
ft232h = FT232H.FT232H()
# Loop turning the LED on and off and reading the input state.
print 'Press Ctrl-C to quit.'
while True:
# Set pin C0 to a high level so the LED turns on.
ft232h.output(8, GPIO.HIGH)
# Sleep for 1 second.
time.sleep(1)
# Set pin C0 to a low level so the LED turns off.
ft232h.output(8, GPIO.LOW)
# Sleep for 1 second.
time.sleep(1)
# Read the input on pin D7 and print out if it's high or low.
level = ft232h.input(7)
if level == GPIO.LOW:
print 'Pin D7 is LOW!'
else:
print 'Pin D7 is HIGH!'
Save the file and then open a command line terminal and navigate to the folder with gpio_test.py. Run the script by
executing on Windows:
python gpio_test.py
You should see the LED start to blink once a second, and the state of the D7 input is also printed. For example if D7 is
connected to ground you'll see:
Pin D7 is HIGH!
Pin D7 is HIGH!
Pin D7 is HIGH!
Swap the jumper wire between ground and 5 volts to see the input value change.
Let's look a little more closely at the code to understand how reading and writing digital GPIO works.
First the required modules are loaded for this script. The time module will be used to delay for a short period of time.
The Adafruit_GPIO and Adafruit_GPIO.FT232H modules will be imported with shorter names using the 'as' keyword.
These modules have all the logic for reading and writing GPIO on the FT232H.
# Temporarily disable the built-in FTDI serial driver on Mac & Linux platforms.
FT232H.use_FT232H()
Next the use_FT232H() function is called to temporarily disable any FTDI serial drivers. This command is necessary on
Mac or Linux platforms because the libftdi library will interfere with the built-in FTDI serial drivers.
You don't really need to run this command on Windows because the FTDI serial driver was disabled using the Zadig
tool, however it can't hurt to call the function as it will do nothing on Windows.
# Create an FT232H object that grabs the first available FT232H device found.
ft232h = FT232H.FT232H()
Now an FT232H object is created and assigned to the ft232h variable. This will detect the first available FT232H
device connected to the computer and initialize its MPSSE for use with GPIO.
Make sure the use_FT232H() function was previously called or else this function will fail!
Next the setup() function is called on the FT232H object. This function takes two parameters, the first is the pin
number and the second is either GPIO.IN or GPIO.OUT to set the pin as a digital input or output.
Remember the pin numbers are 0 to 7 for D0 to D7, and 8 to 15 for C0 to C7.
Now an infinite loop is entered and the LED is turned on and off using the output() function on the FT232H object. This
function takes two parameters, the first is the pin number and the second is GPIO.HIGH/True to set the pin to a high
level (3.3 volts), or GPIO.LOW/False to set the pin to a low level (ground).
# Read the input on pin D7 and print out if it's high or low.
level = ft232h.input(7)
if level == GPIO.LOW:
print 'Pin D7 is LOW!'
else:
print 'Pin D7 is HIGH!'
Finally the digital input is read using the input() function on the FT232H object. This function takes one parameter, the
pin number to read. The function will return GPIO.LOW/False if the input is at a low level (below about 0.8 volts), and
GPIO.HIGH/True if the input is at a high level (above about 0.8 volts, up to 5V max).
That's all there is to use GPIO on the FT232H board! You can use these GPIO pins to turn on and off devices or LEDs,
or read switches or pins from other chips.
Be aware that the output pins on the FT232H are only designed to source a few milliamps of current (up to about 16mA
per pin). If you need to drive devices that take a lot of current, look into using transistors to switch higher amounts of
current.
When using SPI with the FT232H the following pins will have a special meaning:
D0 - SCK / Clock signal. This will be the clock that tells devices when to sample and write data.
D1 - MOSI / Data Out. This will output data from the FT232H to the connected device.
D2 - MISO / Data In. This will read data from the connected device to the FT232H.
One thing to note is that there isn't an explicit chip select / enable pin. You should use any of the free GPIO pins as a
dedicated chip select pin and specify that pin when creating the SPI object.
To use SPI with the Python library you need to create an instance of the Adafruit_GPIO.FT232H.SPI class. For example
see the following code:
# Create a SPI interface from the FT232H using pin 8 (C0) as chip select.
# Use a clock speed of 3mhz, SPI mode 0, and most significant bit first.
spi = FT232H.SPI(ft232h, cs=8, max_speed_hz=3000000, mode=0, bitorder=FT232H.MSBFIRST)
# Write three bytes (0x01, 0x02, 0x03) out using the SPI protocol.
spi.write([0x01, 0x02, 0x03])
Notice that the code starts by importing the FT232H part of the GPIO library and disabling the FTDI serial drivers as
your saw in the GPIO example.
Next the code creates a FT232H object also like was done in the GPIO example.
The next line of code creates a FT232H.SPI object using the FT232H device that was just created. An optional chip
select/slave select line is specified using GPIO 8 / pin C0 with the cs parameter value.
Notice too the speed, mode, and bit order of the SPI protocol are specified as parameters of the initializer. Mode 0
and bit order of MSBFIRST are actually the default values and do not necessarily need to be specified here, but it's
helpful to show them for clarity.
Possible mode values are 0 through 3 and they correspond to SPI mode values for AVR
processors (https://adafru.it/cEC).
Bitorder can be either MSBFIRST for most significant bits to be clocked out first, or LSBFIRST for the least significant
bits to be clocked out first.
Finally the last line shows how to send 3 bytes of data out the D1 (MOSI) line using the write() function. The D0 (SCK)
There are also SPI functions you can use to read and transfer (read and write at the same time) data:
# Write 3 bytes and simultaneously read 3 bytes using the SPI protocl.
response = spi.transfer([0x01, 0x02, 0x03])
print 'Received {0}'.format(response)
The read() function will read the specified number of bytes on the D2 (MISO) line (sending clock pulses out D0 (SCK)
as necessary).
The transfer() function is like calling write() and read() at the same time. The specified array of bytes will be sent out D1
(MOSI) while at the same time data will be read from D2 (MISO).
That's all there is to using the SPI protocol with the FT232H and the Adafruit Python GPIO library!
You might also be interested in this tutorial which shows how to use the FT232H breakout with some Adafruit SPI
devices (https://adafru.it/jFt) that have been ported to use Adafruit's Python GPIO library.
Note that this method of driving NeoPixels is limited to lighting about 340 pixels at a time. This limitation comes from
the maximum amount of data that can be sent to the FT232H at one time over the USB bus, about 64 kilobytes of data.
Because we're oversampling the NeoPixel control signal each pixel actually takes 24*8 bytes of SPI data (or one byte
of SPI data for every bit of pixel data).
To demonstrate lighting NeoPixels with the FT232H breakout you'll need the following parts:
Each pixel can take up to 60mA, so driving more than a handful of pixels can quickly add up to a few amps
or more of current. Do not try to power more than a couple NeoPixels over the FT232H 5V line!
Level converter chip to convert 3.3 to 5 volts OR a power diode that can handle the full power of all the
NeoPixels.
The NeoPixel control signal needs to be at least 0.7*Vcc (power supply voltage) which is just a little too high
for the 3.3 volt output of the FT232H breakout. Just like lighting NeoPixels with the Raspberry
Pi (https://adafru.it/jFv) you need to either convert the control signal to 5 volts using a chip like the
74AHCT125 (http://adafru.it/1787), or drop the NeoPixel power supply down slightly below 5 volts using a
In this example I'm lighting a 16 pixel ring so I'll use a power diode that can handle 1 amp of current. If you're using
more than 16 NeoPixels you'll want a larger power diode, or a level converter chip.
A picture of the hardware setup is below (note I've added a large capacitor to the power supply as recommended in
the NeoPixel Uberguide (https://adafru.it/iZe)):
Now create a file neopixels.py and fill it with the following code:
import time
class NeoPixel_FT232H(object):
def __init__(self, n):
# Create an FT232H object.
self.ft232h = FT232H.FT232H()
# Create a SPI interface for the FT232H object. Set the SPI bus to 6mhz.
self.spi = FT232H.SPI(self.ft232h, max_speed_hz=6000000)
# Create a pixel data buffer and lookup table.
self.buffer = bytearray(n*24)
def build_byte_lookup(self):
# Create a lookup table to map all byte values to 8 byte values which
# represent the 6mhz SPI data to generate the NeoPixel signal for the
# specified byte.
lookup = {}
for i in range(256):
value = bytearray()
for j in range(7, -1, -1):
if ((i >> j) & 1) == 0:
value.append(0b11100000)
else:
value.append(0b11111000)
lookup[i] = value
return lookup
def show(self):
# Send the pixel buffer out the SPI data output pin (D1) as a NeoPixel
# signal.
self.spi.write(self.buffer)
# Run this code when the script is called at the command line:
if __name__ == '__main__':
# Define the number of pixels in the NeoPixel strip.
# Only up to ~340 pixels can be written using the FT232H.
pixel_count = 16
# Create a NeoPixel_FT232H object.
pixels = NeoPixel_FT232H(pixel_count)
# Animate each pixel turning red.
# Loop through each pixel.
for i in range(pixel_count):
# Set the pixel color to pure red.
pixels.set_pixel_color(i, 255, 0, 0)
# Show the pixel buffer by sending it to the LEDs.
pixels.show()
# Delay for a short period of time.
time.sleep(0.25)
# Animate each pixel turning pure green.
for i in range(pixel_count):
pixels.set_pixel_color(i, 0, 255, 0)
pixels.show()
time.sleep(0.25)
# Animate each pixel turning pure blue.
for i in range(pixel_count):
pixels.set_pixel_color(i, 0, 0, 255)
pixels.show()
time.sleep(0.25)
# Animate a pattern of colors marching around the pixels.
# Create a pattern of colors to display.
colors = [ (255, 0, 0), (255, 255, 0), (0, 255, 0), (0, 255, 255),
Save the file and navigate to the folder with it in a terminal, then execute the following in Windows to run the program:
python neopixels.py
Or on Mac OSX or Linux execute the following to run the program as root:
You should see the NeoPixels light up and animate with different colors. Note that you might need to change the
pixel_count variable in the main part of the program to match the number of pixels in your NeoPixel strip, circle, matrix,
etc.
This code does a couple things at a high level. It first defines a class called NeoPixel_FT232H. This class contains
some methods and state which control generating the NeoPixel signal with an FT232H board. The second part of the
code uses the NeoPixel_FT232H class to animate the NeoPixels.
You actually don't need to fully understand the NeoPixel_FT232H class code to use it. This code performs the
'oversampling' by using a lookup table to expand each byte of color data into 8 bytes of SPI data that approximates the
NeoPixel control signal. The only important thing to know about the NeoPixel_FT232H class is that it exposes a
set_pixel_color() function which allows you to set the red, green, and blue color value of a pixel.
Instead let's walk through a bit of the second half of the code that uses the NeoPixel_FT232H class:
# Run this code when the script is called at the command line:
if __name__ == '__main__':
# Define the number of pixels in the NeoPixel strip.
# Only up to ~340 pixels can be written using the FT232H.
pixel_count = 16
# Create a NeoPixel_FT232H object.
pixels = NeoPixel_FT232H(pixel_count)
This portion of code has an if statement that checks if the program is being run from the command line before
executing. This is just a standard Python idiom for defining the main entry point of a program.
Inside the if block you can see the number of pixels is defined and set in the pixel_count variable. Then the
NeoPixel_FT232H object is created by telling it that number of pixels as its only parameter.
The next section performs a few simple animations that turn each pixel on with primary colors. You can see a loop is
used to go through each pixel and the set_pixel_color() function is called to the pixel color. This function takes 4
parameters, the first is the number of the pixel (start at 0), and the last 3 parameters are the red, green, and blue color
components. Each component should be a value from 0 to 255, where 0 is no color and 255 is maximum color
intensity.
After changing the pixel color, the show() function is called to send the colors to the LEDs. You must call show() in
order to make the NeoPixels light up with the colors you've set previously!
Finally notice the time.sleep() function is used to delay for a short period of time (a quarter of a second in this case).
This sleep function is very useful for animating color changes that should go somewhat slowly.
Finally the code enters an infinite loop where it animates a rainbow of colors marching across the pixels. This code
uses the same set_pixel_color() function, but has a little extra logic to pick a color from a list and increase the offset of
chosen colors every loop iteration. Also notice the show() function is again called after updating pixel colors in order
to make the LEDs light up with the desired colors.
That's all there is to controlling NeoPixels with SPI from the FT232H breakout! Feel free to use the code above in your
To use I2C with the Adafruit Python GPIO library and the FT232H board you'll need to setup your circuit in a special
way. In particular you'll need to tie the D1 and D2 pins together with a jumper wire. One of the pins will be read by the
F232H as an input, and the other pin will be used as an output. When tied together both these pins form the SDA or
data line for I2C.
The D0 pin alone will be the SCL clock line for I2C.
The second thing you'll need to do with your circuit is add explicit pull-up resistors from SDA & SCL on the FT232H up
to 3.3 or 5 volts. This is necessary because the FT232H does not have pull-up resistors built in to these lines as it is a
very general purpose chip. I recommend using 4.7 kilo-ohm resistors as these pull-ups.
To summarize, for using I2C you need to setup your hardware as follows:
Connect FT232H D1 and D2 together with a jumper wire. This combined connection is the I2C SDA data line.
Add a 4.7 kilo-ohm resistor from the I2C SDA data line (pins D1 and D2 above) up to FT232H 5V.
Add a 4.7 kilo-ohm resistor from FT232H D0 up to FT232H 5V. This pin D0 is the I2C SCL clock line.
Software Usage
To use I2C with the Adafruit Python GPIO library you'll need to create an Adafruit_FT232.I2CDevice instance. This
object takes as a parameter to its initializer the FT232H object that represents your FT232H chip, and the address of
the I2C device to communicate with using the chip.
For example the code below creates an I2C device for a device with address 0x70:
At this point the I2CDevice instance is ready for reading and writing simple 8 and 16 bit values from registers. The
interface on the I2CDevice class for reading and writing is exactly the same as the interface on the Raspberry Pi
Python I2C code (https://adafru.it/ebW), so you can examine code which is written for the Pi and use it with very few
changes on the FT232H.
For example to read a 16 bit register value and write an 8 bit register value to the device the code might look like:
That's all there is to using I2C with the Adafruit Python GPIO library and the FT232H board!
You might also be interested in this tutorial which shows how to use the FT232H breakout with some Adafruit I2C
devices (https://adafru.it/jFt) that have been ported to use Adafruit's Python GPIO library.
Another alternative is the libMPSSE-I2C library that uses the FTDI D2XX drivers. See this application note for more
details on using libMPSSE-I2C (https://adafru.it/eaT).
The reference for all information about the FT232H. You should consider at least skimming this document,
or even reading it in depth in order to understand all of the chip's capabilities.
MPSSE Command Reference (https://adafru.it/eaU)
This reference details the low-level commands that control the MPSSE component of the FT232H chip.
Check out the FT PROG tool for a utility that allows you to write the EEPROM on the FT232H breakout and
control the C8 and C9 pin functionality. These pins can be configured to drive status LEDs, generate
limited waveforms, or just act as a high or low signal. Check the datasheet for more information on all of
the parameters that the EEPROM can control. Note that FT PROG unfortunately is only supported on
Windows. If you're planning to use FT PROG be sure to see the note about erasing the EEPROM further
below!
Search for FT232H or MPSSE on the page in order to find many useful app notes for using the FT232H to
interface with different serial protocols.
libftdi (https://adafru.it/df4)
libftdi is a nice open source alternative to FTDI's binary drivers. You can find more details here about
interacting with the FT232H at a low level using libftdi.
libmpsse (https://adafru.it/df5)
This is a nice library to access the MPSSE functionality of the FT232H, and is an alternative to the Python
GPIO library shown in this guide. You might check out this library if you find the Python GPIO library is too
limited.
If you're doing development with ARM chips the OpenOCD debugger tool is invaluable for stepping
through the execution of chips using the JTAG protocol. FTDI chips with an MPSSE like the FT232H can
even speak JTAG and work with OpenOCD for on-chip debugging.
First connect your FT232H board to the machine and follow the Zadig tool steps here (https://adafru.it/jFx) to enable
the libusb-based driver for the FT232H board.
Once libusbK is enabled as the driver for the FT232H then download the libftdi Windows binaries from
here (https://adafru.it/fcS) (at the time of this writing you want the libftdi1-1.1_devkit_x86_x64_21Feb2014.zip archive).
Unzip this archive and there should be a bin32 and bin64 subdirectory with a eeprom.exe and other command line
tools. Open a command line terminal and navigate to the appropriate directory for your system (32 or 64-bit), then run
Once erased the libusb driver needs to be uninstalled for the device to make it available for FT_PROG again. Follow
the steps here (https://adafru.it/jFx) to use device manager to uninstall and remove the driver for the FT232H board.
Once the libusb driver is uninstalled unplug the FT232H from the machine and plug it back in again. Run FT_PROG,
slick the scan button (magnifying glass) and the FT232H should be detected.
Schematic
(Click to embiggen)
Fabrication Print
Dimensions in inches