Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jperkin/node-rpio
Raspberry Pi GPIO library for node.js
https://github.com/jperkin/node-rpio
Last synced: 15 days ago
JSON representation
Raspberry Pi GPIO library for node.js
- Host: GitHub
- URL: https://github.com/jperkin/node-rpio
- Owner: jperkin
- Created: 2012-10-20T21:44:06.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2024-05-20T10:50:37.000Z (6 months ago)
- Last Synced: 2024-10-07T03:51:04.011Z (about 1 month ago)
- Language: C
- Size: 551 KB
- Stars: 859
- Watchers: 38
- Forks: 124
- Open Issues: 59
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
node-rpio
=========This is a high performance node.js addon which provides access to the Raspberry
Pi and SunXi (Allwinner V40) GPIO interfaces, supporting regular GPIO as well
as i²c, PWM, and SPI.[![NPM version](https://img.shields.io/npm/v/rpio.svg)](https://www.npmjs.com/package/rpio)
[![Node.js version](https://img.shields.io/node/v/rpio.svg)](http://nodejs.org/download/)
[![NPM downloads](https://img.shields.io/npm/dw/rpio.svg)](https://www.npmjs.com/package/rpio)
[![Build Status](https://travis-ci.org/jperkin/node-rpio.svg?branch=master)](https://travis-ci.org/jperkin/node-rpio)
[![License: ISC](https://img.shields.io/badge/License-ISC-yellow.svg)](https://opensource.org/licenses/ISC)
[![License: GPL v2](https://img.shields.io/badge/License-GPL%20v2-yellow.svg)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
[![Donations](https://img.shields.io/liberapay/receives/jperkin.svg)](https://liberapay.com/jperkin/)## Compatibility
* Raspberry Pi Models: A, B, A+, B+, 2, 3, 4, 400, Compute Module, Zero.
* SunXi (Allwinner V40) Models: Orange Pi Zero, Banana Pi M2 Zero / Berry.
* Node.js Versions: 0.8, 0.10, 0.12, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14.Currently only basic GPIO is supported on the SunXi chipsets.
Newer versions of node.js require you to install the GCC 4.8 packages for C++11
support. If you see compilation problems related to C++11, this is the likely
cause.Due to node-tap requirements the test suite only works on node.js version 6 or
above.## Install
Install the latest using npm:
```console
$ npm install rpio
```## Important System Requirements
This module will only interface with hardware on Linux, but should compile on
any other platform, where it will run in mock mode by default.### Disable GPIO interrupts
If running a newer Raspbian release, you will need to add the following line to
`/boot/config.txt` and reboot:```
dtoverlay=gpio-no-irq
```Without this you may see crashes with newer kernels when trying to poll for pin
changes.### Enable /dev/gpiomem access
By default the module will use `/dev/gpiomem` when using simple GPIO access.
To access this device, your user will need to be a member of the `gpio` group,
and you may need to configure udev with the following rule (as root):```console
$ cat >/etc/udev/rules.d/20-gpiomem.rules <> 7));
process.stdout.write(out.toString(16) + ((j % 16 == 0) ? '\n' : ' '));
}
rpio.spiEnd();
```### Misc
To make code simpler a few sleep functions are supported.
```js
rpio.sleep(n); /* Sleep for n seconds */
rpio.msleep(n); /* Sleep for n milliseconds */
rpio.usleep(n); /* Sleep for n microseconds */
```There will be a startup cost when calling these functions, so it is worth
performing some initial benchmarks to calculate the latency for your hardware
when using the high resolution functions, then factoring that in to your calls.Community benchmarks suggest that the cost for `usleep()` is 72 microseconds on
raspi-3 and 130 microseconds on raspi-1, with latency reducing significantly
after the first call.## Authors and licenses
Mike McCauley wrote `src/bcm2835.{c,h}` which are under the GPL.
I wrote the rest, which is under the ISC license unless otherwise specified.