Friday, March 29, 2024
Embedded & MCUExplainerIoT Software&ToolsMicrocontrollersProgramming

Node.js for Microcontrollers

low.js is a port of the JavaScript runtime Node.js with far lower system requirements, allowing it to run on cheap, power-efficient microcontroller boards based on the ESP32-WROVER module. With low.js you can build scalable Internet-native electronics applications (IoT) easily and fast. low.js runs on any ESP32-WROVER module.

Use Low.js with far lower system requirements.

  • low.js starts up instantly, while Node.js does not (0.6 to 1.5 seconds wait time on Raspberry Pi 2).
  • low.js only uses a fraction of the disk space and memory which Node.js requires, leaving more resources for other processes.
  • With low.js, you can program JavaScript applications utilizing the full Node.js API and run them not only on normal PCs, but also on embedded devices, such as ones based on the $3 ESP32 microcontroller with Wifi on-board.

Low.js vs Alternatives

low.js vs. Arduino

Programs written for the Arduino microcontroller board platform are called Sketches and are written in simplified C/C++ language with the Arduino API.

Arduino is widely used, so for almost any purpose somebody has already written a library and an example which can be used as a template for a new project.

Its biggest flaws are:

  • It is hard to let the program do multiple things in parallel, especially as not all APIs calls are non-blocking.
  • While Arduino on ESP32 does have networking/Wifi support, building fully featured servers still need lots of manual work.

These two flaws are strengths of low.js.

low.js vs. ESP-IDF

ESP-IDF is the low-level development framework for programming the ESP32 chips, provided by the chip maker Espressif itself.

Programming with ESP-IDF requires knowledge of C/C++ and of microcontrollers internals (interrupts, FreeRTOS). For a programmer with this knowledge, it is a very flexible framework to program with, allowing the user to get the most out of the ESP32 chips.

In fact, low.js itself is developed on top of a modified version of ESP-IDF.

Still, as we were able to confirm in several projects, low.js is far easier and less time consuming to program with than with ESP-IDF, often producing the same results with far less lines of code.

low.js vs. Espruino

Espruino is another JavaScript runtime for microcontrollers. It runs on far less powerful microcontrollers than low.js does. This comes at the cost of not taking advantage of the possibilities of the more powerful microcontrollers such as the ESP32:

  • The API of Espruino is far less powerful than the API of low.js is, as Espruino does not provide the Node.js API, which would not fit into the smaller microcontrollers. Espruino provides some API calls which mimic Node.js API calls, such as fs.writeFile, however they do not work the same way. fs.writeFile for example is blocking (there does not seem to be any way to write a file asyncronly with Espruino).
  • The JavaScript engine of Espruino does not compile to byte code, but rather runs of the source code, thus is usually slower than low.js.

low.js vs. MicroPython

MicroPython is a port of Python for microcontrollers, just as low.js is a port of Node.js for microcontrollers. With both microcontrollers can be programmed easily.

The arguments for low.js vs. MicroPython are the same as for Node.js vs. Python:

  • low.js allows the programmer to use one programming language – JavaScript – for the whole project consisting of microcontroller software, website and server in the cloud.
  • The API of low.js is asynchronous first, making it easy to scale projects.

Still, MicroPython could be the better choice if your Python skills are better than your JavaScript skills already.

Downloads

As low.js is in early development, things change fast with the goal of full Node.js compatibility. Because of this, there is no version numbering yet. These are nightly builds compiled directly from the GIT repository.

The versions for PCs are provided so developments can be tested on the PC without having to transfer them to the microcontroller first.

Platform Architecture Version / Date File Size
Linux x86/x64 32 bit (i686) 2019-01-25 0.99 MB Download
Linux x86/x64 64 bit 2019-01-25 0.92 MB Download
Linux ARM 32 bit (ARMv6/v7) 2019-01-25 0.87 MB Download
Linux ARM 64 bit (ARMv8) 2019-01-25 0.89 MB Download
macOS 64 bit 2019-01-25 0.76 MB Download
ESP32-WROVER To flash/install on ESP32-WROVERs, you need to use lowsync, which can be installed via npm.
See the examples or documentation for more details.

You may like also:


 

Harshvardhan Mishra

Hi, I'm Harshvardhan Mishra. Tech enthusiast and IT professional with a B.Tech in IT, PG Diploma in IoT from CDAC, and 6 years of industry experience. Founder of HVM Smart Solutions, blending technology for real-world solutions. As a passionate technical author, I simplify complex concepts for diverse audiences. Let's connect and explore the tech world together! If you want to help support me on my journey, consider sharing my articles, or Buy me a Coffee! Thank you for reading my blog! Happy learning! Linkedin

One thought on “Node.js for Microcontrollers

Leave a Reply

Your email address will not be published. Required fields are marked *