Node bindings for libwiringPi

Usage no npm install needed!

<script type="module">
  import nodeWiringpi from '';



Extremely simple node wrapper for @drogon's wiringPi library (for blinky lights & gpio w/ RaspberryPi)


This package assumes you know how to safely handle electronics and program GPIO pins. It's concievable you could damage yourself or your Raspberry Pi with improper circuit design or improper use of software interfaces. While the author of this package has made reasonable efforts to insure the accuracy of the information and code contained within, it comes with absolutely no warranty or guarantee of correctness.


Before installing and/or building this package, please make sure you have the wiringPi library and the node-gyp package installed. WiringPi info can be found at Node-Gyp info can be found at


The easiest way to install this package is via npm:

    npm install node-wiringpi

Or, you can check out the source using git:

    git clone git://


If the package wasn't automagically built when you installed via npm, this command should do the trick:

    node-gyp configure build

You'll have problems if you haven't installed node-gyp or libwiringPi.


I wrote a very simple LED blinker (this assumes you have a RPi w/ LEDs attached to GPIO pins. To run the program, use the command:

    sudo node blinkin.js

You have to run the program as root so it has permission to access /dev/mem. You could modify the permissions on this file, but please don't do that unless you understand how big of a security hole you're creating.


We currently only support two wiringPi calls: pinMode() and digitalWrite(). Hopefully the only thing you wanted to do was to write to the GPIO ports.

Start off by requiring the package:

    var wpi = require( 'node-wiringpi' );

If you're curious, you can call the num_pins() function to find out how many GPIO pins you have:

    console.log( "you have " + wpi.num_pins() + " GPIO pins." );

Before you write to GPIO lines, you should set them in output mode. This snippit sets pins 0 and 1 into output mode:

    wpi.pin_mode( 0, wpi.PIN_MODE.OUTPUT );
    wpi.pin_mode( 1, wpi.PIN_MODE.OUTPUT );

Once in output mode, you can write HIGH or LOW values to the pin. This sequence turns pins 0 and 1 on and off:

    wpi.digital_write( 0, wpi.WRITE.LOW );
    wpi.digital_write( 1, wpi.WRITE.LOW );
    wpi.digital_write( 0, wpi.WRITE.HIGH );
    wpi.digital_write( 1, wpi.WRITE.HIGH );