Blog Forum Contact Us

low.js Example: Getting Started / Blink LED

With microcontroller boards, getting the on-board LED to blink is one of the simplest tasks you can do. In this example, we are doing exactly this.

For neonious one owners:

This example works with any ESP32-WROVER board. As the neonious one has an IDE, you can get to the same result a whole lot easier without using lowsync:

See the neonious one documentation for more information on the IDE.

1. Flash/install low.js on your board

This was tested on Windows, macOS and Linux. It might work on other platforms.

Step 1.1: Install Node.JS on your PC

No, Node.js is not used by the microcontroller or low.js itself! Node.js and the package manager npm, which is distributed with Node.js, are only used by lowsync, our flashing and syncing tool.

For this, download the right installation package from and install.

Step 1.2: Install lowsync via npm on your PC

To do this, enter the following command as Administrator/root in your terminal:

npm install --unsafe-perm -g lowsync

The option –unsafe-perm lets the install script run as root instead of letting npm change the user to nobody before running the install script. This is required for the serialport module.

Alternativly, install as normal user into your local node_modules directory:

npm install lowsync

You then have to always call lowsync with path however:

node_modules/.bin/lowsync [your parameters...]

Step 1.3: Flash low.js (not needed with neonious one)

After connecting to the board physically by plugging in the cable, you need to find out what the port name is. Under Windows the port usually begins with COM, under other platforms it is a file beginning with /dev/tty. If you cannot find the port, chances are you need to install a device driver for the USB to UART adapter chip.

For the actual flashing of low.js, enter the following command in your terminal:

lowsync flash portname --init

As portname enter the port name you found in the last step.

2. Write user program

Step 2.1: Connect to the microcontroller's Wifi

The Wifi SSID and password to use should have been outputted by the flash command.

If you want to be able to continue to use the Internet, you can tell your device to connect to your existing Wifi by changing the low.js settings with lowsync. You then can also use your existing Wifi with working Internet access. See the documentation for more details.

From now on, the serial port of low.js will no longer be used for development. It is free to use by the user program.

Step 2.2: Create a new project directory

In the new directory, initialize the project by entering the following command in the terminal:

my_project_directory> lowsync init

If lowsync asks questions, you can just skip them by pressing Enter. The default values will work.

Step 2.3: Write program code

Figure out what pin the on-board LED is connected to. For neonious one, the red LED is connected to pin 1.

Enter the following code into a new file index.js:

Is the example not working as expected?

Try checking the status with lowsync status.

To start or restart the program call lowsync start.

You can also check for any (error-) output by calling lowsync monitor and then fix any errors you find in your editor.

Remember to call lowsync sync after any changes you make.

let gpio = require('gpio');

let val = 0, dir = 0;
setInterval(() => {
    val += dir ? 0.03 : -0.03;
    if(val < 0) { val = 0; dir = 1; }
    if(val > 1) { val = 1; dir = 0; }

}, 30);

For fun, this program does not simply blink the LED, it fades the LED in and out with PWM.

Step 2.4: Sync and run

For syncing with the file system, enter

my_project_directory> lowsync

Note that this syncing works both ways: If your low.js application writes log files, these would be synced back to the PC, too.

If the program already ran, lowsync will ask you if you wish to restart the program. Enter yes here. If it did not ask, you can start the program by entering

my_project_directory> lowsync start