Newsletter / June 19th, 2019

With this newsletter we are highlighting some of the developments which were important for us in the last month. If you would like to receive future newsletters per e-mail, please register in the form in the top right of our low.js homepage.

What’s this about?

low.js is a port of Node.JS for (ESP32 based) microcontrollers. With low.js we are bringing ease of programming, scalability of programs and easy connectability to the Internet on to small devices.

Simple use case example: With low.js, this small microcontroller can be programmed to push sensor information such as the room temperature into the cloud, all with just a few lines of code.

News 1: Simple npm module install

Our neonious one microcontroller board which is optimized low.js already had a graphical package manager for npm on-board for months now. Now, we also made it easy to install npm packages on generic ESP32 boards via lowsync. Simple example:

lowsync install mymodule

This command will make lowsync install the package mymodule from npm and all required dependencies. After this is done, mymodule will work out of the box.

Not only is this easier than syncing a node_modules directory, this makes the modules load faster, as lowsync installs the modules packed in a very efficient way.

News 2: HTTPS requests implemented!

low.js supported HTTP servers and clients, but till now only HTTPS servers. Now https.request is also implemented! We even made sure it works with a popular Promise based client module, axios.

As an example, the following code to download an image with axios works great on low.js. It includes complete error handling and streams the image to the file instead of downloading to memory and then to the file afterwards:

const axios = require('axios');
const fs = require('fs');

async function download(url, path) {
	// Start download
	let stream = (await axios({
		method: 'get',
		url,
		responseType: 'stream'
	})).data;

	// File found, download in progress, so write file
	await new Promise((resolve, reject) => {
		let streamOut = fs.createWriteStream(path);

		stream.on('error', reject);
		streamOut.on('error', reject);
		streamOut.on('finish', resolve);

		stream.pipe(streamOut);
	});
}

download('https://www.lowjs.org/img/lowjs.png', 'lowjs.png').then(() => {
	console.log('download done!');
}).catch(console.error);

News 3: WebSocket HTTP/HTTPS clients implemented!

If you want to push your data via WebSockets, this is now possible, too. We added WebSocket client support (to be precise, http/https.request objects handle upgrading now) and thus you can now write code like this:

const myTemperatureModule = require('./myTemperatureModule.js');

const WebSocket = require('ws');
const ws = new WebSocket('ws://www.mycloudservice.com/path');
 
// Push temperature once every second
setInterval(() => {
	try {
		ws.send('temperature: ' + myTemperatureModule.read());
	} catch(e) {
		// WebSocket might not be OPEN yet. Not a problem, next iteration will work
	}
}, 1000);

News 4: Stability, stability, stability!

Our current focus is on stability. With extensive testing we found many problems which we were able to fix. If you ran into any issues when testing low.js in the last months, try again. It might work like a charm now.

We are continuing to look for problems. If you notice any issue, open a GitHub issue, so we can take a look, please!

That’s it! Thank you for reading!