Oct 122015
 
GPIO Zero - Introduction

If you’re a RasPi.TV regular, you’ll know that one of my very favourite things is hacking around with the GPIO ports on the Raspberry Pi and sharing my findings with the world. Sometimes this involves documenting a new feature, sometimes it involves making a new project, using a new chip or just getting something working that I haven’t tried before. But it nearly always involves Python programming and the brilliant RPi.GPIO Python library by Ben Croston. I’ve written all sorts of tutorials (~16) on RPi.GPIO because it is one of my favourite things. You may […more…]

Aug 122015
 
RPi. GPIO GPIO.getmode() function

Another new RPi.GPIO feature that I discovered last week is GPIO.getmode(). This appeared in RPi.GPIO 0.5.11 and allows you to query RPi.GPIO to see whether GPIO.setmode() has been set up as BCM, BOARD, or UNSET mode. This could be useful if you are running a suite of scripts or modules which work together. GPIO.getmode() returns… -1 if GPIO.setmode() is not set 11 if GPIO.setmode(GPIO.BCM) is active 10 if GPIO.setmode(GPIO.BOARD) is active Below you can see a live python session showing what you get when you use GPIO.getmode() with different modes set… Why Did You Bother […more…]

Aug 102015
 
RPI.GPIO New Feature GPIO.RPI_INFO replaces GPIO.RPI_REVISION

In RPi.GPIO 0.5.10 (we’re now on 0.5.11) Ben Croston ‘deprecated’ GPIO.RPI_REVISION, which used to be the preferred way to find out what kind of Raspberry Pi board a program was running on. This was a useful feature to make it possible to write software that will work on any Pi, regardless of how its GPIO pins are arranged. To date, we’ve had three different GPIO pin header layouts for the standard Raspberry Pis (four if you count the compute module). But GPIO.RPI_REVISION has been deprecated (fallen out of favour) because there is now something better. […more…]

Jul 142015
 
RasPiO GPIO Ruler

For some time now I’ve been using the wonderful RPi.GPIO Python library by Ben Croston. It’s great for using the General Purpose Input Output (GPIO) ports on the Raspberry Pi to control things and read inputs. I’ve written at least 14 tutorials on it (listed here) over the last couple of years. But I still find myself needing to look up the exact commands to use. I’ve made a crib-sheet which is really useful, but pieces of paper get lost. What I really want is the most used commands in a portable, accessible form that […more…]

Jul 252014
 
RPi.GPIO update and detecting BOTH rising and falling edges

A few days ago, Ben Croston updated the RPi.GPIO Python library so that the ‘board’ pin numbering system would work with all of the pins on the B+. It doesn’t really affect the way I work, as I always use BCM port numbers. They already worked on the B+ and the compute module. While he was at it, he made a couple of bug-fix tweaks. Looking at what was tweaked, I realised there are a couple of features of RPi.GPIO that I hadn’t yet documented. In this blog post I hope to update my RPi.GPIO […more…]

Jul 192013
 
RPi.GPIO basics 7 – RPi.GPIO cheat sheet and pointers to RPi GPIO advanced tutorials

In the previous six articles, we’ve covered the basics of RPi.GPIO. I hope the series has been useful. While I was doing the “recap” for part 6, I decided to make myself a quick reference “cheat sheet” with all the common RPi.GPIO stuff in it. I figured this would be useful and save me having to look things up on the web and in previous Python scripts I’ve written. I made it as a text file that I can just copy and paste snippets of code from to make RPi.GPIO Python coding easier. Then I […more…]

Jul 172013
 
RPi.GPIO basics 6 – Using inputs and outputs together with RPi.GPIO - pull-ups and pull-downs

Today, it’s time for us to combine inputs and outputs into the same script. It’s nothing scary and it’s not new either. It’s simply a case of doing what we’ve already done in the last two days’ of GPIO basics, but combining them. To make it super-easy, we’ll even stick to the same port numbers we used for the last two days. We’re going to make a new program which takes parts from both the “read a button press” and the “flash an led every half second” programs. We’re going to make a simple new […more…]

Jul 152013
 
RPi.GPIO basics 5 – Setting up and using outputs with RPi.GPIO

Today is output day. I’m going to show you how to switch things on and off using RPi.GPIO to control the output ports of the Raspberry Pi. Once you can control outputs, you can, with a few additional electronic components, switch virtually anything on and off. Given the Raspberry Pi’s excellent connectivity, this means you can switch things on and off through the internet, using any computer, smartphone or tablet from anywhere in the world. You can also use a local network, Bluetooth etc. for short-range control. Setting up is very similar to the way […more…]

Jul 142013
 
RPi.GPIO basics 4 - Setting up RPi.GPIO, numbering systems and inputs

Well, today is the day we actually get to use RPi.GPIO a little bit. But, before we get to that, you should know about the two different numbering systems you can use with RPi.GPIO. If you take a look at the main GPIO header (P1) of the Raspberry Pi, you’ll see that there are 26 pins. The top left pin (as we look at this photo) is called pin 1, the one to the right of it is pin 2. So the next row is 3, 4 etc. and on down to 25, 26. This […more…]

Jul 132013
 
RPi.GPIO basics 3 - How to Exit GPIO programs cleanly, avoid warnings and protect your Pi

You might think I’m going about this series in a funny way. You’d be right! I am. That’s because I’m trying to highlight the bits that people don’t read about in other tutorials/documentation/manuals/books. These bits are useful, important and often overlooked. If I covered inputs and outputs first, you might not get to the rest because you’d already “know all I need”. That’s only partially true though. Although you can get away with not knowing or using this stuff, it’s much better and safer if you know it and use it. So today we’re focussing […more…]