New to Node-Red.. is this possible?

hi.. i have just discovered Node-Red and was wondering if it may be able to help me with a little project i have in mind...

I want to create a small device with one button that a user can press and it sends either a keystroke, or midi note to a windows PC over bluetooth or an OSC address over wifi..

id like to create the program and then buy a Raspberry Pi Zero W, make a small enclosure for it with one big button, add a power source and close it.. when it gets turned on it boots into the program automatically and just has one button which does one thing and therefore fairly foolproof...

i have very limited coding skills and while i could probably manage some simple stuff its the bluetooth or wifi connection to windows and setting it up as a HID or OSC client where i think it might get hard ?

is this possible with Node-Red and if so relatively straight forward or still tricky ? does anyone know any existing project that does a similar thing i might be able to use and/or modify to work for this purpose ? thanks...

Hi, welcome to the forum.

Yes, you can do this with the help of node-red.

If using a pi for the button, you can run Node-RED on there to help with things. You could also run Node-RED on the PC to help with that end too.

Personally, I wouldn't use a Pi for the button end but rather an ESP microprocessor device but that is mostly preferences and cost. If you can't programme a microprocessor, there are plenty of firmwares available to help. My favourite is ESPhome but many people use Tasmota.

I wouldn't try to use Bluetooth though, it is a bit of a nightmare to work with. Stick with WiFi if you can, though startup on the button device would likely be slower unless you keep it powered on.

Another good alternative would be a low cost Zigbee button. That does need some additional infrastructure though (a Zigbee usb dongle to act as a hub and an mqtt broker with the Zigbee2mqtt service both running on a server which could be the PC or a Pi). Though harder for the initial setup, they will be super-reliable and because Zigbee is a mesh network, you can extend the network very easily. That would also open up options for automated lighting, etc as well.

Node-RED is, in my opinion, the best option for a project like this if you have limited coding skills.

I would buy a wifi button like the Shelly for example (I prefer Zigbee but if you use a wifi button you don't need a controller for creating the zigbee network).

The button is only the first part, now that you have a working button you need to capture the button's presses and trigger some actions.

You could use Node-Red which you could install on your PC or laptop.

  1. Configure the button to connect to an http endpoint once pressed
  2. Use node red HTTP-IN node to create an HTTP endpoint which will receive the button's http request and will allow you to trigger any action

thanks for the help..

if possible id prefer the device with the button to send a keystroke or midi/OSC "natively" and not add extra software on the receiving laptop to interpret it.. the laptop already has a fair bit going on so if i can avoid adding extra stuff that would be good.. This is why i thought of a RPi because if Node-RED is running on the Pi it would be handling any conversion away from the laptop..

The shelly button looks like what i was originally looking for but do you have to use software on the laptop to interpret it or anyway to embed something like a keystroke ? otherwise if anyone knows of another button or device that can be used standalone please let me know.. I have thought about hacking apart a power point presenter and putting in a new enclosure and just keeping one of the buttons but most of the presenters ive seen are still bit large size and not sure id succeed.. thanks

The shelly button emits events when pressed, but the event needs to be send somewhere. With Shelly devices most people use MQTT. node-RED is an excellent tool to receive/send MQTT messages. For MQTT you will need to run MQTT broker software, mosquitto is a good and simple candidate, 1 command to install and run it. Perfect on a raspberry.

Node-red can act as an interpreter and translator between formats, this is one of its core features. To convert to another type of format (that is not natively built-in), there are "nodes" available to do this work.

For OSC there is a node available as well (it is quite old, but still works).

So in short:

button press (mqtt message) -> {mqtt broker} -> node-red (read message, translate) -> OSC

Just for a proof of concept, I had switch and slider controls in Apple Homekit that control the LFO's/VCFs/mixer in my VCV Rack software using OSC, and it actually works :')

Once you are into wireless, you always have to have something on both ends that can talk the same language. So what, on the PC are you expecting to be able to receive the data wirelessly and make sense of it?

In regard to pi vs microprocessor - it really depends on whether you are only ever going to have a single button and never do anything else. If you ever plan to do more, you will almost certainly want a "server" involved to coordinate things. At that point a more capable Pi is something worth investing in now since you only need a single setup to be able to cater for the future. Run node-red there and it means that your button(s) can talk anything and you can use node-red to convert to whatever protocol is convenient. For example there is an OCS Node. But that way you could have 10 buttons or 10,000!

I have Reaper DAW on the laptop which already has other devices sending/receiving OSC to it, so if i could get a device like a smart button or RPi sending OSC also that would integrate easily..

the shelly looks decent but i feel like the best option would be to wire a button to a couple of the GPIO pins on a Pi Zero then find a way to convert the button to send a fixed OSC address from the Pi to the laptop.. hence i thought Node-Red might be able to do the conversion ? also it wont ever need to do anything else besides send this one command..

The couple of videos i saw on YT seemed very easy to convert GPIO input to switch an LED.. but can the OSC node simply take a GPIO HIGH input to trigger an OSC message ? or is it more complex than that ? thanks all for the help :slight_smile:

Don't use OSC so I can't help there I'm afraid. Do the docs say? If not, perhaps raise a question to the author on Github.

no probs.. i've seen a few YT videos now discussing GPIO from Pi and also found one or two things talking about the OSC node. on the surface it seems like it might not be too difficult so i'll dive in and see how i go..

after watching a bunch of videos in last couple of days im really impressed with Node-Red... i had no idea this existed and just stumbled upon it from a google search trying to find a solution to this button thing.. im impressed by how many opportunities it creates..