Wiring-PI interrupt problem ( wiringPiISR )

424 views
Skip to first unread message

Dennis Henning

unread,
Oct 10, 2016, 6:08:36 PM10/10/16
to Node-RED
hi,

i want to realize something like a pulse counter for one or more inputs on my raspberry pi 2.
For example i want to post a message to a mongodb database on every pulse etc.

i tried to implement this with nodered and wiringpi.

Simple LED toggle example with wiring pi in nodered works fine so i think it is installed properly.

LED toggle example function:


// select wpi pin 0 = pin 11 on header (for v2)
var pin = 5;

// initialise the wpi to use the global context
var wpi = context.global.wpi;

// use the default WiringPi pin number scheme...
wpi.wiringPiSetup();

// initialise the state of the pin if not already set
// anything in context.  persists from one call to the function to the next
context.state = context.state || wpi.LOW;

// set the mode to output (just in case)
wpi.pinMode(pin, wpi.OUTPUT);

// toggle the stored state of the pin
(context.state == wpi.LOW) ? context.state = wpi.HIGH : context.state = wpi.LOW;

// output the state to the pin
wpi.digitalWrite(pin, context.state);

// we don't "need" to return anything here but may help for debug
return msg;


for my interrupt test i used a function node and attached a debug output to it.

interrupt test:

var newMsg = { payload: msg.payload};


var wpi = context.global.wpi;


wpi.wiringPiSetup();



wpi.pinMode(7, wpi.INPUT);
wpi.pullUpDnControl(7, wpi.PUD_OFF);

wpi.wiringPiISR(7, wpi.INT_EDGE_FALLING, function(delta) {
  return newMsg;
});


if i try to test this function nothing happens.. and after a short while my pi ( nodered ) got stuck so i have to reboot the system or kill the process.


can i use the default gpio IN node which is included in nodered for this approach ?
can i adjust the default IN node  trigger edge !?

thank you for your help !
isrtest.PNG

Dave C-J

unread,
Oct 10, 2016, 6:36:39 PM10/10/16
to node...@googlegroups.com
the gpio nodes use the interrupt edge anyway so I'd start with them anyway.

Dennis Henning

unread,
Oct 10, 2016, 8:08:08 PM10/10/16
to Node-RED
Thank you!
Reply all
Reply to author
Forward
0 new messages