You are currently viewing the United Kingdom version of the site.
Would you like to switch to your local site?
16 MIN READ TIME

GPRTK.GPIO

Add Raspberry Pi GPIO to your PC

PCs don’t offer a GPIO header like the Raspberry Pi, but Mike Bedford reveals that a low-cost add-on is all you need to join in the fun.

Credit: https://github.com/PiSupply/Ryanteck

OUR EXPERT

Mike Bedford uses both PCs and Raspberry Pis, so is quite taken with this method of providing convergence between the two platforms.

The Raspberry Pi might be the poor relation to the PC in performance, but that diminutive single-board computer wins hands down in one area. While a PC’s interfacing options are limited to USB, video, audio and wired and/or wireless networking, the Pi adds the all-important GPIO. That, in turn, enables it to be used to control and monitor external electronics and sensors, and thereby work in conjunction with pretty much any equipment.

Thanks to the Ryanteck RTk.GPIO board, all that changes, and an ordinary PC can, like the Pi, be used with external electronics and hardware. Here we’re going to see how to use the RTk.GPIO, irrespective of whether or not you’re a Raspberry Pi user. If you’re a Pi user, this board enables you to migrate some of your projects to your PC, or use some of your Pi HATs – the add-on boards that plug into the Pi’s GPIO connector – with a PC. Alternatively, if you’re firmly in the PC-only camp, the RTk.GPIO gives you the opportunity to get some experience of real-world interfacing.

Add-on hardware

While PCs don’t have a general purpose input/output (GPIO) port as standard, various hardware solutions are available to add this missing functionality. Traditional products that do this are generally referred to as data acquisition, or DAQ, devices, and connect via USB or occasionally plug into the motherboard. They usually provide digital and analogue I/O so, in that respect, are more powerful than the Pi’s GPIO. However, they don’t offer any level of compatibility with the Pi GPIO, so migrating projects or HATs isn’t easy. However, the biggest drawback is cost. Products start upwards of £100 and rise to several thousands.

The RTk.GPIO costs just a few pounds and adds a GPIO port, similar in most respects to the Pi’s, to your PC.
CREDIT: ELEGOO

QUICK TIP

We didn’t have a sufficiently demanding application to put it to the test, but we did note some online postings about the RTk.GPIO that compared its response time unfavourably to that of the Pi. However, we suspect it won’t be an issue for most users’ applications.

PWM BASICS

The Raspberry Pi’s GPIO header is entirely digital, so there are no analogue outputs or inputs. However, using PWM – which the Pi supports, but the RTk.GPIO can only provide via software – it’s possible to generate an analogue output signal on a GPIO output pin, albeit with limitations. Given that not all Pi users will be familiar with PWM, here’s a brief intro.

PWM stands for pulse width modulation, and the diagram (right) shows how it works. In the top part, the output pin is shown as set to a binary 0, so the pulse width is 0% and the voltage is 3.3V. In the middle part, the PWM has a 50% pulse width, so the average output voltage is half of 3.3V, namely 1.65V. The other parts show 25%, 75% and 100% widths. If the frequency of the pulses is high enough, and the requirement isn’t too demanding, this works as well as outputting a true analogue voltage. If you use it to drive an LED, for example, and the frequency is at least 100Hz, we wouldn’t see it flickering on and off, so it could be used for dimming the LED.

Better approximation to a steady analogue voltage can be achieved using an RC (resistorcapacitor) circuit to average out the pulses and give something more like the dotted red lines. This reduces the speed at which the analogue voltage can change, although using a higher PWM frequency, and thus a lower value of capacitor, helps. This means the RTk.PIO’s slower software-based PWM isn’t as good as the Pi’s hardware PWM.

Unlock this article and much more with
You can enjoy:
Enjoy this edition in full
Instant access to 600+ titles
Thousands of back issues
No contract or commitment
Try for 99p
SUBSCRIBE NOW
30 day trial, then just £9.99 / month. Cancel anytime. New subscribers only.


Learn more
Pocketmags Plus
Pocketmags Plus

This article is from...


View Issues
Linux Format
September 2023
VIEW IN STORE

Other Articles in this Issue


MEET THE TEAM
MEET THE TEAM
This issue, we’re getting AIs to badly develop ap plications for us. Hurrah! So, what are you going to do with all the spare time your personal AI is going to free up?
Not so smart
A rtificial intelligence is like any other tool
REGULARS AT A GLANCE
Newsdesk
THIS ISSUE: EU threat to open source Plasma features face chop Gnome opens window plans Debian embraces RISC-V
JUST BUGGIN’
Jon Masters is a kernel hacker who’s been
Kernel Watch
Jon Masters keeps up with all the latest happenings in the Linux kernel, so you don’t have to.
ONGOING DEVELOPMENT…
John Ogness posted Wire Up Nbcon Consoles, which
Answers
Got a burning question about open source or the kernel? Whatever your level, email it to answers@linuxformat.com
Mailserver
WRITE TO US Do you have a
Hot Picks
Immich
ATTACK OF THE A.I. Pi BOTS
Fun artificial intelligence projects you can build and run at home on the cheapest of hobbyist hardware!
REVIEWS
BarraCuda 8TB HDD
Cheap and cheerful – that’s not how Shane Downing parties.
GeForce RTX 4060
A good graphics card with the wrong name, ponders Chris Szewczyk.
Murena Fairphone 4
Fairest of them all, Jonni Bidwell is excited by an ethical phone with a privacy-respecting operating system.
Peppermint OS
After years of sampling Linux Mint, Nate Drake opts for something spicier in the hybrid Peppermint OS, which integrates cloud-based apps.
Fatdog64 Linux 814
Nate Drake decides to look in on Fatdog, a Puppy-based OS that’s grown into a very credible canine in its own right.
ROUNDUP
Media-creation distros
Michael Reed examines five distributions, aimed at creative types, that come packed with applications, utilities and plugins.
Customisations & extra features
How much does each distro add?
Base distro and package repros
We need a strong foundation with access to the latest software.
Using the user interface
Creative flow is paramount.
System efficiency
It’s a shame if the distro starts gobbling up resources before you’ve even started.
Audio, music and plugins
Showcasing what Linux can do in this realm and saving installation effort.
Video and graphics apps
Ready-to-go drawing and painting applications are always welcome.
Documentation and support
Information on how to get things running and overcome difficulties.
The verdict
Media-creation distributions
A.I. CODING
Matt Holder spends some time discovering how AI, ML and LLM can be used to help us with our programming – and, yes, he explains what the acronyms mean as well…
Pi USER
Pi Foundation open sources its Code Editor
Accelerating feature development and generally doing the right thing all round, hurrah!
RP2040 ETH Mini Dev
Les Pounder loves all his Pi collection, but sometimes there’s some he simply can’t love as much…
Sonic Mini 8K S
Always on the lookout for upgrades, Denise Bertacchi doubly likes it when there’s a bargain, too.
Build a flashy dice roller with NeoPixels
Les Pounder is learning to multitask but we think he misunderstood the instructions.
Smart management for smart kiosks
Tam Hanna takes a look at how Ubuntu Frame harnesses Wayland’s strengths to make smart display management more comfortable.
TUTORIALS
Best kept secrets
A man who keeps his cards close to his chest, we struggled to persuade Shashank Sharma to reveal how he protects his passwords.
Upgrade your Steam Deck SSD
Neil Mohr asked hardcore PC gamers Tony Polanco and Katie Wickens to upgrade a Linux device – what could possibly go wrong?
Access services with Nginx reverse proxy
Nick Peers discovers how to open your network services to the internet with this user-friendly implementation of Nginx.
Render real-world 3D maps in Blender
Credit: www.blender.org
ADMINISTERIA
A ROCKY ROAD AHEAD?
Stuart Burns is a Linux administrator for a
Docker is dead, long live Docker
Docker has been the king of containers but could Podman put an end to Docker’s reign?
LXD gobbled up by Canonical
LXD ownership is transferred to Canonical in the hope of making great strides.
Who installed that?
Yum is more than just a way to install applications – it can do all sorts of interesting stuff.
HostPapa
Ruby P Jane tries this paternal web host provider that offers a range of services for both personal and business use.
Cloudways
A competent host offering scalable cloud-based solutions that has Ruby P Jane loving what she sees.
IN DEPTH
AWS vs Azure
What’s the difference? Not all cloud providers are the same. Steve Cassidy compares the two biggest platforms
CODING ACADEMY
Text adventure combat mechanics
Often found making love and not war, this month Nate Drake takes our interactive text adventure down a dark, violent path.
Code your own Breakout retro game
Matt Holder discovers that writing a ’70s-style classic game isn’t as simple as he first thought.
Creating Flutter apps
David Bolton shows how to set up a Flutter development environment on Linux and then how to build a simple calculator in Flutter.
Chat
X
Pocketmags Support