Hi guys,
i want to reads values from 4 GPIO (1 or 0)
and convert this 4 values to a binary sequence.
can i use a "join" node in node-red ? if yes how ?
Thanks in advance.
Welcome to the forum.
If you set a join mode to wait for 4 values and set it to put them into a string it should work. It will get complicated if you need them in any ordered way.
Yes, that is a way to do it. See the post in the node-red cookbook on Joining Streams for how to do it. In addition you will want to select And Every Intermediate Message in the Join node and make sure the four inputs have different topics.
Key Object pairs works better as it also shows the order:
[{"id":"f66c52e5.e79f","type":"join","z":"5542a8a0.2ca958","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"4","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":460,"y":220,"wires":[["c20ea9e0.d202e8"]]},{"id":"a01e6606.c17d38","type":"inject","z":"5542a8a0.2ca958","name":"","topic":"two","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":160,"wires":[["f66c52e5.e79f"]]},{"id":"a74767e2.c3a8b8","type":"inject","z":"5542a8a0.2ca958","name":"","topic":"four","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":280,"wires":[["f66c52e5.e79f"]]},{"id":"81b4c30e.59ce1","type":"inject","z":"5542a8a0.2ca958","name":"","topic":"three","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":220,"wires":[["f66c52e5.e79f"]]},{"id":"b3f07b2a.53a8b8","type":"inject","z":"5542a8a0.2ca958","name":"","topic":"one","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":100,"wires":[["f66c52e5.e79f"]]},{"id":"c20ea9e0.d202e8","type":"debug","z":"5542a8a0.2ca958","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":690,"y":220,"wires":[]}]
That's what the example in the cookbook does. For this case it will also need the Subsequent Messages box checked though, as the GPIO will only send values on change.
Good point Colin!
yes sir i need them in a certain order( sequence from least significant bit to the most significant bit)
Do you have any other solution ?
This might give you an idea how you can do it:
[{"id":"5542a8a0.2ca958","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"f66c52e5.e79f","type":"join","z":"5542a8a0.2ca958","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"4","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":460,"y":220,"wires":[["c20ea9e0.d202e8"]]},{"id":"a01e6606.c17d38","type":"inject","z":"5542a8a0.2ca958","name":"","topic":"two","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":160,"wires":[["f66c52e5.e79f"]]},{"id":"a74767e2.c3a8b8","type":"inject","z":"5542a8a0.2ca958","name":"","topic":"four","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":360,"wires":[["f66c52e5.e79f"]]},{"id":"81b4c30e.59ce1","type":"inject","z":"5542a8a0.2ca958","name":"","topic":"three","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":260,"wires":[["f66c52e5.e79f"]]},{"id":"b3f07b2a.53a8b8","type":"inject","z":"5542a8a0.2ca958","name":"","topic":"one","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":60,"wires":[["f66c52e5.e79f"]]},{"id":"c20ea9e0.d202e8","type":"debug","z":"5542a8a0.2ca958","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":690,"y":220,"wires":[]},{"id":"75d0a16c.2cad5","type":"inject","z":"5542a8a0.2ca958","name":"","topic":"one","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":100,"wires":[["f66c52e5.e79f"]]},{"id":"b4dd1c38.bae15","type":"inject","z":"5542a8a0.2ca958","name":"","topic":"two","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":200,"wires":[["f66c52e5.e79f"]]},{"id":"7ed05e27.b65e3","type":"inject","z":"5542a8a0.2ca958","name":"","topic":"three","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":300,"wires":[["f66c52e5.e79f"]]},{"id":"24f038fa.41f9e8","type":"inject","z":"5542a8a0.2ca958","name":"","topic":"four","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":400,"wires":[["f66c52e5.e79f"]]}]
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.