Add GPIOs to Windows, Linux, Android Computers and Devices with FTDI USB Adapters / Breakout Boards

It’s possible to to add GPIOs to your computer, (openWRT) router, or Android tablet using some FTDI USB dongles that expose I/Os. On operating systems based on Linux, including Android, you can use the GPIO sysfs interface (/sys/class/gpio) to easily control GPIOs from the command line, and in some cases Rx, Tx, CTS, .. pins can also be used as GPIOs. Zoobab has tried it with various FTDI USB adapters, and Oneping OP-1010 breakout board based on PL2303 HDX chip, and the results are mixed, but it could worth a try.

oneping_op1010
Oneping OP1010 Breakout Board

There are currently patchsets ([1] and [2]) awaiting acceptance to mainline kernel that will enable GPIO support for these USB devices, but in the meantime you need to patch the kernel yourself, and then enable the relevant options in the kernel config for example “USB_SERIAL_PL2303_GPIO” or “USB_SERIAL_FTDI_SIO_GPIO”. The first patch is for PL2303 chips, and the second for FT2xxx/FT4xxx chips, so it should work on most USB to serial debug board out there.

Then you can export the GPIOs (done with OP1010 board) from your Linux PC / board:


and change the values as follows to confirm it’s working:


Even if it is working with OP1010, some other boards do not work, as despite the GPIOs being detected, the values can’t be changed. Other boards that are known to work, at least partially, include JTAGkey Tiny, Arduino Duemilanove, Moderndevice BUB1, and MicroFTX.

You can also control GPIOs for PL2303HXD / EA / RA, from an OTG capable Android device with Prolific PL2303 USB-GPIO app, but apparently not all tablets will work properly, and zoobab finally tested it with Android-x86-4.4-r1 image successfully.

Oneping also provides a Windows app for OP1010, which is demonstrated in the video below. They talk in Chinese, but it’s still easy to understand how it all work even if you can’t understand a word.

I’ve been unable to find Oneping OP-1010 board online, and I’ve been told you need to contact them by email, pay by Paypal (around $10) to receive a sample. Anyway this can also be tested with other low cost FTDI adapters. There are also some other USB modules exposing GPIOs such as Sparkfun’s FT232RL breakout board, or a Numato board with 8 GPIOs and up to 6 analog inputs (share with GPIOs), but I’m not sure the latter support GPIO sysfs interface.

Share this:
FacebookTwitterHacker NewsSlashdotRedditLinkedInPinterestFlipboardMeWeLineEmailShare

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK 5 ITX RK3588 mini-ITX motherboard

20 Replies to “Add GPIOs to Windows, Linux, Android Computers and Devices with FTDI USB Adapters / Breakout Boards”

  1. @zooba
    Are you sure about Antwerps? I think they use the same model as eud.dx.com. Ship from china using Netherlands post. It still takes a lot of time to deliver.

  2. @Alan, maybe the android FTDI kit is something for you. http://www.ftdichip.com/Android.htm

    I have used a FTDI kit like the zooba linked to (bought from ebay shipped to the Netherlands) to build a Nixie clock on Openwrt with C. Works great, AFTER you replace the default time daemon selected for the wr703n by Openwrt.
    For hardware I used simple 3 stage shift registers (74HC595) with K155NA1 (nixie drivers) and the wr703n.

    https://www.dropbox.com/s/7ynhhap0f4qt8sq/2014-10-20%2018.35.32.jpg?dl=0

  3. FWIW: I’m now using the builtin GPIO’s of my Raspberry. Super easy. No kernel patching, just a few lines of Python … great.

  4. Those pretty much standard FTDI FT2232H/FT4232H mini modules seem to be most trouble free, and there is native mainline support on Linux kernel since… Dunno, years.

    And the libftdi is available for virtually all Linux distros, very easy, and simple, to integrate to any kind of app.

    Bitbanging is hitting the wall around 600kbps though.

  5. @anon
    Sysfs is slow, yeah, but for some usage it is good enough (toggling some pins on the shell, or in a shell script). There are some applications which supports sysfs (avrdude, urjtag, openocd, etc…).

    If there is a standard interface for fast bitbanging in kernel space and which does not require to integrate your own code with a libary, I am all for it, but at the moment, it is not there.

    Openocd has for example some code for the PI to use memory-mapped gpios, but this is not what I would call a standard way to access GPIOs.

  6. @zooba
    Creating an kernelspace state machine for bitbanging could accelerate it quite a bit, but as is pretty ugly niche thing, I bet it would never be integrated into mainline Linux… Maybe some FreeRTOS/L4 kernel could handle that, but no idea is there any interest for such thing there either.

  7. @cnxsoft
    Yet another reason not to use Windows and closed-source drivers. The sysfs patch was possible because the driver is open. And those kind of nasty hostile drivers are not possible (at least the community will have an opportunity to reject them) in the free software world.

  8. [ Is there todays/new hardware for USB with dma or memory shift registers for high speed gpio applications available? (thx) ]

Leave a Reply

Your email address will not be published. Required fields are marked *

Khadas VIM4 SBC
Khadas VIM4 SBC