Embedded Computing
  • About
  • Blog
  • Hardware
    • Which Platform?
    • Controller Platforms >
      • Adafruit Platform
      • Arduino Plaform
      • BBC micro:bit
      • Espressif Platform
      • iLabs Platform
      • Raspberry Pi Platform (MCU)
      • Seeed Platform
      • Silicon Labs Platform
      • Teensy Plaform
    • Computer Platforms >
      • BeagleBone Platform
      • Raspberry Pi Platform (SBC)
      • UDOO Platform
    • Peripherals >
      • Shields
      • Grove System
      • Sensors
      • Actuators
    • Displays >
      • E-Paper Displays
      • Reflective Displays
      • TFT Displays
      • LCD Displays
    • Legacy Platforms >
      • chipKIT Plaform
      • 4D Systems Platform
      • Intel Platform
      • LaunchPad Plaform
      • BoosterPacks for LaunchPads
      • LightBlue Bean
      • Maple Plaform
      • Mediatek Platform
      • Microsoft Azure IoT DevKit
      • Particle Platform
  • Software
    • Exploring RTOS with Galaxia >
      • Event Library
      • Semaphore Library
      • Mailbox Library
      • Timer Library
      • Clock Library
      • SWI Library
      • Task Library
    • Ultra-Low Power with EnergyTrace >
      • Ultra-Low Power with MSP430
      • Ultra-Low Power with Energia MT and Galaxia
    • Using Integers Instead of Reals
    • Going Python?
  • IoT
    • IoT Platforms: Which Hardware? >
      • Matter with Silicon Labs MG24
    • IoT Services: Which Solution? >
      • Recommended IoT Solutions
      • Platform-Specific IoT Solutions
      • Other IoT Solutions
      • Not tested IoT Solutions
      • Notification Solutions
    • Get Date and Time from Internet with NTP
    • Fast and Easy WiFi Connection with QR-Code
  • Tools
    • How to Start?
    • Reference >
      • Asking for Help
      • Boards Pins Maps
      • Ruler
      • Boards and Plugs
      • I²C Logic Level Converter
      • Standards for Connectors
    • Training >
      • Texas Instruments Workshops
      • Embedded Systems: Shape The World — MOOC edX UTAustinX UT.6.02x
      • Embedded Systems - Shape The World: Microcontroller Input/Output — MOOC edX UTAustinX UT.6.10x
      • Embedded Systems - Shape The World: Multi-Threaded Interfacing — MOOC edX UTAustinX UT.6.20x
      • Real-Time Bluetooth Networks: Shape the World — MOOC edX UTAustinX UT.RTBN.12.01x
      • Systems Thinking with Texas Instruments Robotics System Learning Kit
    • Books >
      • Getting Started with the MSP430 LaunchPad
      • Getting Started with Arduino
      • Arduino Cookbook
    • IDE >
      • The Battle of IDEs
      • More Options
      • Assessing the Next Generation of IDEs
      • Tools for Documentation
    • Equipment >
      • Saleae Logic Analyser
      • Rigol DS1102E Oscilloscope
      • XDS110 Debug Probe with EnergyTrace​
      • Segger J-Link Programmer-Debugger
      • Nordic Power Profiler Kit II
  • Projects
    • Libraries >
      • Master I²C Software Library
      • Date and Time Library
      • highView Library Suite
      • Others Libraries
    • smartDevices >
      • I²C smartColours Smart Sensor
      • I²C smartRFID Smart Sensor
      • I²C smartLED Display
      • I²C smartControls Smart Device
      • I²C smartWiFi Smart Device
      • I²C smartBLE Smart Device
      • I²C smartNode Smart Device
    • IoT Projects >
      • Remote E-Paper Weather and Message Board
      • Typie-Walkie with LoRa and E-Paper Screen
      • Typie-Walkie with E-Paper Screen
      • Remote e-Paper Pictures Panel
      • Remote e-Paper Messages Panel
      • Industrial IoT Project
      • Remote Contactless Temperature Monitor
      • Using Node-RED for IIoT
      • Low Power Home Network Weather Monitoring
      • Updated Low Power Home Network Weather Monitoring
      • Weather and Security Station with Blynk
      • SensorTag to Blynk Using Node-RED
      • Pervasive Reporting
    • AI Projects >
      • Colour Recognition with Neural Network
    • Other Projects >
      • Air Quality Monitoring
      • Driving a Large E-Paper Display with a Compact Xiao RP2040
      • Low-Power E-Paper Weather Station
      • Portable Particulate​ Matter Monitor
      • FRAM-based E-Paper Screen Controller
      • General Purpose 3.5" Screen
      • Colour Recognition with Neural Network
      • A Low Power Weather Station
      • Digital Volt-Amp-Watt Meter
      • Mobile Measurement with LCD Display
      • Screen with SRAM for GUI
      • Volt-Amp-Watt-Meter for Grove
      • Multi-Touch Project with CapTIvate

Using Node-RED on MCUs

Could Node-RED generate code for MCUs? I asked backed in March 2020. As you may know, I am a big fan of Node-RED. It provides an elegant low-code/no-code solution for IoT but requires a single-board computer to run, like a Raspberry Pi 4B.

My question received an answer at the Node-RED Con 2022 with the Moddable presentation. ​The Moddable SDK implements JavaScript on MCUs and thus allows to run a Node-RED flow on them. 

​
Supported hardware includes ESP32, Raspberry Pi Pico W, among other options, and proprietary boards like the Moddable Two, built around an ESP32 and a 320x240 touch display, which I ordered.

The project relies on different components:
  1. The flow is designed with Node-RED.
  2. ​Node-RED MCU Edition exports it to JavaScript.
  3. Moddable translates the JavaScript project into C++ code.
  4. Moddable calls the tool-chain of the board to build and link, upload and launch the project.
  5. Moddable opens an optional debugger.
Picture

Configure

Installation includes four parts: the required tools; the Moddable SDK; the tool-chain for the targeted board; and the Node-RED MCU plug-in.

As I am using a non-production PC, I opted for a MacBook.
  • Required tools for macOS 13.2 include Xcode 14.2 and CLT 14.2. 
  • The xs-dev utility installs the Moddable SDK and related utilities, including a debugger and a simulator. 
  • The same xs-dev utility can also be used to install the tool-chain for the targeted board, ESP32 or Raspberry Pi Pico.
  • The node-red-mcu-plugin installs the front-end Node-RED MCU and Node-RED MCU Edition runtime. Edit the settings.js file and restart Node-RED.

Although I faced some issues during the installation, support from Moddable was great and the process ultimately succeeded. 
​
Picture
Given the complexity of the project, a container would have been really great to get everything configured at once. Alas, there is no official container, but a user is sharing his own configuration. I haven't tested it yet.

Use

Node-RED now includes a new pane, MCU, with two parts: on top, the selection of the flows to consider for the MCU; below the choice of the targeted board and different options.

The different options include UI support, SSID and password for WiFi, and 
parameters for the screen.
Picture
Picture

First test

The first test is a minimal example with an inject node and a debug node.

The xsbug shows the input and output messages.

Picture

WiFi and MQTT

The flow connects to a MQTT broker, subscribes to the test/in thread, extracts the value from the message, performs some calculations and publishes the result to the test/out thread.

The first question was: How to connect to a WiFi network? The Options pane include dedicated fields to enter the SSID and password. They could also be mentioned on the Arguments field. 

I wanted to use JSONata to perform the calculation, but Moddable doesn't support it. I had to use the function node instead.
Arguments

    

GPIO

The built-in LED on the Raspberry Pi Pico W is not attached to a GPIO of the RP2040 but instead to the WiFi CYW43439 radio on WL_GPIO0. Suggested answer was to specify 32 as GPIO.

I also attached an LED to GPIO15. Selecting GPIO15 on the Raspberry Pi GPIO node displays 10, but the LED does blink.

On the Moddable 2 board, built-in LED is available on pin GPIO2 and backlight PWM is on pin GPIO18.
Picture

SPI and I²C buses

I haven't tested SPI and I²C buses yet.

Pre-configured sensors are available and can be installed with the following command.
Code Editor

    

Dashboard on MCU

One of the greatest and possibly most popular features of Node-RED is the dashboard. The video from the Node-RED Con 2022 shows at 2:19:41 a Node-RED dashboard running on an MCU.

I ordered the recommended Moddable Two board to test this feature. The board is built around an ESP32 and features a 2.4" displays with capacitive touch.

​The versions of the dashboard displayed on the Moddable 2 screen, the browser and the similator look very similar. The Moddable 2 board takes default GMT as timezone, while the browser uses the correct locale format. 
The UI Support should be Enabled and Screen Pixel Format set to rgb565le. Optional Screen rotation can be set to 90°, 180° or 270°.

Specific parameters need to be mentioned on the Arguments field, otherwise a stack overflow occurs.

    

Conclusion

Yes, Node-RED now generates code for MCUs!

I really like the new ability to use the same dashboards on a MCU-powered board. The Node-RED MCU implementation already supports a long list of nodes and new ones are added.

Targeting MCUs with Node-RED might not be the most optimised solution, especially when displaying a dashboard, but this approach speeds up the development on interfaces for MQTT and GUI.
Picture

Links

  • Moddable website
  • Moddable SDK
  • xs-dev installation utility
  • node-red-mcu-plugin for Node-RED
  • ​Node-RED website

​Posted: 31 Oct 2022
​Updated: 
02 Nov 2022, 12 Jan 2023, 08 Feb 2023, 19 Mar 2023
Picture
Picture
Powered by Create your own unique website with customizable templates.