A Node.js library for GPIO access and interrupt detection on Linux boards like Raspberry Pi and BeagleBone.
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.
Developers working on IoT projects, robotics, or hardware prototyping who need to control and monitor GPIO pins from Node.js applications on Linux boards.
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.
GPIO access and interrupt detection with Node.js
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Provides simple read/write methods and interrupt handling with a clean API, as demonstrated in the LED and button examples using watch and writeSync.
Includes a debounceTimeout option to handle button bounce issues, shown in the debouncing example where it delays callbacks until input stabilizes.
Tested on Raspberry Pi (1-4) and BeagleBone boards with various Node.js versions, ensuring reliability on popular hardware as listed in benchmarks.
The Gpio.accessible property allows easy mocking when GPIO access isn't available, facilitating development on non-Linux systems with virtual LEDs.
Relies on the Linux sysfs interface at /sys/class/gpio, which is optional and may not be available on all Linux boards, reducing compatibility.
Does not support configuring pullup and pulldown resistors directly; developers must use platform-specific methods outside the library, as admitted in the README.
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.