Home | Difficulty level | Advanced | Connecting an ESP8266 to Blynk on WiFi with Johnny-Five (Firmata WiFi)

Connecting an ESP8266 to Blynk on WiFi with Johnny-Five (Firmata WiFi)

In the previous tutorial, we discovered the Johnny-Five framework that allows to create connected objects (and more) based on Arduino, Raspberry Pi (or Orange Pi) in Javascript. Johnny-Five is also a very good solution to replace the GPIO of an Orange Pi by an Arduino Nano v3. In the previous tutorials, we used an Arduino connected to a USB port. In this tutorial, we will use the WiFi Firmata (StandardFirmataWiFi) available from the Arduino IDE which allows you to communicate with an ESP8266 in Wi-Fi.

Why not use the Firmware Serial UDP project?

If you do an internet search with the ESP8266 Johnny-Five keywords, you will also find this Serial UDP firmware project. This firmware is available in the form of a binary which installs with esptool.py of Espressif (read this article for more information). You will first need to install Python 2.7 on your computer. I have encountered difficulties connecting to an ESP8266. This is probably a configuration error. Since the source code is not offered on GitHub (or another platform), I advise you to use the firmwareWiFi that works very well. It is simpler to install and is fully configurable.

Install the StandardFirmataWiFi firmware on the ESP8266

The StandardFirmataWiFi firmware provides access to all Arduino features via a TCP serial link. It is compatible with Arduino shields, Shield 101, MKR1000 cards and all ESP8266. For example, you can add an ESP-01 to an Arduino Uno, which is much cheaper than a WiFi Shield.

Connect the ESP8266 to the computer and open the Arduino IDE. In the examples menu you will find a submenu named Firmata. Select the StandardFirmataWiFi firmware.

ide arduino install firmata

By default, debugging is disabled. Look for the line containing the string #define SERIAL_DEBUG and remove comments (//).

Then go to the wifiConfig.h file to configure the connection parameters

  • Step 3 (or look for ssid): Specify the WiFi network to which the ESP8266 must connect
  • Step 4: Specifies a fixed IP (STATIC_IP_ADDRESS). In this case, the subnet mask (SUBNET_MASK) and the IP of the router (GATEWAY_IP_ADDRESS)
  • Step 5: SERVER_PORT, the server connection port
  • Step 6: The security type of the WiFi network. Defaults to WPA (WIFI_WPA_SECURITY). Complete the password corresponding to the security type (wpa_passphrase for WPA).

The configuration is complete. Upload the program, it’s over!

To verify that everything is correct, open the 9600 baud serial monitor. You can also retrieve the IP address of the ESP8266 if you have not set it.

Example: driving a led, reading a BMP180 in WiFi

Let’s go to the test now. We will take the previous example and adapt it to the new configuration.

Necessary material

esp8266 Wemos D1 mini Wemos D1 Mini
chargeur raspbery pi 3 5v 3000ma 5V/3A micro-usb power supply
BMP180 BMP180
led 3mm Led 
resistance 220ohms 220Ω resistor
jumper dupont Jumper Dupont
breadboard Breadboard


The LED is connected to pin D3 (GPIO-0). On the Wemos D1 mini, the I2C bus (SDA – D2, SCL – D1).

Blynk ESP8266 firmata wifi nodejs johnny-five led bmp180_bb

Javascript code

To establish communication with the ESP8266 we will install the npm etherport-client package (package page)

After the installation is complete, create a new

At the beginning of the script, we will initialize the object that you allow us to establish the serial connection with the ESP8266 in WiFi

To connect to the ESP8266, just create an EtherPortClient object. This object requires two parameters, the IP address of the ESP and the port.

For the rest, the programming is perfectly identical to the previous tutorials.

Why is the npm Firmata package not used?

On the internet, you will find many tutorials that establish communication through the Firmata package. This package allows you to control the GPIO of the Arduino in javascript. This is also the goal of the Johnny-Five framework. The complete API for managing the map is detailed here. In my opinion, it is therefore not necessary to add this “over-layer” to your projects. I did not encounter any difficulties communicating in I2C with the BMP180 and driving the GPIO from the Blynk application.

ESP8266 + Johnny-Five + Blynk

Let’s go one step further by integrating the ESP8266 into Blynk. Thanks to Johnny-Five you will not have any programming to do on the ESP8266. If you’re starting out with Blynk, start here. Here is a diagram showing the architecture of the system. Everything happens in WiFi:

  • The Blynk application runs on a WiFi-connected smartphone (or tablet) to the local Blynk server
  • The Blynk server runs on a Raspberry Pi 3 connected to the WiFi local area network.
  • The javascript code can be run on the Blynk server. Here it runs on an Orange Pi Lite (WiFi, 512MB) itself connected via WiFi to the local Blynk server.
  • The Wemos d1 mini runs on battery power using a battery shield and a 1100mAh LiPo battery.

Blynk Nodejs Johnny-Five ESP8266-Firmata BMP180 raspberry orange pi

Project Bl- ynk

Create a new project and add:

  • 2 Gauges (V0 for temperature and V1 for barometer)
  • 1 switch type switch (V2)

esp8266 johnny-five blynk

Javascript code

Paste the project code into a new script by changing the following parameters:

  • Token: the token of the Blynk project received by email
  • IP of the local Blynk server (how to install a local Blynk server on Raspberry Pi)
  • IP ESP8266
  • Port
Save with CTRL + X then Y and then run the script   node j5ESPDemo.js As you can see in this photograph, the Wemos works on battery (1100 mAh). This is not an ideal situation because you can not take advantage of the ESP8266 standby. This is a good example of architecture that could be set up to develop a remote control.

esp8266 firmata wifi nodejs-johnny-five-bmp180-i2c-led-orange pi lite aspberry pi 3

Here, by installing the StandardFirmataWiFi firmware we cut the cord between the computer (or the mini PC Raspberry Pi …) and the ESP8266. In a few lines of code, it is very simple to drive or recover measurements from an ESP8266 in WiFi.

  • Ayush Jain

    I am a beginner, Could you help me know the how can i used it with ESP8266 with Arduino?

    • Hello Ayush. If you can wait a little, I am writing an article for beginners that should help you a lot. It will be finished in one or two weeks. Subscribe to the newsletter to receive notification by email when it is published. See you soon