So here is the working code, which is suppose to talk to StandardFirmata in the ESP8266 and blink an LED. The code compiles properly and runs without any issues. But i don’t see any LED blinking.
Another approach i took was to verify if StandardFirmata is working. I used the Binary file from the project firmata-test and gave it the port my device was connected on. I got a completely blank UI as you can see in the screenshot which suggests there is some problem with the StandardFirmata. It may be incompatible with the type of hardware i am using for this test.
I also have ESP-12 handy, so the next test would be just to verify if StandardFirmata has compatibility issues with the ESP series. But also there is some good news, its about another way of compiling Clojure into binary, it needs more discussion so i will go in detail in the upcoming posts.
Today is the day 2 of the FIOT, as discussed in the previous post i shall be exploring the ESP8266 with a mainstream software engineering functional programming(FP) language.
In my current employment, we work in Clojure due to the language’s pureness and immutability. There is a discussion on StackOverflow that you can follow to read more about it being “probably the closest” to functional.
Following is the picture of the hardware i have chosen for this experiment.
At this stage, we have a set hardware and programming language, now we need some sort of IDE to convert our code into binary right?
Wrong, it is not that simple.
Unfortunately, Clojure cannot be directly compiled into binary at this stage. So we would have to use an intermediate bridge to communicate with the hardware. This is where Firmata comes to the rescue. The concept is that your hardware will run a Firmata protocol server and you will use a client library to instruct the hardware to do the job. It is not ideal but it is one step forward then not using a functional programming language at all.
The Firmata protocol is based on the midi message format but fortunately, we don’t have to learn what they are as the client libraries are a good wrapper. Since we have picked Clojure we have the following client library choices:
I have chosen Clodiuno for this task simply because it has good documentation and the code is straight-forward. I noticed the examples in clj-Firmata are using channels in clojure which i don’t think is needed for a “hello world” program.
Today, i have started exploring how we can use Functional Programming with hardware. Typically, hardware programming is done in C, Assembly or dialects of C/C++. It is easy to compile the code written in those languages and convert it into binary to burn it onto the hardware as a new firmware.
A simple google search will show you that there are people in the past like John Lee who published a book in 1972, who presented the concept of describing hardware as notations. Then in 1985, Meshkinpour and Ercegovac  proposed another Functional Programming style language called FHDL. So the idea about using functional programming with hardware is not new but the approach that has always been taken is to develop a separate language from the mainstream software programming languages and look at hardware as a completely different world.
The book Infrastructure as Code disagrees with the idea that hardware should be treated separately from your software component. The reason for treating hardware separately in the past was that it was expensive and it took more effort to add a new hardware or get a bigger machine for your use case. There is no reason to do that anymore as hardware is more affordable and easily accessible.
So in the upcoming blog posts i shall explore one of the most famous ICs for Internet of Things ESP8266 using a functional programming language. I am interested in hardware parallelisation, performance and code simplicity. Also, i shall explore some design patterns for functional programming languages like function composability.
Lets start this journey!
 J. A. N. Lee, Computer Semantics, Van Nostrand Reinhold Company, 1972.
 F. Meshkinpour and M. D. Ercegovac, “A functional language for description and design of digital systems: sequential constructs,” in Proceedings of the 22nd ACM/IEEE Conference on Design Automation, pp. 238–244, ACM Press, 1985. View at Scopus
 M. D. Ercegovac and T. Lang, “A high-level language approach to custom chip layout design,” Technical Report MICRO Project Reports 1982-83, University of California, Berkeley, Calif, USA, 1982. View at Google Scholar