How to pick a msg from a msg stream

Hi there!
I got the following scenario:

  • sensor A is delivering continuously data by means of serial interface
  • sensor B is delivering one trigger msg every once in a while (operator hits a button)

What I am trying to achieve is the following:
At the moment the sensor B msg is received the next msg (or previous is ok too) of sensor A shall be picked. The data of both msg needs to be merged. The merged data of msgA and msgB are then handled in following nodes.

How can I do something like that in node-red?
Thanks a lot!
JR

One way is with the contrib node node-red-contrib-queue-gate. Sensor B will trigger the release from the queue of the last message from Sensor A.

Untitled 1

[{"id":"b002bb26fe613d70","type":"inject","z":"a8b6a475c8d16c7d","name":"SENSOR A","props":[{"p":"payload"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":370,"y":300,"wires":[["a9610aec39003a2b"]]},{"id":"43c205f1871ca9fa","type":"inject","z":"a8b6a475c8d16c7d","name":"SENSOR B","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"control","payload":"trigger","payloadType":"str","x":370,"y":340,"wires":[["a9610aec39003a2b"]]},{"id":"a9610aec39003a2b","type":"q-gate","z":"a8b6a475c8d16c7d","name":"","controlTopic":"control","defaultState":"queueing","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","peekCmd":"peek","dropCmd":"drop","statusCmd":"status","maxQueueLength":"1","keepNewest":true,"qToggle":false,"persist":false,"storeName":"memory","x":530,"y":320,"wires":[["bc1885523c19002e"]]},{"id":"bc1885523c19002e","type":"debug","z":"a8b6a475c8d16c7d","name":"debug 265","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":320,"wires":[]}]
1 Like

Wow, thank you so much! That works for me.
Cheers
JR

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.