/ microcontroller monday

Microcontroller Monday - Adafruit FT232H - CircuitPython

alt

This isn't the first time that this board has crossed my path, in fact it first landed on my desk in 2015!

So what is it?

A USB to serial breakout board that enables any PC to have a series of GPIO pins broken out and ready for use on a breadboard. In the past it used a Python 2 library to control the state of the pins, but now there is a CircuitPython library.

CircuitPython?

CircuitPython is a fork of MicroPython, a version of Python 3 for microcontrollers. It was created by the Adafruit team and in a short amount of time it has become quite a popular language.

But why is Python popular?

Python has seen a great surge in popularity, and right now we can use it on devices as small as a microcontroller, or as large as a data centre. We can create physical computing projects using the same language which is used to manage data centres for NASA. Python is becoming the best cross platform / project language to get the job done.

Yeah but language x is better because it is quicker / compiles / produces Unicorns. This is probably true, and these platforms offer great benefits over Python. But if I can use Python on many different devices, I reduce the amount of work required for me to create a project.

So what can FT232H with CircuitPython offer?

It is still very early days for this project, but at the time of writing we have GPIO pin access, SPI and I2C. We cannot use Neopixels :( at this time, but I am sure that this will change in future updates.

Update 15/10/2019 Neopixels via SPI!

Adafruit have released a Neopixel library for SPI, which means the FT232H can now use Neopixels via the SPI interface :)

The FT232H is merely an interface board between our big PC and the electronic components that we wish to control. We install CircuitPython on our PC and this in turn talks tot he FT232H.

So is it easy to install?

Pretty much yeah. Follow Adafruit's instructions and you are ready to go.

So why should I use this over a typical CircuitPython device?

Now that is a good point. The FT232H is a remarkable piece of kit but it is $15. So why do we need it? Well the thing is we don't. This is a special piece of kit and those using it with CircuitPython will be creating projects that rely on buttons and LEDs and a powerful computer to back it up. Think of it as a device that enables your PC to have a small number of GPIO pins.
If we do not need the power of a full PC, and our project can be run directly for the device, then perhaps a Trinket M0 or Gemma M0 is more for you.

So what did you build Les?

IMG_20191014_132603
First of all I made a quick flashing LED project, you press the button and the LED flashes ten times.

Screenshot-from-2019-10-14-13-21-32

Here is the code!

import board
import digitalio
import time

led = digitalio.DigitalInOut(board.C0)
led.direction = digitalio.Direction.OUTPUT
button = digitalio.DigitalInOut(board.C1)
button.direction = digitalio.Direction.INPUT

while True:
    if button.value == True:
        for i in range(10):
            led.value = True
            time.sleep(0.2)
            led.value = False
            time.sleep(0.2)

Is that all you made?

Well no, I also made a quick demo of a button controlled web browser.
Press the button and a web page opens in your default browser.

import board
import digitalio
import webbrowser
import time

button = digitalio.DigitalInOut(board.C1)
button.direction = digitalio.Direction.INPUT

while True:
    if button.value == True:
        time.sleep(0.2)
        webbrowser.open_new_tab("http://bigl.es")

So where can I buy an FT232H?

In the USA you can go direct to Adafruit and for the UK you can pick one up from Pimoroni.

Happy Hacking