How to get JavaScript running on your ESP8266 using Espruino

JavaScript is a very popular language these days and it’s used for absolutely everything from web development to mobile apps and lately efforts are made for porting it to run on actual microcontrollers like ESP8266. Today we’re gonna use a couple of tools to load a special firmware on the ESP8266 that will allow you to run JavaScript code that will get sent via USB to an interpreter running on your ESP8266. The interpreter is going to take that JavaScript code executed and respond accordingly.

There are a couple of options for getting JavaScript running on your ESP8266. So today we’re going to be talking about Espruino.

Download Espruino Image

Navigate to the download section of the Espruino website, and download the latest version of the Espruino firmware.

Once downloaded, go ahead and move the zipped file to a known location on your computer.  Here we’ll create a folder inside our user’s directory called ESP8266-Espruino. From your Terminal App type in.

cd ~ && mkdir ESP8266-Espruino

We then move and unzip the file inside the said directory.

Installing pySerial

pySerial is a Python module that allows a Python program to communicate with a serial (e.g., USB, RS232) port.  The tool that we’ll use to load the Espruino firmware onto the ESP8266 Development Board is written in Python, and it uses this module to communicate with the USB port for writing out the firmware to (specific) devices connected to it.

Arguably, the simplest way to install this is by downloading the source code from the project’s Github repository:

cd ESP8266-Espruino && git clone

Then, we can install the pySerial module in our system.  Here we’ll make it available for our entire system (system-wide install).

cd pyserial && sudo python install

Downloading Software For Loading Espruino Onto The Board

The last piece of software we need is the program that will allow us to write the Espruino firmware onto the ESP8266 Development Board over USB (using amongst other things the pySerial module).  To get this tool we can simply:

cd .. && git clone

Because Espruino runs in a variety of boards, we need to find the directory with the files corresponding to the ESP8266.  This is located inside our espruino_1v95 folder.  We can then start writing the Espruino firmware with ease!

cd espruino_1v95/espruino_1v95_esp8266


python ../../esptool/ --port /dev/tty.SLAB_USBtoUART --baud 115200 \

write_flash --flash_freq 80m --flash_mode qio --flash_size 32m \

0x0000 "boot_v1.4(b1).bin" 0x1000 espruino_esp8266_user1.bin \

0x3FC000 esp_init_data_default.bin 0x3FE000 blank.bin

If everything goes well, you should get something similar to what’s shown on this screenshot (no errors):

Sending JavaScript Over USB

Now we can use any Serial Terminal programs to start sending JavaScript commands over USB to the ESP8266, and have the Espruino firmware interpret them accordingly.  In our case, we’ll use the program screen available in OSX, so from our terminal we enter:

screen /dev/tty.SLAB_USBtoUART 115200

And we should establish a connection to the USB port at a baud rate of 115200 (press Ctrl-A followed by Ctrl-\ to quit).  The screen should go blank at this point, so the easiest test is to reset your ESP8266 Development Board, which outputs the startup message shown below once the Espruino firmware starts running:

Finally, we can use the Espruino API to test out a few commands.  Connect an LED to the pin labeled D2 on the board, which corresponds to GPIO4 on the ESP8266 SoC.  If we input the command:


The LED should turn on!

NOTE: Remember that the Espruino firmware uses the GPIO numbers instead of the board labels to refer to each pin.

sarah ali

sarah ali

Sarah is a passionate writer and blogger. As an early adopter, she enjoys trying out new social media and Internet tools along with WordPress plugins and Web apps.
sarah ali

Leave a Reply

Your email address will not be published.