Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

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

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Node.js
  3. onoff

onoff

MITJavaScript

A Node.js library for GPIO access and interrupt detection on Linux boards like Raspberry Pi and BeagleBone.

GitHubGitHub
1.3k stars124 forks0 contributors

What is onoff?

onoff is a Node.js library that provides GPIO (General Purpose Input/Output) access and interrupt detection for Linux-based single-board computers like the Raspberry Pi and BeagleBone. It allows developers to read from and write to GPIO pins, handle hardware interrupts, and debounce button inputs, solving the problem of interfacing JavaScript applications with physical hardware.

Target Audience

Developers working on IoT projects, robotics, or hardware prototyping who need to control and monitor GPIO pins from Node.js applications on Linux boards.

Value Proposition

Developers choose onoff for its straightforward API, support for both synchronous and asynchronous operations, built-in debouncing, and reliable performance across popular platforms like Raspberry Pi and BeagleBone, making hardware interaction accessible from Node.js.

Overview

GPIO access and interrupt detection with Node.js

Use Cases

Best For

  • Controlling LEDs and reading button states on Raspberry Pi
  • Building IoT devices with Node.js and GPIO
  • Handling hardware interrupts for sensor inputs
  • Prototyping robotics projects with BeagleBone
  • Debouncing mechanical switches in embedded applications
  • Mocking GPIO functionality in development environments

Not Ideal For

  • Projects requiring high-frequency GPIO toggling above 20kHz
  • Non-Linux systems or boards without the sysfs GPIO interface
  • Applications needing integrated pullup/pulldown resistor configuration

Pros & Cons

Pros

Intuitive GPIO Control

Provides simple read/write methods and interrupt handling with a clean API, as demonstrated in the LED and button examples using watch and writeSync.

Built-in Debouncing

Includes a debounceTimeout option to handle button bounce issues, shown in the debouncing example where it delays callbacks until input stabilizes.

Cross-Platform SBC Support

Tested on Raspberry Pi (1-4) and BeagleBone boards with various Node.js versions, ensuring reliability on popular hardware as listed in benchmarks.

Mockability for Development

The Gpio.accessible property allows easy mocking when GPIO access isn't available, facilitating development on non-Linux systems with virtual LEDs.

Cons

Sysfs Dependency Limits Portability

Relies on the Linux sysfs interface at /sys/class/gpio, which is optional and may not be available on all Linux boards, reducing compatibility.

Missing Hardware Configuration Features

Does not support configuring pullup and pulldown resistors directly; developers must use platform-specific methods outside the library, as admitted in the README.

Performance Constraints for High-Speed Apps

Benchmarks show maximum interrupt detection around 20k per second, which may be insufficient for applications requiring very rapid signal processing compared to alternatives like pigpio.

Frequently Asked Questions

Quick Stats

Stars1,258
Forks124
Contributors0
Open Issues7
Last commit2 years ago
CreatedSince 2012

Tags

#iot#hardware#embedded#interrupt#beaglebone#beaglebone-black#nodejs#linux#javascript#raspberry-pi#gpio

Built With

N
Node.js

Included in

Node.js65.5k
Auto-fetched 1 day ago

Related Projects

johnny-fivejohnny-five

JavaScript Robotics and IoT programming framework, developed at Bocoup.

Stars13,403
Forks1,733
Last commit2 years ago
serialportserialport

Access serial ports with JavaScript. Linux, OSX and Windows. Welcome your robotic JavaScript overlords. Better yet, program them!

Stars5,986
Forks1,012
Last commit5 months ago
usbusb

Improved USB library for Node.js

Stars1,650
Forks287
Last commit1 day ago
pigpiopigpio

Fast GPIO, PWM, servo control, state change notification and interrupt handling with Node.js on the Raspberry Pi

Stars968
Forks87
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