3 Replies Latest reply on Jun 17, 2014 12:50 AM by Randation

    Interrupt on GPIO value change


      I'm trying to handle simple GPIO events in node.js and have successfuly installed node v0.10.25 and installed/compiled the epoll module (fivdi/epoll · GitHub).


      Everything works fine, but it seems that GPIO changes do not fire EPOLLPRI interrupts.


      I have this example code from epoll module examples:


      var Epoll = require('epoll').Epoll,

        fs = require('fs'),

        valuefd = fs.openSync('/sys/class/gpio/gpio26/value', 'r'),

        buffer = new Buffer(1);

      // Create a new Epoll. The callback is the interrupt handler.

      var poller = new Epoll(function (err, fd, events) {

        // Read GPIO value file. Reading also clears the interrupt.

        fs.readSync(fd, buffer, 0, 1, 0);

        console.log(buffer.toString() === '1' ? 'pressed' : 'released');


      // Read the GPIO value file before watching to

      // prevent an initial unauthentic interrupt.

      fs.readSync(valuefd, buffer, 0, 1, 0);

      // Start watching for interrupts.

      poller.add(valuefd, Epoll.EPOLLPRI);

      // Stop watching after 30 seconds.

      setTimeout(function () {


      }, 30000);


      I wonder if anyone succeded in firing and handling interrupts on GPIO changes, with node.js or some other environment.