Closed jupiter8888 closed 6 years ago
firmata sends digital reads in groups of 8 to the host (firmata.js in this case). This happens when any one pin in the group changes. firmata.js loops through the 8 pins (aka the port) and emits a digital-read-N
where N is the pin number for each of those 8 pins whether they have changed or not.
It sounds like firmata is behaving as expected and you need checks in node-red or your code to make sure action is only taken when the value on the relevant pin changes. This means storing pin state. Have you asked this question over in the node-red community?
Yes, i i can get away with adding some RBE nodes on each inputs. No big deal.
Thank you for your explanation, very clear now.
might want to try running a test with just firmata.js. Both node-red-contrib-gpi and node-red-arduino use firmata.js under the hood, so not sure why multiple events would be triggered unless firmata.js isn't tracking state changes correctly
@montesul I don't think that's something firmata.js tries to do. In J5 we are tracking state on each instance (button, etc) and deciding whether or not to fire there.
Here are the relevant lines:
https://github.com/firmata/firmata.js/blob/master/lib/firmata.js#L124-L149
oh right, thanks @dtex the node-red stuff just hooks into the events of the IO class. I remember this bothering me about ports a couple of years ago, and I had a protocol proposal to do individual pins instead.
That said, another option for @jupiter8888 's issue could be to use the J5 instance from the node-red-contrib-gpio nodes and use J5 components like the buttons you mentioned. The RBE node should work as well.
i'm having this issue in Node-Red both with the arduino node and the contrib-gpio node wich use firmata, and a raspberry pi. Tried also with Node-red on a pc and on an orange pi, same result.
Here's the thing:
I have a digital only board filled with RC circuits on every inputs. (12 of them on an Uno) and if i switch, say input 4, the GPIO node 4 gives "0" (true), that's normal, BUT, EVERY other GPIO nodes give 1 (false, wich is their actual state) so all the pins are reporting their state on state change of one pin.
the node says "It only outputs on a change of value", is this a bug or i'm doing something wrong here?
Thanks.