logo
Kurashizu Blogwhere ideas flow
  • Home
  • News
  • Blog
  • About
  • Home
  • News
  • Blog
  • About

© 2026 Kurashizu. All rights reserved.

Admin·New Post·Service Status
Powered by Cloudflare·01.11.26
← Back to news

Gpiozero Flow

Original article
bennuttall.com|111 points|34 comments|by benn_88|Jul 30, 2026

Gpiozero Flow

By Ben Nuttall | Published 25 July 2026

Back in 2015, I conceptualized gpiozero. My goal was to create a Python library for the Raspberry Pi that simplified GPIO interaction through abstraction. Instead of forcing developers to wrestle with pin channels, voltages, pull-up resistors, and edge detection, I wanted them to think in terms of high-level concepts: Is the button pressed? Is the sensor detecting motion? Is the motor spinning forward?

Three Paths to the Same Result

We designed the library to support three distinct programming paradigms. Consider a simple task: making an LED react to a button.

ApproachLogic StyleImplementation Example
ProceduralPollingwhile True: if button.is_pressed: led.on()
Event-DrivenTriggeredbutton.when_pressed = led.on
ReactiveState-Followingled.source = button

While these achieve the same outcome, they differ in readability and flexibility. For instance, if you wanted to invert the logic (LED off when button is pressed), the first two methods are easy to modify, but the third requires a different approach.

To solve this, we introduced functions to manipulate the "stream" of data moving between devices:

"We provide tools to alter the value stream as it travels from source to destination."

For example, to reverse the logic: led.source = negated(button)

Or to create an automated oscillation using a sine wave: led.source = sin_values()

The Mathematics of Value Streams

The magic of gpiozero lies in its standardized value ranges. By using PWM (Pulse Width Modulation), we can treat an LED's brightness as a float within the range: 0≤brightness≤10 \le \text{brightness} \le 10≤brightness≤1

If we connect an analog input (like a potentiometer via an MCP3008) that also outputs a value between 000 and 111, the connection is seamless:

pot = MCP3008()
led = PWMLED(pin)
led.source = pot # Brightness follows the pot position

Some devices use a bipolar range, such as motors, where the range is: −1≤speed≤1-1 \le \text{speed} \le 1−1≤speed≤1 (Where 0→10 \to 10→1 is forward and 0→−10 \to -10→−1 is reverse).

To handle these transitions, we provide a suite of stream manipulation functions:

  • negated / inverted
  • clamped / scaled
  • absoluted / booleanized
  • zipped / smoothed

From Diagrams to a Visual Interface

During my time at Raspberry Pi, I often used flow diagrams in presentations and documentation to illustrate these relationships. This sparked an idea: Why not build a web-based UI?

I envisioned a canvas where users could drag-and-drop GPIO devices and connect them with lines. While tools like Node-RED exist, I found them too convoluted and too focused on pins →\to→ devices.

The Development Journey (2026)

By 2026, the availability of Claude made this project feasible. I provided a specification for a Minimum Viable Product (MVP) acting as a simulator, and we iterated rapidly.

Development Checklist:

  • Build core simulator prototype
  • Refine UI with icons and animations
  • Implement Python code generator
  • Create Pi-based websocket agent for remote control
  • Add localStorage for saving canvases
  • Implement Base64 JSON encoding for shareable links

Conceptual Flow Diagram

Expanding the Ecosystem

We integrated nearly every gpiozero device, including:

  1. Internal tools: TimeOfDay
  2. Artificial sources: sin_values
  3. Composite devices: We added the ability to break down complex devices (like traffic lights) into individual LEDs or convert them to PWMLEDs.

Regarding add-on boards, the "source/value" logic is tricky because boards are composites of multiple inputs and outputs. To solve this, I included boards as pre-configured components on the canvas, saving the user from manual pin assignment.

Overcoming Connectivity Hurdles

A significant technical challenge arose with HTTPS. Because secure origins cannot make insecure websocket connections to a local LAN device (and local devices lack SSL certificates), a standard hosted app couldn't talk to a Pi.

The Solution: I released a Python package called gpiozero-flow. This package bundles the websocket agent and the web app.

pip install gpiozero-flow

Now, the hosted version at flow.bennuttall.com allows you to simply enter your Pi's IP address or hostname. Your project is transferred via a share link, and you can toggle Live Mode to control physical hardware in real-time.

Conclusion

In essence, this is a graphical programming environment similar to Scratch, Blockly, or Edublocks. However, it is uniquely tailored to the logic of gpiozero, proving that while the basics are simple, the potential for advanced flow-based control is immense.