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.
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:
1 2 3 4 |
root@sabayon /sys/class/gpio [22]# echo 252 > export root@sabayon /sys/class/gpio [23]# echo 253 > export root@sabayon /sys/class/gpio [24]# echo 254 > export root@sabayon /sys/class/gpio [25]# echo 255 > export |
and change the values as follows to confirm it’s working:
1 2 |
root@sabayon /sys/class/gpio [22]# echo 1 > gpio255/value root@sabayon /sys/class/gpio [22]# echo 0 > gpio255/value |
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.
Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.
Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress
You know what would be great? A cheap China phone that exposes extra IO pins.
Maybe this $4 board based on FT232RL would also do: http://www.aliexpress.com/item/Free-shipping-1pcs-FT232RL-FTDI-USB-3-3V-5-5V-to-TTL-Serial-Adapter-Module-for/1902980198.html
There’s also another PL2303-HDX board with explicit GPIO support, sold on a Vietnamese website for about $5: http://www.tme.vn/Product.aspx?id=1734#page=pro_info
This FTDI breakout board is way cheaper and Electrodragon ships from Antwerp:
http://www.electrodragon.com/product/ftdi-serial-adapter-for-arduino-avr-pic-etc/
I am waiting for my package, will update the page when I have it.
@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.
@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
@Johny007
See this comment: http://hackaday.com/2014/08/26/new-chip-alert-the-esp8266-wifi-module-its-5/#comment-1760842
I live in Belgium, received a parcel from electrodragon last week, but it looks like it was sent from HK. I will triple check back home.
FWIW: I’m now using the builtin GPIO’s of my Raspberry. Super easy. No kernel patching, just a few lines of Python … great.
@zoobab
It looks like Electrodragon is doing the same as Eu-dx. The package was shipped via air priority to a postbox in BE, which is then reshipped via the belgian post.
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.
@iamfrankenstein[nl]
awesome! thank you for the link.
@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.
@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.
What ever you do don’t use the latest ftdi drivers either direct from them or windows update.
They’ll brick clone devices including arduino clones
http://hackaday.com/2014/10/22/watch-that-windows-update-ftdi-drivers-are-killing-fake-chips/
http://arstechnica.com/information-technology/2014/10/windows-update-drivers-bricking-usb-serial-chips-beloved-of-hardware-hackers/
That includes anything with a serial interface.
@Al
http://zeptobars.ru/en/read/FTDI-FT232RL-real-vs-fake-supereal
@Al
Bricking unauthorized/illegal chip clones is a bad thing?
@Al
Just as a note, there’s a new patch to keep these bricked devices working in Linux.
@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.
@cnxsoft
Where is that patch?
@zooba
Oops sorry, I forgot to include the link….
http://www.spinics.net/lists/linux-usb/msg115963.html
[ Is there todays/new hardware for USB with dma or memory shift registers for high speed gpio applications available? (thx) ]