How to install Espruino firmware in an ESP8266 board

espruino_logo

This is an update to the installation tutorial I’ve already wrote: Run JavaScript on your ESP8266 using Espruino firmware

For this installation I’m using a D1 mini board which is a “wrapper” for the ESP8266 (ESP-12) board.

Flash the Espruino firmware

The first step is to flash the Espruino firmware into the ESP board. You can find a tutorial in the Espruino site. In this article I’m putting a short list of instructions ready to use.

Install the ESP tools with the following command:

The ESP tools are a set of Python scripts necessary to flash a firmware in the ESP board.

We need now the last version of the Espruino firmware, you can get it from the download page of the Espruino site. The zip file will contain the Espruino firmware also for the ESP8266 board.

We are ready to flash our board. The following instruction are for a ESP-12 board connected to the /dev/ttyUSB0 port. Please refer to the original tutorial for a different version of the ESP board. First move to the folder where you have unzipped the firmware.

The blue led in the board will start blinking and you will see the following output in console:

If you’re having problems finding the correct device path in Linux:

  • first check that you’re using an USB data cable. The first time I’ve tried I was getting crazy because I was using a simple power USB cable.
  • second try this console command to print the system events when the USB cable is plugged:

    When you plug the cable you will get something like this:

Ready to run

After the flash operation the board is ready to receive your JavaScript commands!

To send the commands you need to connect to the board using a serial connection (through the USB port). Under linux you can use the screen program:

Now you can send JavaScript commands that will be interpreted and the output provided as response.

For example writing:

you will get:

You can call functions, for example:

it will reset the board and print a boot message:

If you want to exit from Screen press CTRL-A and then \.

Now you’re ready to write your JavaScript code and run it in a ESP8266 board, for example using the Espruino Web IDE.

 

Run JavaScript on your ESP8266 using Espruino firmware

espruino_logo

Espruino is a board that comes with a pre-installed firmware capable of running JavaScript code. You can buy one of the official board or you can flash a list of “not officially supported” boards. The list contains also the ESP8266 board, so let’s try to run our JavaScript code on it.

For this article I’m using a NodeMCU Amica board which lets us play with the ESP8266 (ESP-12) without the burden of connecting it to the computer and also powering it to the right voltage all from a micro USB port.

All the programs in the article are run from a Linux Mint 17 operative system.

Flash the firmware on ESP8266

First step is to flash the Espruino firmware into the ESP board. You can find a tutorial in the Espruino site. In this article I’m putting a short list of instructions ready to use.

Create a working folder and download there the ESP tools.

The ESP tools are a set of Python scripts necessary to flash a firmware in the ESP board.

We need now a ESP8266 dedicate version of the Espruino firmware. You can find the latest version in this forum post. Here the instructions to download the last version available today (26/06/2016):

We are ready to flash our board. The following instruction are for a ESP-12 board connected to the /dev/ttyUSB0 port. Please refer to the original tutorial for a different version of the ESP board.

The blue led in the board will start blinking and you will see the following output in console:

(Did you noticed the “Running Cesanta flasher stub…” print? Looks familiar?)

If you’re having problems finding the correct device path in Linux:

  • first check that you’re using an USB data cable. The first time I’ve tried I was getting crazy because I was using a simple power USB cable.
  • second try this console command to print the system events when the USB cable is plugged:

    When you plug the cable you will get something like this:

After the flash operation the board is ready to receive your JavaScript commands!

To send the commands you need to connect to the board using a serial connection (through the USB port). Under linux you can use the screen program:

Now you can send JavaScript commands that will be interpreted and the output provided as response.

For example writing:

you will get:

You can call functions, for example:

it will reset the board and print a boot message:

Time to use the Espruino Web IDE.

Espruino Web IDE

The Espruino project provides a Web IDE for editing and uploading your JavaScript code to your board. The IDE also manages the modules that can be used in your code in order to extend the basic functionalities offered by the SDK, for example to use the Wi-Fi device or external sensors like the DHT-22.

The Web IDE can be installed as Chrome application or as NodeJS package.

Espruino Web IDE

After the IDE has been installed we have to configure the baud rate in order to have the communication with the board working fine. Click on the gear icon on the top right, select the COMMUNICATIONS tab, then set the “Baud Rate” to 115200.

espruino_web_ide_settings

Now everything is ready to play. Click the connect button on the top left, select the USB port to use and the IDE will connect to the board.

On the left side you can write commands directly to the board and get the response live.

espruino_web_ide_console

On the right side you can write your code and then upload it to the board using the upload button on the center.

espruino_web_ide_editor

Now we ready to write our first JavaScript program to run on our ESP8266 board!