Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. MicroPython
  3. micropython-rotary

micropython-rotary

MITPython

A MicroPython driver for reading rotary encoders with hardware interrupt support and effective debouncing.

GitHubGitHub
339 stars61 forks0 contributors

What is micropython-rotary?

micropython-rotary is a MicroPython library for interfacing with rotary encoders on embedded development boards. It reads encoder rotations using hardware interrupts and implements a debouncing state machine to provide accurate and reliable counts. The driver supports various range modes, configurable increments, and platform-specific optimizations for boards like ESP32, Raspberry Pi Pico, and Pyboard.

Target Audience

Embedded developers and hobbyists working with MicroPython on devices like ESP32, Raspberry Pi Pico, or Pyboard who need to integrate rotary encoders for input control in projects such as dials, menus, or parameter adjustment interfaces.

Value Proposition

Developers choose this library for its robust debouncing implementation, interrupt-driven efficiency, and cross-platform support. It offers a reliable, battle-tested solution adapted from Ben Buxton's proven algorithm, reducing software glitches and ensuring accurate encoder readings in resource-constrained embedded environments.

Overview

MicroPython module to read a rotary encoder.

Use Cases

Best For

  • Adding rotary encoder input to MicroPython-based embedded projects
  • Building control interfaces with dials or knobs on ESP32 or Raspberry Pi Pico
  • Implementing menu navigation systems in embedded devices
  • Creating parameter adjustment controls for IoT devices
  • Developing instrumentation panels with rotary input
  • Prototyping hardware interfaces with reliable debouncing

Not Ideal For

  • Projects using CircuitPython or other non-MicroPython embedded Python environments
  • Applications where software polling is sufficient and interrupt overhead is undesirable
  • Systems with GPIO pins that do not support interrupts or have strict boot sequence constraints
  • Developers needing built-in argument validation and error handling

Pros & Cons

Pros

Interrupt-Driven Responsiveness

Uses hardware interrupts for immediate pin change processing, ensuring real-time updates without constant polling, as detailed in the 'Interrupt based' section.

Proven Debouncing Algorithm

Implements Ben Buxton's state machine for reliable contact noise filtering, adapted from his C++ work, ensuring accurate counts as highlighted in the acknowledgements.

Flexible Configuration Options

Supports multiple range modes, reverse direction, half-step mode, and configurable increments via constructor parameters, allowing customization for various use cases.

Platform-Specific Optimizations

Includes tailored files for ESP8266/ESP32, Pyboard, and Raspberry Pi Pico to handle hardware differences, as shown in the file installation guide.

Cons

No Argument Validation

The library does not check for configuration errors in arguments, as stated under Methods, which can lead to runtime issues if pins or values are misconfigured.

Manual File Management

Requires copying platform-specific files separately, though mip install eases this, adding setup complexity compared to single-file or drop-in libraries.

Interrupt Limitations

Depends on GPIO interrupt support, and some pins have boot sequence risks, as noted in the README for ESP8266/ESP32, limiting pin choice and potential conflicts.

Frequently Asked Questions

Quick Stats

Stars339
Forks61
Contributors0
Open Issues15
Last commit2 years ago
CreatedSince 2018

Tags

#encoder#interrupts#micropython#esp32#driver#hardware#embedded#esp8266#pyboard#debouncing#rotary-encoder#tinypico#raspberry-pi-pico#micropython-driver#gpio

Built With

M
MicroPython

Included in

MicroPython1.8k
Auto-fetched 1 day ago

Related Projects

encodersencoders

Assorted code ideas, unofficial MP FAQ, plus index to my other repositories.

Stars532
Forks95
Last commit1 month ago
encodermenuencodermenu

Simple GUI menu for micropython using a rotary encoder and basic display.

Stars117
Forks20
Last commit5 years ago
AS5600AS5600

AS560 Micropython library for reading this magnetic sensor

Stars42
Forks10
Last commit1 year ago
rotary-encoderrotary-encoder

Code to drive a rotary encoder in micropython

Stars30
Forks9
Last commit3 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub