Node-red-mcu-plugin v1.0: Integrating Node-RED MCU Edition into the Node-RED editor

About six months ago, @phoddie launched the discussion of an inspiring idea: What if ... one could use Node-RED to program microcontrollers (MCU)? His first thoughts kicked off a development of two components that made this idea become reality: node-red-mcu, a custom runtime, based on the XS Javascript framework created by Moddable Inc. & the node-red-mcu-plugin that integrates node-red-mcu into the Node-RED editor.
After a lot of polishing over the last weeks, supported by a number of very patient members of the Node-RED community, I'm really really excited to announce that we've today released v1.0 of this plugin.

The purpose of the plugin is twofold:

  1. It makes it super easy to build a flow & to push it onto a connected MCU.
  2. It ensures that you, operating the Node-RED editor, get the same user experience that you're accustomed to - despite your flow now runs on an external (but connected) device.

So let’s assume, you've created a flow that you intend to run on a MCU:

  • Select the targeted flow(s) in the plugin's selector panel & deploy once - to confirm your selection.
  • Choose from the dropdown list of supported devices the platform specifier you intend to build for.
  • Define - only if necessary - some parameters to configure the build process, like dashboard support or your WiFi credentials.
  • Then press the Build button. :rocket:

Now it's happening a lot:

  • At first, the plugin composes the data necessary to build the flow for the MCU: It collects flow & node configurations, pulls in - if necessary - code from contributed nodes, walks the dependency tree and resolves links & junctions, to finally put everything into a dedicated build environment.
  • Then it triggers the build & push process, trying to take into consideration all the tiny little things that are platform dependent - to ensure building successfully on macOS, Windows & Linux!
  • Once the code has been uploaded, after the MCU resets & launches, the plugin drives the interface of the editor, displaying the information data created by the the flow and transmitting operator inputs to the MCU. Debug messages, status information, inject button support; all those standard features are supported.

If you're curious to test it, just plug in the MCU Santa brought you (or the other one, that is laying around next to you) & create the flow that most (if not all) of you are familiar with:

image

Despite it looks quite nullish, you'll easily experience a lot of the functionality mentioned above in action! :tada:

So where's the limit of what you can achieve with node-red-mcu & the node-red-mcu-plugin? We haven't seen it so far:

  • The Moddable team created the Moddable Holiday Wreath, operating an ESP32-S3 microcontroller, streaming audio, Neopixels, MQTT, and, of course, Node-RED MCU Edition.
  • This is a screencopy of my CCS™ (Cellar Control System) flow, featuring a window actuator & a fan as well as a number of sensors (humidity, temperature) to ensure proper ventilation of the room - driven by a tiny ESP32 that commands a DS2482 I2C 1-Wire bridge.

Enjoy testing & operating with Node-RED MCU Edition.
We're looking forward to get your comments, to listen to your feedback and to discuss additional feature requests! :wink:

Have a great Christmas time! :santa:

9 Likes

Hi Ralph,
Merry christmas for you too, and thanks for all the hard work you have done for this community!!

Noob question: what is the easiest way to get started with this on a Raspberry Pi? I haven't installed anything yet for Moddable...

Andy has been so kind to implement two new sensor types for me, so need to test it somehow. Some beginner level info is very welcome!

Thanks!!!
Bart

This is amazing, but (as with a lot of things lately) it leaves me with several layers of confusion. Do I understand correctly: the plugin modifies the editor so it can talk directly to node-red-mcu which then requires the Moddable SDK to be installed and talking to a supported MCU? I assume it's easier to do than describe, but are those the right steps?

Also, thanks for referencing the "slick comment" I contributed to the NR documentation.

Let me try to explain it this way:

Node-RED operates on Node.js which is based on the V8 Javascript engine.
Node-RED MCU Edition (or node-red-mcu) operates on the Moddable SDK which implements XS as Javascript engine.

The node-red-mcu-plugin eliminates the effort to bring node-red-mcu & the flows (at that stage deeply merged) on the MCU & modifies the editor to exchange with the connected MCU when the flows are running.

1 Like

Hi Burt!

You'll have to invest a bit of time first to prepare your environment.
There's yet a very good "Getting Started" guide provided by the Moddable team.
In short:

That ready, the world is yours... :+1:

2 Likes

Thanks. That's exactly what I was looking for.

Thanks !!

I was wondering whether it is possible to use this docker container? Just to get people started quicker with Moddable, without having to go through the installation manuals. Of course it is only for ESP32, so ESP8266 lovers won't be helped with it... But perhaps not possibe, unless your sidebar could send commands to it. Although it seems well maintained, this is the only usage information I could find on his Github repo.

@BartButenaers see moddable/esp8266.md at public · Moddable-OpenSource/moddable · GitHub for esp8266

Hey Dave,
Yes I had seen that. But to be very honest I have very bad experiences with installation manuals that require compilation and builds. For some reason that always fails for me with very cryptic errors. NOT saying at all that this will be the case here! Perhaps it will go very smooth as soon as I start with it. But it seems that somebody has already gone through the entire installation process and created a Docker image for it. So I was thinking: if I could start that container, and send docker commands to it from the node-red-mcu plugin sidebar, that that might be a nice alternative. But perhaps not. I have no idea at the moment...

Just thinking out loud, because I have so much to do in so less free time that every shortcut is a great help for me. And I don't think I am the only one of this community in this kind of situation...

Whereas I see the (potential) benefits, I'm currently unsure if this is a valid option. There's e.g. access necessary to hardware ports on the host system & the window server. Additionally, the linked container has a size of 4.someting GB; you wouldn't want to update this once per day! :wink:

This yet shall not sound like neglecting your - vaild (!) - comment. We just have to investigate an alternative way of how to manage the efforts to setup the build system.

Ok valid arguments...

To be clear: I don't expect you to implement this today, so I can use it tomorrow :wink:
Was just wondering if this could be an alternative way to go, to lower the threshold for people to start using this...

Ah hadn't seen that. That is indeed big. No arguments agains that.
But of course I assume that installing each tool on it's own will end up in total to something similar?
I am not a Docker specialist, but I assume the overlay layers contain the same kind of information as the individual tools on their own?
But I can be completely mistaken...

Yes I hadn't been asking myself the same question. But I made the assumption that the Docker container developer had already found a solution for this. Otherwise his container would be useless I assume?

Morning @ralphwetzel,
Trying to have something up and running, but not there yet:

  1. It would be very useful if your package was published on npm and available via the Node-RED palette. Because quite a lot of command line work is required at the moment, which makes it very hard to test this if you have very limited free time (like me...). Thanks!!

  2. This is probably a super stupid question, but I see your sidebar but can't find any of the mcu related nodes:

    image

    Since your plugin installs node-red-mcu automatically, I went to my ~/.node-red/node_modules folder but couldn't find it there. But nothing 'mcu' related:

    But the sidebar pops up. Do you have any idea what I am doing wrong?

Will be. Just a matter of time constraint... :wink:

Nothing.
node-red-mcu supports the core nodes & some based on other (contributed) nodes & some special ones.

  • To work with the core nodes, just pull them in from the left hand node palette - as usual.
  • To work with those based on other (contributed) nodes, you'll have to install those.
  • The special ones have to be installed separately like any other additional package. You'll find them in the directory where the plugin was installed, subdirectory node-red-mcu (e.g. .node-red/node_modules/@ralphwetzel/node-red-mcu-plugin/node-red-mcu); search for directories that have a package.json. Once installed, they will show up in the palette.

The node-red-mcu page has more details...

As an expert in time constraints I can just say: fair enough :wink:

Ah yes, it are not mcu derivates of the core nodes. But you can drag simple the core nodes in the flow. Had seen that in Peter's youtube video. Completely forgotten...

After installing the sensor node like this:

The generic sensor node indeed appears in my palette:

image

If you guys would ever find some time, it would be good to allow this to be done simply via the palette. Otherwise I am afraid that quite some folks will quit during the setup procedure, which would be a pity for this wonderful contribution...

Quick question. If you are using an instance of node-red for both normal flows and MCU flows - how does that work? Aren't the MCU flows still active in node-red itself as well?

As soon as you nominate a flow to be an MCU flow (via the flow selector panel), all nodes of this flow are substituted for the runtime with ones dedicated to support the MCU features. Thus the flow (and all of its nodes) is put in a kind of a standby mode until the MCU connects & sends data...

2 Likes

@BartButenaers

Good news - as promised: node-red-mcu-plugin is now available via npm as well as via the Node-RED integrated palette:

And as we speak of news:
We are going to showcase Node-RED MCU Edition @ FOSDEM23, Feb 4&5, ULB Brussels / Belgium - even with a dedicated stand. We're looking forward to meet all / most / many / some of you there!

5 Likes

@ralphwetzel - Note: there is also an Events category on here so feel free to link to your Fosdem sessions

:+1: I wasn't aware of this!
Thank you for your proposal! We'll do...

@ralphwetzel
Thanks a lot! Again a step closer to an easy installation procedure.

Nice to see that this stuff is going to be showcased! Unfortunately I won't be visiting FOSDEM23, because my wife now already thinks my Node-RED hobby is getting way out of hands. Even without me starting to visit expositions :wink:

3 Likes