Pi-gpio input pull / buffering message

Hi everyone,

I need some assistance on how to buffer a message if there's no network or get a pulled state of a Raspberry GPI.

I have a state on a GPI, sending it via udp to another system. But as soon as the network connection is disconnected, of course this message will be lost. So I'm looking for a way of buffering it, until I know, the other device can receive that message.

The alternative would be a way to get the RPI GPI state by pulling the state rather then pushing through the RPI GPI node, if there's any way to do that.

Thanks for you help, have a good day!
32Domi / Dominik

You can save it in the context.
https://nodered.org/docs/user-guide/context

Having thought about it a rather pleasing solution would be to use node-red-contrib-queue-gate with its recently added features peek and drop. Set in to queueing mode, with a limit of 1 message and to keep the latest message. Then use the peek method to get the latest message, send it to the other system and when you are sure it has gone ok then drop the message from the queue.

However an even better solution (if it is practical in your case) would be to use MQTT, Have a broker on the local system and write the values to that using a retained topic rather than sending them out via UDP (which is not guaranteed to get through even when the network is connected). At the other machine subscribe to the broker to receive the data for that topic. Then if the network fails you don't need to take any special action. When it recovers and the remote machine reconnects it will automatically be sent the latest data.

I will try that as soon as possible and let you know how I got it sorted out.

Sadly the software on the server, that should get that message, is not able to handle mqtt. So I would need to add another layer for transforming it, which I would rather try to avoid.

Thank you and you will hear the results!

You could run node red on the server too, pick the data up via mqtt and pass it to the s/w which will then be on localhost, so you can assume it will always connect. Then you can let mqtt handle the network problem.

Hi there! Update: I tried the queue-gate node and it works like a charm. This is exactly what I needed and will help me in other purposes, too.
Thanks a lot for your kind help. :slight_smile:

Domi

1 Like

Excellent.

1 Like