Low.js is a port of Node.js and Has Certain Requirements to Run. Low.js developed by a company named NEONIOUS who has own ESP32 board (which you may purchase). Commonly, when we say ESP32 then we mean ESP-WROOM-32 based board. However, for this guide that ESP-WROOM-32 based board will not work. We need ESP32-WROVER based board. ESP-WROOM-32 does not have the 4 MB PSRAM required for low.js. Wrover modules have PSRAM that the Wroom does not. PRAM essentially allows your programs to use 4MiB of RAM more, and another 4MiB you can use too. With the Wroom you would only have the 500-ish Kb of internal memory. There is also speed difference of ram (133 vs 144 mhz). ESP32-WROVER based boards of course more modern but bigger and costs higher than ESP-WROOM-32. ESP32-WROVER modules has either a PCB antenna or an IPEX antenna. This means your ESP32-WROVER board have 4MB FLASH and 4MB RAM. It’s CPU is dual-Core Tensilica LX6 240 MHz. Incredible amount of RAM. 4MB in embedded projects usually not needed which actually the reason to use ESP WROOM 32 more for other works. WEMOS has a ESP32-WROVER board with battery port, SD card slot whose clone is sold by China. At least for now, you will find node.js IoT guide for Raspberry Pi more. You can actually port some of them ESP32-WROVER board. WROVER is less used, you can see this chart on Wikipedia :
1 2 3 | # # https://en.wikipedia.org/wiki/ESP32#Development_and_other_boards # |
Steps of Setup Node.js (low.js) on Windows for ESP32
First install Node.js by downloading Windows MSI package from the official website :
1 | https://nodejs.org/en/ |
After installation finishes, launch Windows Command Prompt and type the below commands to check whether node and npm installed :
---
1 2 | node -v npm -v |
It is practical if to have esptool installed but not written on docs as requirement (probably the dependency gets installed) :
1 | pip3 install esptool |
If you get output without error after issueing node -v
, npm -v
commands then run this command to installed the required tool :
1 | npm install -g lowsync |
It will take some time to get installed. Attach your ESP32 to the PC and determine the number of COM port it is attached, it is for our testing was COM6. As hints how to guess COM port number, easiest way is to launch Arduino IDE if your ESP32 is configured with Arduino IDE. Else launch Windows Device Manager and check port.
Next, issue this command :
1 | lowsync flash COM6 --init |
Watch this output to appear :
1 2 3 4 5 | C:\Users\abhishekghosh>lowsync flash COM6 --init *** Step 1/3: Probing ESP32 microcontroller esptool.py v2.6-beta1 Serial port COM6 Connecting..... |
Press the boot button on ESP32 board. Else you’ll end up with this :
1 2 3 4 5 6 7 8 9 | C:\Users\abhishekghosh>lowsync flash COM6 --init *** Step 1/3: Probing ESP32 microcontroller esptool.py v2.6-beta1 Serial port COM6 Connecting........_____....._____....._____....._____....._____....._____....._____ A fatal error occurred: Failed to connect to Espressif device: Invalid head of packet (0x08) An error has occurred: Cannot read MAC address of ESP32 chip. Please check connection! |
If everything is fine, the flash will proceed :
1 2 3 | C:\Users\abhishekghosh>lowsync flash COM6 --init *** Step 1/3: Probing ESP32 microcontroller now checking if it is an ESP32-WROVER... (takes a while) |
You can tell your device to connect to your existing Wifi by changing the low.js settings with lowsync. Create a new project directory, you can create a file named index.js
with this content :
1 2 3 4 5 6 7 8 9 10 11 | let gpio = require('gpio'); gpio.pins[1].setType(gpio.OUTPUT); 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; } gpio.pins[1].setValue(val); }, 30); |
LED is connected to pin 1 is directed by two lines:
1 2 3 4 5 | … gpio.pins[1].setType(gpio.OUTPUT); … gpio.pins[1].setValue(val); … |
Initialize the project by entering the following command in the terminal:
1 2 3 4 | lowsync init # sync lowsync lowsync start |
That is it. You should see LED attached to pin 1 having PWM fading. Here is API documentation :
1 | https://www.lowjs.org/documentation/lowjs-for-esp32-api.html |