# Adafruit FT232H With SPI & I2C Devices

## Overview

Warning: 

![](https://cdn-learn.adafruit.com/assets/assets/000/021/367/medium800/adafruit_products_DSC00742.jpg?1416602332)

The [Adafruit FT232H breakout](https://www.adafruit.com/products/2264)&nbsp;is a great way to add GPIOs and an I2C or SPI bus to your&nbsp;computer. &nbsp;There are [lots](../../../../nokia-5110-3310-lcd-python-library/overview)&nbsp;[of](../../../../ssd1306-oled-displays-with-raspberry-pi-and-beaglebone-black/overview)&nbsp;[Adafruit](../../../../led-backpack-displays-on-raspberry-pi-and-beaglebone-black/overview)&nbsp;[breakout](../../../../using-the-bmp085-with-raspberry-pi/overview)&nbsp;[boards](../../../../tmp006-temperature-sensor-python-library/overview) that use I2C or SPI and have been ported to Python for&nbsp;the Raspberry Pi & BeagleBone Black, so can you use those boards with the&nbsp;FT232H breakout too? &nbsp;Yes, you can! &nbsp;With a few simple changes you can make sensors and displays built with&nbsp;the [Adafruit Python GPIO library](https://github.com/adafruit/Adafruit_Python_GPIO)&nbsp;work with the FT232H breakout too. &nbsp;Follow this guide to learn how to connect SPI / I2C devices and update their code to work the FT232H breakout!

Before you get started you'll want to make sure you're familiar with [the FT232H guide](../../../../adafruit-ft232h-breakout/overview)&nbsp;and have followed its steps to install the FT232H driver software.

# Adafruit FT232H With SPI & I2C Devices

## SPI Devices

Warning: 

Adafruit SPI devices which use the [Adafruit Python GPIO library](https://github.com/adafruit/Adafruit_Python_GPIO)&nbsp;(i.e. are designed&nbsp;to work with the Raspberry Pi and BeagleBone Black) can easily be configured to work with the FT232H over a SPI connection. &nbsp;Some of these devices include:

- [MAX31855 Thermocouple Amplifier Breakout](../../../../max31855-thermocouple-python-library/overview)
- [Nokia LCD](../../../../nokia-5110-3310-lcd-python-library/overview)
- [SSD1306 OLED Displays](../../../../ssd1306-oled-displays-with-raspberry-pi-and-beaglebone-black/overview)
- [ILI9341 LCD](../../../../user-space-spi-tft-python-library-ili9341-2-8/overview)&nbsp;

# Wiring

To use one of these devices you'll first want to&nbsp;first read the device's tutorial to get an overview of its connections and library usage. &nbsp;Then connect the device to the FT232H breakout just like you're connecting the device to a Raspberry Pi or BeagleBone Black, but with the following SPI connections:

- **Device SCLK** or clock to **FT232H D0** / serial clock.
- **Device MOSI** or data in to **FT232H D1** / serial output.
- **Device MISO** or data out to **FT232H D2** / serial input.

For other digital pins on the device, such as chip select, reset, data, etc., you should connect those pins to any free GPIO pins on the FT232H, such as **C0** to **C7** (GPIO numbers **8** to **15** ).

For device power you can use the 5V pin on the FT232H board to supply up to ~500mA of 5 volt power. &nbsp;Also remember the FT232H board digital outputs operate at 3.3 volts&nbsp;and&nbsp;the digital inputs can safely accept either 3.3 volts or 5 volts.

# Software Setup

Follow the device's tutorial and make sure you have installed on your PC any external Python libraries that the device uses&nbsp; For most devices like sensors there are no other Python dependencies to install.

## Python Imaging Library For Displays

Many of the display libraries, such as the Nokia LCD, SSD1306, or ILI9341 display, use the [Python imaging library (PIL)](http://www.pythonware.com/products/pil/)&nbsp;which you'll need to install on your PC. &nbsp;On a Windows PC it can be a little tricky to install Python libraries so I recommend installing the [PIL setup executable from its website](http://www.pythonware.com/products/pil/). &nbsp;On a Mac you'll need to make sure [Xcode command line tools](http://stackoverflow.com/questions/9329243/xcode-4-4-and-later-install-command-line-tools)&nbsp;and [PIP](http://pip.readthedocs.org/en/latest/installing.html)&nbsp;are&nbsp;installed, then run:

```auto
sudo pip install pil
```

or

```auto
sudo pip install pillow
```

On a Debian or Ubuntu Linux machine you can install PIL with an apt package by running:

```auto
sudo apt-get update
sudo apt-get install python-imaging
```

After any dependencies are installed you can install the device's software library just like you were installing it on a Raspberry Pi or BeagleBone Black. &nbsp;You should run the software library's **setup.py** script and pass it the install parameter. &nbsp;For example on a Mac or Linux machine, in a command terminal navigate to the directory with the library's source code and execute:

```auto
sudo python setup.py install
```

On a Windows machine open a command terminal, navigate to the directory with the library's source code and execute:

```auto
python setup.py install
```

(make sure [Python is added to your path](http://stackoverflow.com/questions/6318156/adding-python-path-on-windows-7)&nbsp;before running the above!)

# Usage

To make the device's example code work with&nbsp;the FT232H you'll need to make a few small changes. &nbsp;First you'll need to include the FT232H module, enable the FT232H, and create an FT232H device by adding to the start of the code:

```auto
import Adafruit_FT232H as FT232H

# Temporarily disable FTDI serial drivers to use the FT232H device.
FT232H.use_FT232H()

# Create an FT232H device instance.
ft232h = FT232H.FT232H()
```

Next create an FT232H SPI object using the FT232H device. &nbsp;Note that you can optionally set the chip select / secondary select pin by specifying the FT232H GPIO number that's connected to the device's chip select pin. &nbsp;

For example&nbsp;if the device's chip select pin is connected to the FT232H **GPIO 8 /**  **C0** pin the SPI device would look like:

```auto
# Create an FT232H SPI object with the specified chip select pin.
ft232h_spi = FT232H.SPI(ft232h, cs=8)
```

Finally create the device object and pass in the FT232H SPI device that was created above as the **spi** parameter of the initializer. &nbsp;If the device uses other GPIO pins, such as a reset or data pin, you'll also need to pass the FT232H device as the&nbsp; **gpio** parameter value.

For example to configure a Nokia LCD&nbsp;with the **data / DC pin** connected to FT232H **GPIO 9 /**  **C1** and the **reset pin** connected to FT232H **GPIO 10 /**  **C2** , the code would look like:

```auto
display = LCD.PCD8544(9, 10, spi=ft232h_spi, gpio=ft232h)
```

Putting everything together, here's the full [Nokia LCD shapes.py example](https://github.com/adafruit/Adafruit_Nokia_LCD/blob/master/examples/shapes.py)&nbsp;converted over to use the FT232H with the **chip select / CS** pin connected to **GPIO 8 /&nbsp;C0** , **data / DC pin** connected to **GPIO 9 /&nbsp;C1** , the **reset / RST pin** connected to **GPIO10 /&nbsp;C2:**

```auto
    import time

import Adafruit_Nokia_LCD as LCD
import Adafruit_FT232H as FT232H

from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont

# Temporarily disable FTDI serial drivers to use the FT232H device.
FT232H.use_FT232H()

# Create an FT232H device instance.
ft232h = FT232H.FT232H()

# Create an FT232H SPI object with the specified chip select pin.
ft232h_spi = FT232H.SPI(ft232h, cs=8)

# Create the Nokia display object.
disp = LCD.PCD8544(9, 10, spi=ft232h_spi, gpio=ft232h)

# The code below is exactly the same as the Nokia LCD library's shapes.py example:
  
# Initialize library.
disp.begin(contrast=60)

# Clear display.
disp.clear()
disp.display()

# Create blank image for drawing.
# Make sure to create image with mode '1' for 1-bit color.
image = Image.new('1', (LCD.LCDWIDTH, LCD.LCDHEIGHT))

# Get drawing object to draw on image.
draw = ImageDraw.Draw(image)

# Draw a white filled box to clear the image.
draw.rectangle((0,0,LCD.LCDWIDTH,LCD.LCDHEIGHT), outline=255, fill=255)

# Draw some shapes.
draw.ellipse((2,2,22,22), outline=0, fill=255)
draw.rectangle((24,2,44,22), outline=0, fill=255)
draw.polygon([(46,22), (56,2), (66,22)], outline=0, fill=255)
draw.line((68,22,81,2), fill=0)
draw.line((68,2,81,22), fill=0)

# Load default font.
font = ImageFont.load_default()

# Alternatively load a TTF font.
# Some nice fonts to try: http://www.dafont.com/bitmap.php
# font = ImageFont.truetype('Minecraftia.ttf', 8)

# Write some text.
draw.text((8,30), 'Hello World!', font=font)

# Display image.
disp.image(image)
disp.display()

print 'Press Ctrl-C to quit.'
while True:
	time.sleep(1.0)
  
```

# Adafruit FT232H With SPI & I2C Devices

## I2C Devices

Warning: 

Adafruit I2C&nbsp;devices which work with the Raspberry Pi & BeagleBone Black also use the [Adafruit Python GPIO library](https://github.com/adafruit/Adafruit_Python_GPIO)&nbsp;and can easily be configured to work with the FT232H. &nbsp;Some of these devices include:

- [TMP006 Non-Contact Temperature Sensor](../../../../tmp006-temperature-sensor-python-library/overview)
- [MCP9808 Precision Temperature Sensor](../../../../mcp9808-temperature-sensor-python-library/overview)
- [BMP085/180 Pressure Sensor](../../../../using-the-bmp085-with-raspberry-pi/overview)
- [Adafruit LED Backpacks](../../../../led-backpack-displays-on-raspberry-pi-and-beaglebone-black/overview)
- [SSD1306 OLED](../../../../ssd1306-oled-displays-with-raspberry-pi-and-beaglebone-black/overview)

Danger: 

# Wiring

Like the [FT232H guide mentions](../../../../adafruit-ft232h-breakout/i2c), when using I2C you'll need to setup your circuit with external pull-up resistors connected to the I2C clock and data lines. &nbsp;This is necessary because the FT232H is a general purpose chip which doesn't include built-in pull-up resistors.

As a quick summary of the I2C wiring, make the following connections:

- Connect FT232H **D1** and **D2** together with a jumper wire. &nbsp;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. &nbsp;This pin **D0** is the I2C **SCL&nbsp;** clock line.

Next wire your I2C device to the&nbsp;FT232H **SDA** and **SCL** lines just as you would for a Raspberry Pi or BeagleBone Black. &nbsp;For other digital pins on the device, such as chip select, reset, data, etc., you should connect those pins to any free GPIO pins on the FT232H, such as **C0** to **C7** (GPIO numbers **8** to **15** ).

For device power you can use the 5V pin on the FT232H board to supply up to ~500mA of 5 volt power. &nbsp;Also remember the FT232H board digital outputs operate at 3.3 volts&nbsp;and&nbsp;the digital inputs can safely accept either 3.3 volts or 5 volts. &nbsp;

**Note with the setup above the I2C pins SDA and SCL will be pulled up to 5 volts when idle! &nbsp;** Make sure your I2C device can handle this voltage (Adafruit breakout boards, unless noted otherwise, are made to handle 5 volts). If you are using a 3.3V device, simply connect the pullups to 3.3V instead of 5V

# Software Setup

Follow the device's tutorial and make sure you have installed on your PC any external Python libraries that the device uses&nbsp; For most devices like sensors there are no other Python dependencies to install.

If you're using a display like the SSD1306 OLED you'll likely need to install the Python Imaging Library (PIL). &nbsp;Check the [instructions on the SPI setup page for more details on installing this library](../../../../adafruit-ft232h-with-spi-and-i2c-libraries/spi-devices#python-imaging-library-for-displays).

After any dependencies are installed you can install the device's software library just like you were installing it on a Raspberry Pi or BeagleBone Black. &nbsp;You should run the software library's **setup.py** script and pass it the install parameter. &nbsp;For example on a Mac or Linux machine, in a command terminal navigate to the directory with the library's source code and execute:

```auto
sudo python setup.py install
```

On a Windows machine open a command terminal, navigate to the directory with the library's source code and execute:

```auto
python setup.py install
```

(make sure [Python is added to your path](http://stackoverflow.com/questions/6318156/adding-python-path-on-windows-7)&nbsp;before running the above!)

# Usage

To make the device's code work with the FT232H you need to make a few small changes to the code. &nbsp;First you'll need to include the FT232H module, enable the FT232H, and create an FT232H device by adding to the start of the code:

```auto
import Adafruit_GPIO.FT232H as FT232H
 
# Temporarily disable FTDI serial drivers to use the FT232H device.
FT232H.use_FT232H()
 
# Create an FT232H device instance.
ft232h = FT232H.FT232H()
```

Then in the device's initializer pass in the FT232H device as the value of the optional **i2c** parameter. &nbsp;For example with the BMP085/180 breakout the code would look like:

```auto
sensor = BMP085.BMP085(i2c=ft232h)
```

Note that if the device uses other digital pins, such a reset pin, you should also pass the ft232h object as an optional **gpio** parameter. &nbsp;See the [SPI page&nbsp;for an example of passing this gpio parameter](../../../../adafruit-ft232h-with-spi-and-i2c-libraries/spi-devices#usage).

That's all there is to configuring a device to use the FT232H with I2C! &nbsp;You can now use the device just like the library example code shows.

Here's the [full simpletest.py example for the BMP085/180](https://github.com/adafruit/Adafruit_Python_BMP/blob/master/examples/simpletest.py)&nbsp;ported over to use the FT232H:

```auto
import Adafruit_BMP.BMP085 as BMP085

import Adafruit_GPIO.FT232H as FT232H
 
# Temporarily disable FTDI serial drivers to use the FT232H device.
FT232H.use_FT232H()
 
# Create an FT232H device instance.
ft232h = FT232H.FT232H()

# Create BMP085 device with FT232H as I2C provider.
sensor = BMP085.BMP085(i2c=ft232h)

# You can also optionally change the BMP085 mode to one of BMP085_ULTRALOWPOWER, 
# BMP085_STANDARD, BMP085_HIGHRES, or BMP085_ULTRAHIGHRES.  See the BMP085
# datasheet for more details on the meanings of each mode (accuracy and power
# consumption are primarily the differences).  The default mode is STANDARD.
#sensor = BMP085.BMP085(mode=BMP085.BMP085_ULTRAHIGHRES, i2c=ft232h)

print 'Temp = {0:0.2f} *C'.format(sensor.read_temperature())
print 'Pressure = {0:0.2f} Pa'.format(sensor.read_pressure())
print 'Altitude = {0:0.2f} m'.format(sensor.read_altitude())
print 'Sealevel Pressure = {0:0.2f} Pa'.format(sensor.read_sealevel_pressure())
```


## Featured Products

### Adafruit FT232H Breakout - General Purpose USB to GPIO, SPI, I2C

[Adafruit FT232H Breakout - General Purpose USB to GPIO, SPI, I2C](https://www.adafruit.com/product/2264)
Wouldn't it be cool to drive a [tiny&nbsp;OLED display](https://www.adafruit.com/categories/98), read a [color...](https://www.adafruit.com/products/1334)

In Stock
[Buy Now](https://www.adafruit.com/product/2264)
[Related Guides to the Product](https://learn.adafruit.com/products/2264/guides)
### Thermocouple Amplifier MAX31855 breakout board (MAX6675 upgrade)

[Thermocouple Amplifier MAX31855 breakout board (MAX6675 upgrade)](https://www.adafruit.com/product/269)
Thermocouples are very sensitive, requiring a good amplifier with a cold-compensation reference. The MAX31855K does everything for you, and can be easily interfaced with any microcontroller, even one without an analog input. This breakout board has the chip itself, a 3.3V regulator with 10uF...

In Stock
[Buy Now](https://www.adafruit.com/product/269)
[Related Guides to the Product](https://learn.adafruit.com/products/269/guides)
### Nokia 5110/3310 monochrome LCD + extras

[Nokia 5110/3310 monochrome LCD + extras](https://www.adafruit.com/product/338)
These displays were used in old Nokia 5110/3310 cell phones (before the smart-phone fad turned every cell phone into a TV). It's a&nbsp;84x48 pixel monochrome LCD display. These displays are small, only about 1.5" diagonal, but very readable and come with a white backlight. This...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/338)
[Related Guides to the Product](https://learn.adafruit.com/products/338/guides)
### Monochrome 0.96" 128x64 OLED Graphic Display - STEMMA QT

[Monochrome 0.96" 128x64 OLED Graphic Display - STEMMA QT](https://www.adafruit.com/product/326)
These displays are small, only about 1" diagonal, but very readable due to the high contrast of an OLED display. This display is made of 128x64 individual white OLED pixels, each one is turned on or off by the controller chip. Because the display makes its own light, no backlight is...

In Stock
[Buy Now](https://www.adafruit.com/product/326)
[Related Guides to the Product](https://learn.adafruit.com/products/326/guides)
### Monochrome 128x32 I2C OLED graphic display

[Monochrome 128x32 I2C OLED graphic display](https://www.adafruit.com/product/931)
These displays are small, only about 1" diagonal, but very readable due to the high contrast of an OLED display. This display is made of 128x32 individual white OLED pixels, each one is turned on or off by the controller chip. Because the display makes its own light, no backlight is...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/931)
[Related Guides to the Product](https://learn.adafruit.com/products/931/guides)
### 2.8" TFT LCD with Touchscreen Breakout Board w/MicroSD Socket

[2.8" TFT LCD with Touchscreen Breakout Board w/MicroSD Socket](https://www.adafruit.com/product/1770)
Add some jazz & pizazz to your project with a color touchscreen LCD. This TFT display is big (2.8" diagonal) bright (4 white-LED backlight) and colorful! 240x320 pixels with individual RGB pixel control, this has way more resolution than a black and white 128x64 display. As a bonus,...

Out of Stock
[Buy Now](https://www.adafruit.com/product/1770)
[Related Guides to the Product](https://learn.adafruit.com/products/1770/guides)
### Adafruit 0.56" 4-Digit 7-Segment Display with I2C Backpack - Red

[Adafruit 0.56" 4-Digit 7-Segment Display with I2C Backpack - Red](https://www.adafruit.com/product/878)
What's better than a single LED? Lots of LEDs! A fun way to make a small display is to use an [8x8 matrix](https://www.adafruit.com/category/37_88) or a [4-digit 7-segment display](https://www.adafruit.com/category/37_103). Matrices like these are...

In Stock
[Buy Now](https://www.adafruit.com/product/878)
[Related Guides to the Product](https://learn.adafruit.com/products/878/guides)
### Contact-less Infrared Thermopile Sensor Breakout - TMP007

[Contact-less Infrared Thermopile Sensor Breakout - TMP007](https://www.adafruit.com/product/2023)
Unlike most of the other temperature sensors we have, this breakout has a really cool IR sensor from TI that can measure the temperature of an object without touching it!

**Please note: These parts are formally discontinued, they work great but we won't be stocking for a much...**

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/2023)
[Related Guides to the Product](https://learn.adafruit.com/products/2023/guides)

## Related Guides

- [Adafruit LED Backpacks](https://learn.adafruit.com/adafruit-led-backpack.md)
- [Running PyPortal Code on Blinka with Displayio](https://learn.adafruit.com/running-pyportal-code-on-blinka-with-displayio.md)
- [Wearable Continuous Temperature Monitor with Adafruit IO](https://learn.adafruit.com/wearable-temperature-monitor.md)
- [Fidget Spinner Tachometer](https://learn.adafruit.com/fidget-spinner-tachometer.md)
- [Speech Synthesis on the Raspberry Pi](https://learn.adafruit.com/speech-synthesis-on-the-raspberry-pi.md)
- [CircuitPython Hardware: LED Backpacks & FeatherWings](https://learn.adafruit.com/micropython-hardware-led-backpacks-and-featherwings.md)
- [Adafruit 2.8" and 3.2" Color TFT Touchscreen Breakout v2](https://learn.adafruit.com/adafruit-2-8-and-3-2-color-tft-touchscreen-breakout-v2.md)
- [CircuitPython Libraries on Linux and the 96Boards DragonBoard 410c](https://learn.adafruit.com/circuitpython-libraries-on-linux-and-the-96boards-dragonboard-410c.md)
- [I2C Addresses and Troublesome Chips](https://learn.adafruit.com/i2c-addresses.md)
- [CircuitPython Hardware: ILI9341 TFT & FeatherWing](https://learn.adafruit.com/micropython-hardware-ili9341-tft-and-featherwing.md)
- [CircuitPython Hardware: SSD1306 OLED Display](https://learn.adafruit.com/micropython-hardware-ssd1306-oled-display.md)
- [Programming SPI flash with an FT232H breakout](https://learn.adafruit.com/programming-spi-flash-prom-with-an-ft232h-breakout.md)
- [Adding a Single Board Computer to Blinka](https://learn.adafruit.com/adding-a-single-board-computer-to-blinka.md)
- [CircuitPython Display Support Using displayio](https://learn.adafruit.com/circuitpython-display-support-using-displayio.md)
- [Desktop or Laptop TFT Sidekick With FT232H](https://learn.adafruit.com/tft-sidekick-with-ft232h.md)
- [MicroPython Hardware: I2C Devices](https://learn.adafruit.com/micropython-hardware-i2c-devices.md)
