After yesterday’s success with Firmata installation i decided to progress and test the ESP-01 with Clojure. The idea was to test each pin and see if i can send HIGH and LOW signals on the output.
I wrote the following piece of code to test it. The full project can be found on my github.
(ns firmata-test.core (:require [clodiuno.core :refer :all] [clodiuno.firmata :refer :all])) (defn -main  (let [board (arduino :firmata "/dev/tty.wchusbserial1450")] ;;allow arduino to boot (Thread/sleep 1000) (pin-mode board 0 OUTPUT) (while true (doseq [x (list 0)] (println x) (println "HIGH") (digital-write board x HIGH) (Thread/sleep 6000) (println x) (println "LOW") (digital-write board x LOW)) (Thread/sleep 6000)) (close board)))
Using the Cloudiuno library, this code is testing the HIGH and LOW signals on PIN 0 with a 6 seconds delay.
I used a voltmeter to see if the voltage was changing after 6 seconds. So this is what i could see on my terminal while it was running.
And i had a voltmeter attached to the PIN 0 of ESP-01 to see if the voltage was actually changing. You would need a voltmeter to check if the voltage is changing after 6 seconds.
Then after 6 seconds,
During this experiment i noticed that the signal value was inversely proportional to the voltage that was being displayed on the multi-meter. I am still not sure why that happened. Could it be a bug in the library ?
Anyways, this is a great success as now we can finally use Clojure (The Functional Language of our choice) to program hardware such as the famous IOT module called “ESP8266” or to be more specific ESP-01.
I ordered few more of these from China which has now been delivered so i am thinking of a way to use them to prepare a good demo.
Wish me luck.. this is not the end, this is just the start so keep following !