Listening to key input from other pi devices in the dashbord

Hello everyone, this may sound like a dumb question but I am very new to node-red and was wondering if you had any thoughts on this.

I am running node-red from a main Windows device. I have multiple pi devices that I would like to listen for keystrokes and have it displayed in my node-red dashboard. That is the primary goal and was wondering if you had thoughts or suggestions on what to do.

So far, I have seen that to get messages from pi devices, the best way is to use MQTT to send messages out and then have node-red receive them with the MQTT module. Still not sure how the keystrokes would be sent through an established MQTT. Is this the best method or is there something else that’s better? I think once I get the keystrokes received in node-red then I can handle the display of it via changing a label’s variable to equal the payload, but it’s the steps in between where I am stuck.

Thank you in advance

Are you running node-red in the Pi?
If so have you worked out how node red can detect key presses?

I have not. I currently run node-red on the Windows machine that I am expecting to retrieve display from the pi. I wasn’t sure what the best way would be...

Keyword for transferring info between machines is spelled "MQTT"...as you already have found...so forget my comment

Node-red on pi does have a keyboard node that grabs key codes and and Mqtt node to send them

I am not sure what you mean by that. I thought you wanted to pickup keypresses.

If it is keypresses you want to pickup then you will need to run something in the pi to pick them up and publish them to MQTT on the Windows machine. I would do that by running node-red on the Pi. Alternatively if you know Python you could run a Python app on the Pi which does the publish.

Apologies, @Colin . To clarify, I want to have the keypresses in the RPi be sent to the Windows machine and be displayed on the node-red dashboard. I run an escape room and would like to monitor what players are keying in on a central dashboard instead of opening up vnc sessions for multiple RPi’s.

In that case the second half of my previous post applies. However, I am not sure that it is possible to monitor the keyboard without grabbing it. In other words if you pickup the keypresses in python or node-red I am not sure that they will go to other applications that want to use the keyboard. That isn't a node-red issue of course.

Thank you @Colin. So I already have a python script on the RPi that when it listens to a certain sequence, it would result in an audio file being played. From what you have said, I am interpreting it as if I run a node-red keypress module, the input to the node-red may negate what the Python script is listening to, therefore no longer play my audio file?

Give it a try.

In that case add to that script, sending every keypress off to MQTT for node-red on the PC. I believe MQTT in python is very easy.

Even easier in Node-RED...

Though node-red is not even installed on the pi. If @thepianocian is fluent in python then modifying the script may be easier for him.

I can install node-red on the pi. It seems easier to use the keypress in node-red then have to figure out the mqtt in pyhthon. I am more worried about whether using keypress will disable the listening of keypresses in the python script for audio activation.

We will look forward to you telling us the answer :slight_smile:

Look in the getting started guide for the instructions for installing on the pi.

1 Like

I guess to throw another wrench into it that I forgot to mention and realize it's important now...

Keypress works for the keyboard, but what I'm trying to do is listen to a USB joypad/gamepad controller's presses. I tried it out and it looks like the keyboard presses would be detected but the gamepad would not. Does node-red have any nodes that support this? Was looking at gamepad-controllizer but it doesn't look like that works with what I'm trying to do.

Does your python script pick up the data you need or does it too just read the keyboard?

The python script picks up gamepad presses but I do not have enough python knowledge to know what to do with it so that is why I was opting for a node-red solution if possible.

OK, so you do have a path for a solution if you can't find a node-red method.

well under the covers Node-RED is using python to monitor /dev/input/by-path/kbd :slight_smile: so maybe you can find how that device is registering by watching the /dev/input/by-path (or by-id) directory and plugging and unplugging the device to see what appears... and go from there.