Adafruit I2C devices which work with the Raspberry Pi & BeagleBone Black also use the Adafruit Python GPIO library and can easily be configured to work with the FT232H. Some of these devices include:
Wiring
Like the FT232H guide mentions, when using I2C you'll need to setup your circuit with external pull-up resistors connected to the I2C clock and data lines. 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. 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.
Next wire your I2C device to the FT232H SDA and SCL lines just as you would for a Raspberry Pi or BeagleBone Black. 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. Also remember the FT232H board digital outputs operate at 3.3 volts and the digital inputs can safely accept either 3.3 volts or 5 volts.
Note with the setup above the I2C pins SDA and SCL will be pulled up to 5 volts when idle! 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 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). Check the instructions on the SPI setup page for more details on installing this library.
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. You should run the software library's setup.py script and pass it the install parameter. For example on a Mac or Linux machine, in a command terminal navigate to the directory with the library's source code and execute:
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:
python setup.py install
(make sure Python is added to your path 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. 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:
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. For example with the BMP085/180 breakout the code would look like:
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. See the SPI page for an example of passing this gpio parameter.
That's all there is to configuring a device to use the FT232H with I2C! You can now use the device just like the library example code shows.
Here's the full simpletest.py example for the BMP085/180 ported over to use the FT232H:
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())
Text editor powered by tinymce.