FIOT – Chapter 3 – The Demo

Following is the demo that i presented at the Lambda Lounge.

Slides that i prepared but never presented as audience was seeking more excitement, so i went freestyle.



FIOT – Chapter 2 : Controlling multiple ESP-01 – Success !!

Previously, i was controlling the ESP-01 over TCP/IP using NodeJS but my main target from the beginning was to control it using Clojure. I have finally made it just two days before the actual demo in Lambda Lounge.

So all the details are in my previous post, the only difference is that this one is a Clojure version, i will build on top of it to create the demo that i would be presenting on Monday.

Here is a summary if you don’t want to read the previous post, i have flashed StandardFirmataWifi onto an ESP8266 IOT Module, to be specific the module is ESP-01. I am controlling the GPIO pin 0 of that module using Clojure without using any external library.

The communication is carried out using the messages in MIDI format. The IP Address of my ESP-01 on the network was and the port open in the flashed version of StandardFirmataWifi was 3030.

So here is the code:

(import ( Socket))

(def socket (Socket. "" 3030))

(def SET-PIN-MODE     0xF4)
(def PIN              0x00)
(def OUTPUT-MODE      0x01)
(def LOW              0x01)
(def HIGH             0x00)

(defn send-command [& bs]
  (let [out (.getOutputStream socket)]
    (doseq [b bs]
      (.write out b))
    (.flush out)))

(send-command SET-PIN-MODE    PIN  OUTPUT-MODE)

I am going to start building the main demo now and will add pictures for it. Stay in touch with the blog feed if you are interested or just show up in the Lambda Lounge to see the LIVE DEMO.

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.