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 192.168.0.18 and the port open in the flashed version of StandardFirmataWifi was 3030.
So here is the code:
(import (java.net Socket)) (def socket (Socket. "192.168.0.18" 3030)) (def SET-PIN-MODE 0xF4) (def RESERVED-COMMAND 0x00) (def DIGITAL-MESSAGE 0x90) (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) (send-command DIGITAL-MESSAGE LOW RESERVED-COMMAND) (send-command DIGITAL-MESSAGE HIGH RESERVED-COMMAND)
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.