Getting started with Espruino on ESP32

This blog explain the steps I’ve done to deploy javascript on the ESP32 development board from ezsbc.

I just received from ezsbc my ESP32 µController.

So, it’s time to use it and as a first step, connect to my local Wifi and execute some code !

I’m running MacOS Sierra on a Macbook pro 2016 using a USB-C adapter to connect the board.

Flash the ESP32

Tools Installation

Install the latest version of esptool

1
2
$ git clone git@github.com:espressif/esptool.git
$ python setup.py install

Download the latest Espruino Firmware

From the espruino travis repo download a version of the firmware.

In my case I choose espruino_1v92.13_esp32.tgz which looks like the latest as writing.

unzip the file, it should contains:

1
2
3
4
5
espruino_1v92.13_esp32
├── README_flash.txt
├── bootloader.bin
├── espruino_1v92.13_esp32.bin
└── partitions_espruino.bin

cd in espruino_1v92.13_esp32 and perform the following command:

1
$ esptool.py --chip esp32 --port /dev/tty.usbserial-DN0128PU --baud 921600 write_flash -z --flash_mode "dio" --flash_freq "40m" --flash_size detect 0x1000 bootloader.bin 0x8000 partitions_espruino.bin 0x10000 espruino_1v92.13_esp32.bin

If everything went well, the development board should be ready to boot …

Test Espruino

Espruino Web IDE

Intstall the Espruino Web IDE in Google chrome.

The application is availlabe from the chrome webstore

Connect to the usb port, /dev/tty.usbserial-DN0128PU in my case.

Once connected, if you perform a process.env you should have a JSON description of the environment as in this picture:

Sounds good, let’s deploy some code …

Deploy code

From the Espruino Web IDE add a new file in the project (by clicking on ) and in this file add the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/**************************************
* SETUP Wifi
**/
var SSID = "MySSID";
var WIFI_PWD = "thepassword";
var wifi = require("Wifi");
function onInit() {
console.log('On init ...');
wifi.connect(SSID, {password: WIFI_PWD}, err => {
console.log("connected? err=", err, "info=", wifi.getIP());
});
}
setInterval(() => {
console.log("Five second later ...");
},5000);

As sometimes the deployement is not working properly, I’m doing the following to get it smooth:

reset()

Deploy the code ( button)

save() and press return immediatelly, even if the upload is not finished.

That’s it, you should have in the console your IP a print every 5 sec …

Contents
  1. 1. Flash the ESP32
    1. 1.1. Tools Installation
    2. 1.2. Download the latest Espruino Firmware
  2. 2. Test Espruino
    1. 2.1. Espruino Web IDE
  3. 3. Deploy code
|