RPi Tutorial Easy GPIO Hardware & Software
- GPIO Protection Circuits
- Basic Circuits: LED output - DC motor - Switch Input - Analogue Sensor
- Intermediate Circuits: Shift Registers - Analogue to Digital - Driving Circuit - Alpha-Numeric Display
- Advanced Circuits: Control Hardware Over The Internet
While most of these circuits may interface directly to the RPi, the use of a buffered interface (such as the one supplied by the Gertboard) is recommended which will help protect against damage. Alternatively, experiment with one of the #Alternative Test Platforms.
Extreme caution should be exercised when interfacing hardware at a low level, you may damage your RPi, your equipment and potentially yourself and others. Doing so is at your own risk!
This tutorial is based on this thread and aims to introduce basic circuits which can be used with the RPi's General Purpose Input/Output (GPIO). Basic electronics knowledge will be required (i.e. familiarity with typical discrete components such as transistors, diodes and resistors).
- Online Circuit Lab - Circuit Design and Simulation - Excellent tool for experimenting with circuits (also used for the circuit diagrams used here)
- Introduction To Embedded Programming - GPIO - In particular there is lots of detailed information about GPIO inputs and outputs for beginners to understand the principles behind the circuits.
- Microchip's PIC Tips and Tricks PDF - Contains lots of useful example circuits for use with PIC micro-controllers, can be adapted for use with the RPi (3.3V GPIO).
- The Electronics Club - An excellent resource for beginner electronics, explains many basic circuits.
Alternative Test Platforms
Until you have a RPi to test with, there are many alternative platforms available which will allow the testing of basic circuits. In addition, they may be interfaced with directly using the RPi in the future.
- TI LaunchPad - A low cost development platform ($4.30 including free world shipping). Includes programmer/debug board, two processors (with 16 GPIO including I2C/SPI/UART, 8ch 10bit ADC etc).
- Arduino - Common hobbyist development platform. Excellent community support and additional hardware.
- STM32 Primer/EvoPrimer - Self-contained development platform. Mentioned since I may use one at some point (I bought the original Primer a long time ago). It includes a battery, acceleration sensors and built in display screen.
Note: Until RPi devices are available, I can not confirm this will work on a real RPi. For now, I shall be using the TI LaunchPad (see Alternative Test Platforms for details) to test the hardware on (as it is cheap and the logic levels similar).
1. LED output
Directly driven (will need very low powered LED) or driven via transistor (allowing higher current).
1. LED output
Completed see above.
MOSFET or Darlington Pair to provide high power drive and reverse bias diode to protect from motor coils.
With or without de-bouncing.
Using a basic transistor switch circuit.
An introduction to using additional ICs. In this case, using a parallel to serial 8-bit shift register to read 8 digital inputs using two GPIO pins.
Use of a ADC chip to sample inputs.
For example motor speed control.
(IN-PROGRESS) Control via 4-wire data (total 6 GPIO) and also alternative 2-wire interface circuit.
Implement web control and monitoring of GPIO connected components.
Contributing to this tutorial
This is an open project so please feel welcome to add your own sections and improve its content.
Please see the Talk:RPi Tutorial Easy GPIO Hardware & Software page to discuss this page.