Raspberry Pi Foundation builds a bridge between PCs and GPIO pins
The Raspberry Pi and its ilk generally lack the computing horsepower of a modern desktop or laptop computer, but one area where they excel is in physical computing, or interacting with a wide range of devices that control things in the real world. Typical PCs lack general-purpose input-output (GPIO) interfaces, and when they exist, the documentation is typically very poor.
To make the best of both worlds, the Raspberry Pi Foundation has now come up with a tool called the GPIO expander to shuttle data from a powerful computer into and out of the real world using a Raspberry Pi Zero's GPIO pins. This tool lets the Pi serve as a sort of bridge between its GPIO pins and potentially much more powerful and complex software running on an x86 PC. Applications for computers using GPIO pins include toggling relays, checking the status of external circuits, and interfacing with sensors of multiple types like temperature, humidity, motion, and distance.
At the end of last year, the Pi Foundation ported its Raspbian Pixel development OS over to x86 PCs. Pixel got ease-of-use improvements in the intervening months, and the GPIO expander software is only its latest trick. The expander will allow developers to use a PC to access the GPIO pins of an attached Pi Zero using the visual programming language Scratch or a Python library.
The GPIO expander works by booting an attached Pi Zero from software stored on the host PC. In this configuration, the Pi Zero runs a minimal version of Raspbian and presents a USB Ethernet interface that the host PC can use to reach the GPIO pins. A Raspberry Pi running Raspbian can also serve as the USB host. The Pi Foundation says that when using multiple Pi Zero servants, a single Pi could possibly control up to 140 GPIO pins, a big increase from the usual 40. This developers haven't actually tried this multi-Pi approach, though, so tread carefully.
[email protected]:~ $ export GPIOZERO_PIN_FACTORY=pigpio [email protected]:~ $ export PIGPIO_ADDR=fe80::1%usb0 [email protected]:~ $ python3 >>> from gpiozero import LED >>> led = LED(17) >>> led.blink()
The GPIO expander software only works in the Pi Foundation's Debian-based releases of Pixel so far. Hopefully developers will port the capability to Ubuntu-based distributions in the near future, including Windows 10's Linux subsystem. For now, physical computing users will still need to resort to devices like the Bus Pirate in order to use GPIO pins on more common PC operating systems. For those interested in more information, the Pi Foundation's blog post has some interesting information about the new tool and its development.