Control Input Output of ESP8266 with AJAX

I used to brag about Arduino YUN being the IoT enabler. Then came along super cheap ESP8266 but there was an entry barrier to using it as it seemed like someone who is proficient in Electronics only could make it work. Then came companies like Adafruit, Sparkfun, etc who spoon fed the makers with a version of ESP8266 suitable to their skill level. Prior to this I wanted to experiment with it but never did. Then I procured 3 Adafruit ESP8266 Huzzahs and played with LUA programming. Arduino IDE supporting the ESP8266 was icing on the cake as anyone who has worked on Arduino could now work on ESP8266.

Although I have a degree in Electronics Engineering and have done programming in school and college, I have never worked in that field as I work on Computer Networks. I consider makers to be “Jack of all trade, Master of one”, so rather than learning all technologies associated with making, it is helpful if you get related stuff from people who have already done it. So when I find something which has not been documented and can be helpful to others, I write about it. If you have read my post on “Control Input Output of Arduino Yun with AJAX“, I wish to achieve something similar in this article. This post could not have been possible without the help of “ESP8266 Tutorial” as working with YUN HTML is easier than working with HTML on ESP8266. YUN has a separate HTML file and INO file. ESP8266 is having just one file and to put tons of HTML code in it is difficult. The above mentioned article describes how to easily do that.

Continue reading

Advertisements

Control Input Output of Arduino Yun with AJAX

Arduino has gone totally IoT with the Arduino Yun. It has both Wireless and wired connectivity options. IoT doesn’t necessarily mean that it has to deal with Cloud drives, automated inputs, automatic backup to SQL database, etc. It can also mean that your inputs and outputs are user controlled albeit over the Internet. In my previous project, I made a rover which would be controlled by a web interface. Since the webpage was designed such that it would load the whole page depending on each user input (this is how HTML works), many times the http request would timeout as the Arduino was not able to process whole page loads. I had to find out a way in which the web page would not have to change each time I┬áchanged the direction of the rover. This is where AJAX comes into picture. What AJAX enables us to do is send a request to the Arduino and get a reply from the Arduino while not requiring a page reload. Since I learn stuff as and when there is a requirement, I scoured the Internet for folks who had already implemented such a thing. The only article on the Internet which dealt with Arduino Yun and AJAX was “Interact and remotely control Arduino YUN with Ajax” by Boris Landoni. Continue reading