Skip to content

Dead-simple and minimal V8 addon for Node.js to work with GPIO, with TypeScript typings, based on wiringPi (or similar, like wiringOP) library

Notifications You must be signed in to change notification settings

Irelynx/node-wiring-pi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node.js Wiring PI (V8 C++ addon)

Dead-simple and minimal V8 C++ addon for major versions of Node.js (tested on 10+) to work with GPIO. Includes TypeScript typings.

Installation

npm install https://github.com/Irelynx/node-wiring-pi

# or 

git clone https://github.com/Irelynx/node-wiring-pi
cd ./myNodejsApp
npm install ../node-wiring-pi

Usage after installation

const wpi = require('node-wiringPi')

// or 

const {
  wiringPiSetup,
  piBoardRev,
  digitalRead,
  digitalWrite,
  pinMode,
  delay,
  delayMicroseconds,
  LOW,
  HIGH,
  INPUT,
  OUTPUT
} = require('node-wiringPi');

Verified versions of Node.js that works with addon

  • Node.js v10.23.0 (V8 v6.8.275.32)
  • Node.js v14.15.3 (V8 v8.4.371.19)

Tested at: 2020.12.30, on Orange Pi Zero (H2+, 512MB)

Requirements

Available functions/variables

Name Type Description
wiringPiSetup(): Number function Initial Setup, must be called before any other function will be called
piBoardRev(): Number function Get Pi board revision
pinMode(pin: Number, mode: OUTPUT | INPUT): void function Set pin mode
digitalWrite(pin: Number, value: LOW | HIGH): void function Write digital value
digitalRead(pin: Number): LOW | HIGH function Read digital value
delay(ms: Number): void function SYNC Milliseconds delay
delayMicro(mks: Number): void function SYNC Microseconds delay
LOW: Number = 0 Number LOW digital signal value
HIGH: Number = 1 Number HIGH digital signal value
INPUT: Number = 0 Number INPUT mode
OUTPUT: Number = 1 Number OUTPUT mode

Why yet another GPIO module?

  • Major part of modules in NPM or GitHub for wiringPi library, that provides GPIO access, does not compile on newer versions of Node.js, or uses different versions of wiringPi with tweaks, or developers refuse to support new versions of Node.js (because of V8 API changes, like "removing" v8::Handle), or projects are completely abandoned
  • Practice

Used links and documentations

About

Dead-simple and minimal V8 addon for Node.js to work with GPIO, with TypeScript typings, based on wiringPi (or similar, like wiringOP) library

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published