USB Dongle Brings Python-Controlled GPIO To The Desktop

Microcontroller dev boards are wonderfully useful items, in testament to which most of us maintain an ample collection of the things. But dragging one out to do a simple job can be a pain, what with making sure you have the whole toolchain set up to support the device, not to mention the inevitable need to solder or desolder header pins. Wouldn’t it be nice if there was a simple plug-and-play way to add a few bits of GPIO to your desktop or laptop machine?

[Nick Bild] thinks so, and came up with the USBgpio. The hardware in the dongle is pretty much what you’d expect — an Arduino Nano 33 IoT. Yes, you could just bust out a Nano and do this yourself, but [Nick] has done all the heavy lifting already. Eleven of the Nano’s IO pins plus 3.3V and ground are broken out to header pins that stick out of the 3D-printed enclosure, and the dongle is powered over the USB cable. [Nick] also built a Python library for the USBgpio, making it easy to whip up a quick program. You just import the library, define the serial port and baud rate, and the library takes care of the rest. The video below shows a quick blinkenlight test app.

Earth-shattering stuff? Perhaps not; [Nick] admits as much by noting the performance doesn’t really dazzle. But that’s hardly the point of the project, and if you need a couple of pins of IO on the desktop for a quick tactical project or some early-stage prototyping, USBgpio could be your friend.

25 thoughts on “USB Dongle Brings Python-Controlled GPIO To The Desktop

  1. “Wouldn’t it be nice if there was a simple plug-and-play way to add a few bits of GPIO to your desktop or laptop machine?”

    Yep… there was, with the emphasis on “was” it was called the parallel port. Quick, easy, cheap, relatively fast and accessible.

      1. In the before times, I remember making LPT cables to play multiplayer games, then serial cables, then null modems, then…

        This is the big clapback when people talk about how AWEMAZZZING raspberry pis are. “But muh GPIO!”

        Form factor? Point to the Pi.

        Power consumption? Conditional point to the Pi.

        GPIO? Oh FFS, LPT1: does the job

        …and a garage sale computer at the same price point will have orders of magnitude more horsepower and flexibility than your hipster hot credit card.

    1. In certain limited circumstances, one can use the handshake lines of an RS-232 serial port.

      If your I/O consists of a pushbutton or dry contact relay in a piece of equipment, looping back RTS/CTS and/or DTR/DSR works well. Either of those outputs can be looped back through either of the inputs, and through RI so there are three semi-crude inputs available on many 9 pin ports.

      (I suppose with two controllable outputs and three inputs, one could even set up a six button key matrix.)

    2. I see LPT1: and LPT2: silk screens and through holes for unused headers on modern motherboards. Are those just relics, or would they work with a bit of brave soldering?

    1. Thanks, came here to say try Adafruit_blinka library and the MCP2221A, python meets Circuitpython. Also with the linked board it has the usual suspects of gpio type pins plus a StemmaQT/qwiic/JST-SH 4pin I2C quick connect port. There’s alternatively the FT2232 breakout, but loads of options supported by Blinka.

      -disclosure- I’m lucky enough that Adafruit currently pay me to work on their Arduino stuff and IoT things, but been a fanboy of good open source software and hardware my whole life so make of it what you will

  2. So it’s using the serial communication to relay pin commands from desktop to the Arduino? I’ve considered doing something like that before, a nice general solution for this would be really nice – a library you could include that implemented a standardized messaging system that you could apply to any Arduino compatible board. But on the PC side, I would also hope for more than just Python support.

  3. This is most likely trivial, and I don’t want to start a war, however wouldn’t case be a little faster than elseif statements in the code to read/write/pull high and low on the gpio pins as far as the code ON THE microcontroller is concerned? Please correct me, if I’m wrong.

    1. It might be if the compiler doesn’t optimize it for you automatically, but I would only start worrying about it until performance actually becomes an issue.

      I work on some enterprise code where perfomance is a genuine concern for some processes, and it’s a different language on processors orders of magnitude more powerful than an arduino, but I’ve never had a scenario where if else was the bottleneck, it’s usually just inefficient logic or lack of caching.

  4. I tought the same, it’s a firmata sketch, but, hey, there are ways to improve it.

    I’m thinking probably some extra pin rows, one for transistorized output with the option of external power, in which one can work let’s say with 12v DC. (another one of open-collector serie?)
    I certainly would have insert in the box the resistor + led combo, in order to see what is happening.
    Also, the lib (I didn’t look at it, probably is already there) can have some more precise modes, like jiggle with microseconds on/off pulsses (think of even move servos), or specific bitbanged secuencies.

    Also, all that instruments already exists, but, I think the collective could improve this simple small swiss knife.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.