Introduction: ESP8266 Firmata-J5 NodeBot

The ESP8266 is a WIFI-enabled SoC available in many shapes and forms.

It usually comes with nodemcu firmware which runs on lua script. Most of us just flash it using the arduino core provided by the Esp8266 community themselves.

Now, you can program it using Javascript!!!

This is thanks to the great work by soundanalogous, jacobrosenthal and jnsbyr (work on Firmata firmware) and ofcourse rwaldron for Johnny-five library.

This is just a guide about how to make it work.


1. The ESP8266 works as Wi-Fi server. An option to configure as a Wi-Fi client will be added in the future.

2. Analog Read does not seem to be working for the time being, but work is in progress.

3. This is all new and the dependencies may get updated often.

Here we are going to use the StandardFirmataWiFi to use ESP8266 as server, connect to a network and run a node.js J-5 script on a host machine connected to same network to blink LED pin 13.

This was tested on macosX

Step 1: Ingredients

  • Libraries

  1. Latest Arduino IDE(1.6.8 as of writing)
  2. ESP8266 Core
  3. Latest Arduino Firmata Library with support for ESP8266
  4. Latest johnny-five library
  5. Etherport-client

  • Computer
  • host machine(computer, raspberry-pi, etc) capable of running node.js
  • Patience
  • Based on your board, you might also need an USB-serial converter

Also, I assume you have experience with programming ESP8266 based board with Arduino IDE,

otherwise, please first read here

Step 2: Some Information


JavaScript Robotics and IoT programming framework, developed at Bocoup.


StandardFirmataWiFi is a WiFi server application. You will need a Firmata client library with
a network transport in order to establish a connection with StandardFirmataWiFi. To use StandardFirmataWiFi you will need to have one of the following boards or shields: - Arduino WiFi Shield (or clone) - Arduino WiFi Shield 101 - Arduino MKR1000 board (built-in WiFi 101) - ESP8266 WiFi board compatible with ESP8266 Arduino core


Client-side virtual serial port for Etherport for the implementation of firmata-compatible boards and tethering hubs to control boards by a remote entity.

Step 3: Arduino IDE Configuration

  1. get the latest arduino ide

Install the approapriate IDE for your platform

2.Install the ESP8266 core

Installing with Boards Manager

Starting with 1.6.4, Arduino allows installation of third-party platform packages using Boards Manager. We have packages available for Windows, Mac OS, and Linux (32 and 64 bit). Install Arduino 1.6.8 from the Arduino website.Start Arduino and open Preferences window.Enter into Additional Board Manager URLsfield. You can add multiple URLs, separating them with commas.Open Boards Manager from Tools > Board menu and install esp8266 platform (and don't forget to select your ESP8266 board from Tools > Board menu after installation).The best place to ask questions related to this core is ESP8266 community forum:

3. Download the Latest Arduino Firmata Library

Updating Firmata in the Arduino IDE - Arduino 1.6.4 and higher
If you want to update to the latest stable version: Open the Arduino IDE and navigate to: Sketch > Include Library > Manage LibrariesFilter by "Firmata" and click on the "Firmata by Firmata Developers" item in the list of results.Click the Select version dropdown and select the most recent version (note you can also install previous versions)Click Install.

Cloning Firmata

If you are contributing to Firmata or otherwise need a version newer than the latest tagged release, you can clone Firmata directly to your Arduino/libraries/ directory (where 3rd party libraries are installed). This only works for Arduino 1.6.4 and higher, for older versions you need to clone into the Arduino application directory (see section below titled "Using the Source code rather than release archive"). Be sure to change the name to Firmata as follows: $ git clone ~/Documents/Arduino/libraries/Firmata Update path above if you're using Windows or Linux or changed the default Arduino directory on OS X

Now we need to modify the libraries accordingly.

Step 4: Making Necessary Changes

  1. Open the StandardFirmataWiFI example from examples(check the picture)
  2. This will open StandardFirmataWiFI.ino along with wifiConfig.h
  3. Uncomment / comment the appropriate set of includes for your hardware (OPTION A, B or C). Option A is enabled by default.

    4.It is already configured for ESP8266. Find Step 2:

    // STEP 2 [REQUIRED for all boards and shields]
    // replace this with your wireless network SSIDchar ssid[] = "your_network_name";

    change "your_network_name" to yours appropriately, e.g "myHomewifi"

    5. In this example we are using DHCP so we are not configuring Step 3. If you need to use static IP please follow the instructions provided in the wifiConfig.h file itself

    6. Configure your home network pass: The default is Option A

    /* * OPTION A: WPA / WPA2 * * WPA is the most common network security type. A passphrase is required to connect to this type. * * To enable, leave #define WIFI_WPA_SECURITY uncommented below, set your wpa_passphrase value * appropriately, and do not uncomment the #define values under options B and C */
    #ifdef WIFI_WPA_SECURITY char wpa_passphrase[] = "your_wpa_passphrase"; #endif //WIFI_WPA_SECURITY

    7. Flash your ESP8266 using the corresponding settings to your board

    e.g I use the NodeMCU 0.9 development board. I use and FTDI-TTL adapter to program the MCU.

    You need to select the appropriate Port settings.

    It might say the file is Read-only. Just save another copy

Step 5: Setting Up Johnny-Five

Johnny-Five is an Open Source, Firmata Protocol based, IoT and Robotics programming framework, developed at Bocoup. Johnny-Five programs can be written for Arduino (all models), Electric Imp, Beagle Bone, Intel Galileo & Edison, Linino One, Pinoccio, pcDuino3, Raspberry Pi, Particle/Spark Core & Photon, Tessel 2, TI Launchpad and more!

Install Johnny-Five:

You need to have node.js already running on your system. Read Here

Source Code:

git clone git:// && cd johnny-five
npm install 

npm package:

Install the module with:

npm install johnny-five

We also need the Etherport-client library:

Client-side virtual serial port for Etherport for the implementation of firmata-compatible boards and tethering hubs to control boards by a remote entity.

npm install etherport-client

Writing JS Client

Create a js file in the johnny-five directory and name it appropriately.

Paste this code:

Update line 18 below to the ESP8266 board address

* Update line 18 below to the ESP8266 board address * * Enable Serial debugging by uncommenting //#defin SERIAL_DEBUG in StandardFirmataWiFi * (save a copy of StandardFirmataWiFi first) * * On startup (you may have to reset the ESP board because it starts up really fast * view the Serial output to see the assigned IP address (if using DHCP) * Or if you want to give the board a static IP (not use DHCP) then uncomment the * following lines in wifiConfig.h and update to your chosen IP address: * #define STATIC_IP_ADDRESS 10,0,0,17 * #define SUBNET_MASK 255,255,255,0 // REQUIRED for ESP8266_WIFI, ignored for others * #define GATEWAY_IP_ADDRESS 0,0,0,0 // REQUIRED for ESP8266_WIFI, ignored for others */ var Firmata = require("firmata").Board; var EtherPortClient = require("etherport-client").EtherPortClient; var board = new Firmata(new EtherPortClient({ host: "", port: 3030 }));
board.on("ready", function() {
  console.log( + "-" +
    board.firmware.version.major + "." +
  var state = 1;
  var lastVal = 0;
  this.pinMode(2, this.MODES.OUTPUT);
  setInterval(function() {
    // blinks the blue LED on a HUZZAH ESP8266 board
    // for other boards, wire an LED to pin 2 or change
    // the pin number below
    this.digitalWrite(13, (state ^= 1));
  }.bind(this), 500);
  // this does not seem to be working - need to look into it
  // one other thing is ESP uses a 1V reference for analog so
  // once this works, it will need scaling
  this.analogRead(0, function(value) {
    if (value != lastVal) {

Step 6: Making It Work

So now after flashing your ESP8266 board with the StandardFirmataWifi firmware and we can run the basic Johnny-five script.


node "your_file_name".js

Change the line name according to your file name you just created.

That's it. You should see the LED attached to pin 13 blink.

Now you can make awesome projects from here. The possiblities are endless. Johnny-five already have a lot of examples.

Again. A big shoutout to anyone who helped this awesome feature be possible. Sorry if a didn't give credit to anyone unintentionally.

Robotics Contest 2016

Participated in the
Robotics Contest 2016