A Very Moddable Holiday Wreath
All year the team at Moddable works with our clients and community of developers to bring the power of the JavaScript ecosystem to embedded developers. The end of the year at Moddable is an opportunity for us to build a project using the technology we've been building all year. This year's project weaves Neopixels into a holiday wreath along with a speaker to play Christmas carols. A previous year-end project used Neopixels at a massive scale, so to make this one really different we ran it on an ESP32-S3, one of our most recent ports, and coded it using Node-RED MCU Edition.
Features
It's unusual for a holiday wreath to have a feature list, but this is no ordinary wreath. It has three different modes for animating the lights. The animation changes automatically every minute, and can be advanced by pressing a button. The wreath streams Christmas carols continuously from the cloud.
This is an IoT wreath, continuously connected to the cloud. The wreath publishes the current animation mode and song to MQTT so you can monitor its state from anywhere in the world. You can also remote control the wreath using MQTT to change the animation and song.
Technology
Our Christmas wreath looks and sounds great in our front office window. But what's really interesting is the technology behind it.
The animations run at about 100 frames per second providing smooth color transitions. High performance JavaScript is a reality on embedded devices. Our new Performance Profiler is one reason we get such great results. The wreath is remarkably robust too -- running continuously without glitches or restarts. That's because it is powered by the same Moddable SDK used in high-reliability consumer and industrial IoT products.
The Christmas carol sounds files are too big to fit into the ESP32-S3 module, so they are stored in the cloud. The wreath streams the WAVE files using our new HTTP audio streaming module.
The HTTP streaming and MQTT connections use new implementations of these network protocols developed this year as part of our work to create standard embedded JavaScript APIs. Both are based on proposals that are part of ECMA-419 2nd Edition. The implementations are full-featured, lightweight, and easy to integrate into projects.
The ESP32-S3 is the new flagship microcontroller from Espressif and we've been working throughout the year to deepen our support for it. The wreath is our first project to use its new PDM audio output capability which can eliminate the need for an external I²S component. The audio quality is excellent and the cost is less.
Node-RED?
The wreath is coded in Node-RED. If you aren't familiar with Node-RED already, it is a visual programming environment that uses message flows to control hardware and connect to the network. It was originally developed using Node.js on Raspberry Pi running Linux. Moddable has been re-implementing the Node-RED runtime to work on inexpensive microcontrollers running the Moddable SDK. Node-RED is implemented in JavaScript and you can write JavaScript as part of your projects. It is a great way to quickly build projects.
To get a feel for what working with Node-RED looks like, there's the Node-RED flow for the wreath.
Each block contains additional details, but just by looking at their names and how they are connected together, you get a good sense of what the project does. To dig deeper on the details of the wreath project, check out the announcement page on the Node-RED MCU Edition repository on GitHub.
Moddable believes Node-RED is a great complement to our Moddable SDK, providing a friendly on-ramp for developers getting started on embedded and powerful tools for experienced developers. We'll be doing more with Node-RED MCU Edition in 2023.
Conclusion
Fun projects like our Moddable holiday wreath are opportunities to try something new and learn a few things along the way. The Moddable team used this project to stress test some of our latest additions to the Moddable SDK. The large feature list of the wreath motivated us to improve our Node-RED skills to create a relatively simple flow. If this project inspires you to try your own experiments using the Moddable SDK, we're here to support you and we'd love to see your results.