I2C

PyFtdi has support for I2C along with some additional useful scripts. You can install it with
pip3 install pyftdi
For more detailed install instructions, see https://eblot.github.io/pyftdi/installation.html

i2cscan.py is included with PyFdti. If you run it with no parameters, it will just list all the connected FTDI devices:

Available interfaces:
ftdi://ftdi:2232:1:e/1 (Dual RS232-HS)
ftdi://ftdi:2232:1:e/2 (Dual RS232-HS)

Please specify the USB device

ftdi:2232:1:e refers to your tigard board. The /1 and /2 refer to which port. See the documentation for more about the URL scheme. We use the second port for I2C, and it’s the only device attached, so we can just say:

i2cscan.py ftdi:///2

PyFtdi alone is great for throwing together code to quickly interface with an I2C device. Circuitpython already has libraries for tons of I2C devices, but is geared towards microcontrollers. Blinka is a neat way of using all the CircuitPython libraries on top of regular python. Now that FT2232H support is included in Blinka releases, it’s pretty easy to set up:

  1. First, install Adafruit’s Blinka library:
    pip3 install Adafruit_Blinka
  2. Next, install the libraries you’ll plan to use – we used the adafruit-circuitpython-ssd1306 library in the video:
    pip3 install adafruit-circuitpython-ssd1306
    pip3 install adafruit-circuitpython-ht16k33
  3. Finally, we set up our environment to point to Tigard:
    export BLINKA_FT2232H=1

Now, it’s time to interact with some I2C devices. Based heavily on Adafruit’s examples, I modified oled-print-ft2232h.py and led-8×8-ft2232h.py. Take a look at Adafruit’s documentation on:

A neat aspect of Blinka is that you can prototype all your code on your computer with tigard, and then take that same python script and run it on circuitpython on a microcontroller or other system.

In order to test the production run of Tigard, I prototyped the test cases and used a tigard to display status to an OLED display; then copied it all to a Raspberry Pi so the factory could test them as soon as they were assembled – see more in the following video.