Sai Kiran's Blog

Sai Kiran's Blog

Connecting Johnny-five (Arduino, Raspberry Pi etc) over WiFi to the PC using ESP8266

Connecting Johnny-five (Arduino, Raspberry Pi etc) over WiFi to the PC using ESP8266

Subscribe to my newsletter and never miss my upcoming articles

Johnny-five is an amazing framework which allows us to make awesome IOT projects using JavaScript but no system is perfect, it has its own disadvantages, johnny-five uses firmata to communicate with Arduino using a wired connection, which seriously limits its capability, when it comes to portability or flexibility. For example if you want to build a robot you would’t want a wired connection to your laptop always, running behind it with your laptop in hand(though it is a great sight to see lol). So that’s what we are going to solve in this article.

Introducing ESP8266 WiFi module


ESP8266 — (type — ESP-01)

Its a very cheap chip, this tiny device is capable of hosting an access point or you can connect to your existing WiFi and you can interact with it over the internet and it can also be used independently by flashig NODEMCU or similar firmware and the on board GPIOs can be programmed, but that is beyond the scope of this article. Right now we will just hook it up with an Arduino or any Johnny-Five supported device, And yeah this is not the only way either there are several other ways but for a quick and cheap prototype this is the best.

Getting started

I will be using an Arduino UNO and an ESP-01(type of ESP8266).

Firstly, lets install the firmware into the esp8266 chip, you will need a USB-TTL converter for that

USB to TTL USB to TTL converter

It looks like this, while there may be other variants I used this, converters may not supply enough current to the chip, the esp8266 module runs on 3.3V input voltage, you can not use 5v, it will fry the chip, if your converter is not good enough you may face unwanted resets, this chip may not work with the 3.3v on Arduino too, so its better to power it externally.

ESP GPIO Once you are familiar with the pins of the chip we can begin wiring it

USB - ESP connection

Connecting ESP-01 to converter for flashing — Source google

Here is the schematic to connect, ESP8266 to converter and flash the firmware, so that we can later hook it up with Arduino. We used the converter directly to supply power here, in case you used an external power supply, connect the ground of the converter to the ground of external power supply.

Now the fun part starts.

Run the following command in the terminal (command prompt for windows) to clone the GitHub repository. You may have to install python 2.7 for this.

git clone [](

The repository includes the firmware files 0x00000.bin and 0x40000.bin(inside esptool directory), and ofcourse ESPTOOL which can be used to flash our firmware files.

Run the following set of commands to flash the files

#navigate to esptool inside cloned directory
cd johnny-five-esp8266/esptool
#First we need to clear the memory of the chip and existing firmware,
#be sure to replace port with your usb controller address
python --port /dev/ttyUSB0 erase_flash
#now lets flash the firmware, be sure to replace port with your usb controller address
python -p /dev/ttyUSB0 write_flash 0x00000 0x00000.bin 0x40000 0x40000.bin

Now disconnect the USB-TTL converter and get rid of it(connections) all we care about now is the holy grail ESP8266 (LOL).

The sacred bonding

I assume you have already flashed standard firmata on your Arduino or do it (since you were already using johnny-five using a wired connection), so lets wire up ESP8266 to Arduino. Don’t get overwhelmed by the power supply device thingy connected to ESP8266, you can use something else.


Schematics for connections

Connect ESP8266 VCC and CH_PD pins to 3.3v and GND to ground, like I mentioned earlier don’t use 3.3v output of Arduino it doesn’t supply enough current, use an external power supply and make sure you don’t use USB on your Arduino, power it with a 12v power adapter or you may buy a 3.3v and 5v dual regulator to eliminate a wire.

Connect RX of Arduino to TX of ESP8266 and TX of Arduino to RX of ESP8266. You can either connect them directly or you may have to use a level shifter. According to the datasheet ESP can withstand it, unlike VCC which must be connected to 3.3v (Remember do not connect Arduino to USB, use external power supply else you will end up confusing it’s serial communication capabilities, poor thing).

Oh wait further setup is required, there is a sample johnny-five project in the the folder you’ve cloned earlier. It blinks led connected to pin 13. Open the directory in terminal and Run npm install to install the dependencies.

The dependencies are as follows

  1. Johnny-five (of course)
  2. firmata
  3. udp-serial (A wrapper around dgram to create a virtual serial port over udp)

While the dependencies are installing we can setup our ESp8266. If you want to use ESP8266 as an Access Point. Then turn on the power supply and you will find an access point with a name like ESP_XXXX, you can connect to it. By default the network is open, so you may choose to set password. To change Go to . ESP portal Home page at

If you want to connect your ESP8266 to existing network, Connect to ESP_xxx access point first, and navigate to, and click on join setup. Enter the credentials and click on join, your esp may restart, now again connect to ESP_xxx access point and head to Take a note of IP address of your ESP_8266 at STA_SSID. Now you can access this home page at this IP address when you are connected to your existing network. Fetch IP from router settings

Now click on serial setup and change the BAUD rate to 57600(default firmata baud rate), if you choose to use higher baud rate, make sure you’ve flashed your Arduino with the same baud rate. Change the port to 41234(default udp connection port) and click submit. Baudrate Now open index.js and change the IP address, to the IP of your ESP8266.

    var VirtualSerialPort = require('udp-serial').SerialPort;
    var firmata = require('firmata');
    var five = require("johnny-five");
    var sp = new VirtualSerialPort({
    host: '' //make sure to change the ip(use if you are using ESP8266 as Access Point)
    var io = new firmata.Board(sp);
    io.once('ready', function(){
        console.log('IO Ready');
        io.isReady = true;

        var board = new five.Board({io: io, repl: true});

        board.on('ready', function(){
            console.log('five ready');
            var led = new five.Led(13);

Once your dependencies are installed run node index.js .

Voila, we made it. The led is blinking in all its glory of new found freedom. Now you can use this to setup your existing johnny-five project or make a new one. Go build some amazing things.


This article is inspired from the gist at, and amazing work by Riven at .

Share this