PyCon Russia keynote – Physical computing with Python and Raspberry Pi

I was invited to give the closing keynote at PyCon Russia, which took place in Moscow in July. It was my first visit to Russia – and I had a great trip.

Ben Nuttall on Twitter

Today I am mostly being the Raspberry Pi Community at @PyConRu

I travelled with David McIver, the author of property-based testing framework, hypothesis. I also got to spend some time with other international speakers including Jackie Kazil (whom I met on my 2014 US Tour), Python core developer Raymond Hettinger, Google developer Nathaniel Manista, and (local) Armin Ronacher, the creator of the Flask web framework.


Here’s the video of my talk on Physical computing with Python and Raspberry Pi. I spoke about the Raspberry Pi, the Foundation and its mission, and lots of technical detail about the GPIO Zero library:

Physical computing with Python and Raspberry Pi, Ben Nuttall, Raspberry Pi

Uploaded by ??????? ?????????? on 2016-07-13.

You’ll find my slides on speakerdeck.

What’s new in GPIO Zero v1.3?

One year ago today, I started the GPIO Zero project. We now have a core team of three (Dave Jones, Andrew Scheller and me). There have been 587 commits, we’ve released four major versions, and published a book. The library has great coverage of GPIO devices, and contains features I never even dreamed of. In the last year I’ve delivered workshops and given talks about it at conferences and events around the UK, the US and even in Russia. It’s being used in Raspberry Pi’s learning resources, and teacher training and by hobbyists around the world. Read on to find out what’s new in the latest release.

GPIO Zero v1.3 is out now! Install it (or upgrade) with:

sudo apt-get update
sudo apt-get install python3-gpiozero python-gpiozero

What does this release bring?

  • New ButtonBoard class
  • New Servo and AngularServo classes
  • New CPUTemperature class
  • Improved remote GPIO support
  • Plenty of behind-the-scenes changes
  • Lots of new recipes


The new ButtonBoard class is a composite device representing multiple buttons. The idea being you can pass the value set from a collection of buttons into another collection of the same size: e.g. matching buttons to LEDs. You can also process the value set to get the information you want, for example the number of buttons pressed; any pressed, all pressed, proportion pressed or more. We’re currently discussion options for documenting these examples and possibly extending the features of this class in Issue #425.


The long-discussed Servo classes have now arrived! Servo allows you to move a servo between its minimum, maximum and mid-point positions:

from gpiozero import Servo
from time import sleep

servo = Servo(17)
while True:

AngularServo allows you to move a servo to specific angles:

from gpiozero import Servo
from time import sleep

s = AngularServo(17, min_angle=-45, max_angle=45)

s.angle = 0.0
s.angle = 15
s.angle = 45
s.angle = -45

We’re currently discussing what else should be added to the servo classes for different use cases.


We introduced some internal devices which act like regular GPIO Zero classes. CPUTemperature allows you to access the Pi’s CPU temperature, and use it to control other devices:

from gpiozero import LEDBarGraph, CPUTemperature

temp = CPUTemperature(min_temp=50, max_temp=90)
graph = LEDBarGraph(5, 6, 13, 19, 25, pwm=True)
graph.source = temp.values

Now the LEDs will light up according to the temperature: at 50 degrees all the LEDs will be off; at 90 degrees they’ll all be on; at 70 degrees half will be on; and anything in-between. There’s also a TimeOfDay class provided but it’s not working properly at the moment so I’ll cover that in the next release post.

Remote GPIO support

I talked about this last time. It’s really exciting. It was amazing to see this working in v1.2 but support wasn’t really very good, so its use was limited. However, significant work has gone into remote GPIO support since then and it’s going to be really powerful. Thanks to a pigpio, a C library from GitHub user joan2937, we can set up GPIO Zero devices connected to pins on Pis over a network. Easily.

Usually, you’d set up an LED like so:

from gpiozero import LED

led = LED(17)


Where the 17 refers to pin 17 on the Pi you’re executing the code. You can also do this:

from gpiozero import LED
from gpiozero.pins import PiGPIOPin

pin = PiGPIOPin(17, host='')
led = LED(pin)


Here, rather than simply specifying the number 17, we’ve provided a reference to a pin on another Pi on the network. This means you can remotely control the LED connected to that other Pi.

However, an easier method is to supply the Pi’s IP address in an environment variable. Before running the python shell, IPython, IDLE or whatever you’re using, simply set the PIGPIO_ADDR environment variable:

$ PIGPIO_ADDR= python

to run a file, or:

$ PIGPIO_ADDR= ipython3

to run the IPython shell, for example. Each of these will be set up so that when you type led = LED(17), it uses pin 17 on that remote Pi. Note: you’ll need to enable Remote GPIO, start the pigpio daemon, and install the pigpio python client on your host machine. See full instructions in this gist.

Of course, you can mix these methods and use a default pin factory but also specify pins on other Pis.

To set this up, you need the pigpio Python library installed on the device you’re running the code, and the pigpio daemon running on the remote Pi (and remote GPIO enabled in raspi-config). Read the pins documentation for more info.

Did I mention you can run this on any PC, not just on a Pi? That’s right. You can install GPIO Zero on your laptop and run GPIO Zero code which communicates with a Pi on the network. The Python code is running on your laptop, which communicates with the pigpio daemon using sockets. The daemon does all the GPIO stuff. I’ve seen this working on Linux, Mac and Windows. Admittedly, we need to provide much more solid instructions for getting this working if we want it to be seen as a viable solution for schools, Code Clubs and such. But it’s a start. Please give feedback if you’re using it (if you have any issues or not – we’d love to know). There’s also some interesting stuff around. If you know your way around installing with pip on Windows and Mac, we could use your help! See Issue #434.

What’s next?

We didn’t complete all the things we had on the list for this release, but we decided to push it out anyway, and leave the rest to the next release. As well as lots of minor improvements, we intend to add I2C support, including I2C expander chips (and probably SPI expander chips while we’re at it), which will be really handy. You’ll be able to set up an expander chip, and index it to refer to each pin, and create regular device objects on those pins, something like this:

from gpiozero import IOExtender, LED

ext = IOExtender()
led = LED(ext[0])


Then there’s temperature sensors, different types of motors, servos and more. Feature requests welcome on GitHub! We’re also aiming to establish a release schedule for future releases.


Again, thanks to Dave Jones and Andrew Scheller for all their hard work in the last release, and to everyone who provided useful feedback on GitHub. Keep it coming!


Dave and I will be giving a talk together on GPIO Zero at PyConUK this week. The video will be available shortly after the conference. We’re also running a sprint on GPIO Zero, welcoming new developers to the library. Come and have a go if you’re available, and we’ll show you where to start.

Simple Electronics with GPIO Zero book

Today the MagPi team released a new publication: Simple Electronics with GPIO Zero.


This 100-page book takes you from the basics, like lighting an LED, all the way to building projects like an Internet radio using the GPIO Zero Python library.

This book is available as a free PDF, but you can also pay to get it for your iPad or Android device with the MagPi app. Soon it will also be released in print. It’s now available in print. All proceeds go towards the Raspberry Pi Foundation’s education programmes.


I’ve been amazed with how the GPIO Zero project has grown. There have been three major releases (a fourth due later this year), and it has been featured in The MagPi many times, and in three Kickstarter projects: the RasPiO Pro HAT; Analog Zero; and GPIO Zero Ruler.

Also check out the GPIO Zero documentation, the Physical Computing with Python resource, and GPIO Zero on GitHub.

2015 Open Source Yearbook

I contributed to the 2015 Open Source Yearbook, created by, which you can download as a PDF or view the individual articles online.

Open Source Yearbook 2015

The 2015 Open Source Yearbook is a community-contributed collection of the year’s top open source projects, people, tools, and stories. Download the 2015 Open Source Yearbook (PDF) now!

  1. 6 creative ways to use ownCloud – by Jos Poortvliet, ownCloud community manager
  2. 10 tools for visual effects in Linux with Kdenlive – by Seth Kenlon, independent multimedia artist, free culture advocate, and UNIX geek
  3. 6 useful LibreOffice extensions – by Italo Vignoli, founding member of The Document Foundation
  4. Top 5 open source community metrics to track – by Jesus M. Gonzalez-Barahona, co-founder of Bitergia
  5. 5 great Raspberry Pi projects for the classroom – by Ben Nuttall, education developer advocate for the Raspberry Pi Foundation
  6. 8 books to make you a more open leader – by Bryan Behrenshausen, for The Open Organization
  7. 5 handy Drupal modules – by Michael E. Meyers, the VP of Developer Relations at Acquia
  8. Best Couple of 2015: tar and ssh – by David Both, Linux expert and enthusiast
  9. 3 open hardware projects for beginners – by Alicia Gibb, CEO of Lunchbox Electronics
  10. 10 helpful tools for a sys admin’s toolbox – by Ben Cotton, support engineer group leader at Cycle Computing
  11. Top 10 open source projects of 2015 – by Jen Wike Huger, an editor for
  12. 5 favorite 3D printing projects of 2015 – by Harris Kenny, VP of Marketing at Aleph Objects
  13. Top 5 open source frameworks every application developer should know – by John Esposito, Editor-in-Chief at DZone
  14. Publisher’s picks: 29 open source books for 2015 – by Rikki Endsley, Community Manager at
  15. Diversity in open source highlights from 2015 – by Cindy Pallares-Quezada, an Outreachy alumni
  16. Adafruit’s best open source wearables of 2015 – by Becky Stern, director of wearables at Adafruit
  17. 2015 was a good year for creating the world’s ‘missing maps’ with OpenStreetMap – by Drishtie Patel, GIS Analyst and Missing Maps Project Coordinator at the American Red Cross
  18. 5 favorite open source Django packages – by Jeff Triplett, Frank Wiles, and Jacob Kaplan-Moss, Django contributors
  19. Facebook’s top 5 open source projects of 2015 – by Christine Abernathy, Developer Advocate on the Open Source team at Facebook
  20. 10 projects to fork in 2016 – by Jason Baker,
  21. 10 cool tools from the Docker community – by Mano Marks, director of developer relations at Docker, Inc.
  22. 5 best open source games of 2015 – by Robin Muilwijk, Internet and e-government advisor


Raspberry Pi Weekly

Back in 2013, inspired by PyCoders Weekly, a great Python email newsletter, I created Pi Weekly, the same sort of thing for Raspberry Pi. Each week I curated a collection of links to news, projects and articles from the Raspberry Pi community. Its subscriber base grew steadily and within a few weeks it was featured on the Raspberry Pi blog. Towards the end of that year I was given the opportunity to go and work for the Raspberry Pi Foundation, and I continued to run the newsletter in the same format.

140 weeks into the project, having not missed a single week, it was relaunched with a new look and moved into the Raspberry Pi website as the Foundation’s official newsletter.

All past issues are available to browse on the website

I created a simple system for the newsletter generation. The whole thing is based within in a WordPress site, and issues are just posts with a set of custom fields, a repeater for the links, and a post template to show the issue as a web page. Then a plugin I wrote generates a full document of the same content in email-friendly HTML. For Pi Weekly, this was just a bog standard Mailchimp email template with my content in it, but for the official Raspberry Pi Weekly, I created a custom template made by our designer Sam Alder. The code for Pi Weekly is available on GitHub, it just requires the ACF plugin and the appropriate custom fields created. It would be fairly easy to create such a system in another CMS or web framework.

I wrote more about how Pi Weekly started and how it played a part in getting me hired at the Foundation in Pi Weekly – MVP, Evolution and My Dream Job and you can see how I announced it in Announcing Pi Weekly.

Be sure to check out the new Raspberry Pi Weekly