Interface and application programming

Weekly_Assignments :

Useful links:

Materials

micro servo

RGB LED

What I want

introduction

The idea was to create a javascript app called via wifi-ip address, running directly on the memory of the esp module and interfaced with the RGB-Servo board executing the color changing and the servo rotation.

What I did

ESP01

At the beginning I have used ESP01 NodeMcu 0.9.4 build 20141230 powered by Lua 5.1.4
but when I started the server from the ip address and recalled my index.html (servo_rgb.html) page with jquery.min.js (to control the operation of the buttons) it didn’t give to any response.
I started to investigate why this happend and I discovered that the memory inside ESP01 is insufficent to “solve” (or charging) jquery.min.js !

OK ! the server HTTP is UP ! on internet via my router and local connect direct by is own network!
great succes!

APP JS

Now I must write some code in javascript and HTML, to put inside a index.html page, served by ESP8266.
In this page I can command servo motor and led rbg, using button.

I start to write the code using jquery.min.js
but…

The library is too slow to have a response on http server over the ESP8266!
So my instructor (Fiore Basile) suggested me to remove the jquery.min.js library, because it is much bigger than what I need for my opertions. Basically, it is unuseful for me. I removed the call to the jquery file from index, and replaced it including the javascript code directly in the page.

Modifying Neil’s sketch “Hello Echo” I made the two rx and tx pins by olimex interface and I connected the rx and tx pins by olimex to the relative reception and trasmission pins on my servo rgb board, that I had predisposed for this purpose.

I set the clock divider, and initialize the servo phase and frequency, frequecy in the case of the micro servo is 20 ms that corresponding at ICR1 = 20000
in order to prevent some strange code passed by TX from ESP8266 I add a condition for execute the code only if the first character is “#”

Thanks to the board that I built in output device I am able to power the wifi module directly via the 3.7V lipo battery (test!).

Esp8266 app + DEMO

Conclusion

I found very interesting sperimenting with this way of writing apps, specially because of applying it on a small device as mine. It wasn’t very hard since I used the samples of the different github distributions: modifying them it is quite easy to get to the result.
Nonetheless I would have liked to write an app using nodejs and I think I will have to develop it for my final project.

I found the main difficulties in the debug phase of the Esp, but I solved them simply changing the module and getting a more powerfull one, even if this is not the way I like the most. The difference between the two pieces is only a couple of dollars and I think that a couple of dollars are really worth it.