Functional Programming with IOT – Chapter 2 : Controlling multiple ESP-01 – Progress Update

In the introduction of this chapter, i mentioned about several technologies that can be used for controlling multiple ESP8266. This blog post explores them further in detail and describes a way of controlling multiple ESP8266 using a javascript v8 library.

The challenging part of controlling multiple ESP8266 is that it is a physical hardware and if i start plugging each one of them onto my machine’s serial port then i will run out of them. Thankfully computer science has already solved this problem by introducing the topic of networking. ESP8266 is a successful IOT module due to its capability to connect to any wireless network, this means we can connect multiple one of them to the same network and send commands to make them do things.

In my day 13 blog post, i explained how to use Firmata to send commands to a ESP-01 module which is connected to your serial port. This blog post is taking the same concept further but instead of using StandardFirmata we will be using StandardFirmataWifi. This gives you the ability to control Firmata over a wireless network and in theory you can interact with multiple one of them. Make sure you have the correct board configuration in your firmata library as described in day 13 blog post as that is a must requirement for ESP-01.

So here is what i did.

I flashed my ESP-01 with a StandardFirmataWifi with custom configuration for my wireless settings as described in the following screenshot:

Wifi Configuration for ESP-01
Wifi Configuration for ESP-01


I then connected this ESP-01 to an independent power supply.

ESP-01 Connected to Independent Power Supply
ESP-01 Connected to Independent Power Supply

Clojure libraries are hard to find for this particular kind of problem and i quickly wanted to test the theory so i went with a javascript v8 solution.

Following is the code that i used to send HIGH and LOW signals on pin 0.

'use strict';

var five = require("johnny-five");
var EtherPortClient = require("etherport-client").EtherPortClient;
// update host to the IP address for your ESP board
var board = new five.Board({
    port: new EtherPortClient({
        host: "", //ESP-01 IP Adress
        port: 3030 //Port that we configured in wifi config
    timeout: 1e5,
    repl: false

board.on("ready", function() {
      var led = new five.Led(0);

Following is my terminal screenshot, as you can see when you connect to the module you get a confirmation or “ready” back which means that you can now start sending HIGH and LOW signals to the module.

Running the code in terminal
Running the code in terminal

Then i verified the packets are being sent out from my machine by using a packet sniffing tool called “wireshark”.

Verifying the TCP Packets are being sent out
Verifying the TCP Packets are being sent out

As you can see we have source which is my host machine and destination which is ESP-01 module. I found out the ip address for the ESP8266 through my wifi router’s admin interface in the connected devices section.

Next, i wanted to verify the output of the signals that i was sending so i used a multimeter to see if the voltage is fluctuating between a HIGH and LOW and it was.

ESP-01 - Voltage High
ESP-01 – Voltage High

This proves that we can connect multiple of them to the same network and send commands to them just by adding multiple boards in the code. But our topic is functional programming with IOT and the language that we chose to demonstrate that it is possible is Clojure. So the next step is to repeat the same experiment but in Clojure Language.

Stay in touch, i will soon be posting an update on that.

Leave a Reply

Your email address will not be published. Required fields are marked *